calendar
๐ ๐จโ๐ป
We all know that working with date and calendar can be quite a pain in the neck.
For example, even github doesnโt handle correctly the calendar display (https://github.com/orgs/community/discussions/74391) - because of leap year starting on sunday.
This tiny library (https://github.com/Its-Just-Nans/go-calendar) can create a svg calendar for you.
- https://en.wikipedia.org/wiki/Leap_year_starting_on_Saturday
- https://en.wikipedia.org/wiki/Century_leap_year
- https://github.com/Its-Just-Nans/go-calendar
- https://pkg.go.dev/github.com/Its-Just-Nans/go-calendar
Example to generate calendar from Github contributions
Using gh api and jq, you can get your contributions from Github with
gh api graphql -F owner='Its-Just-Nans' -f query='
query( $owner: String!) {
user(login: $owner) {
contributionsCollection {
contributionCalendar {
totalContributions
weeks {
contributionDays {
contributionCount
weekday
date
}
}
}
}
}}' | jq '[.data.user.contributionsCollection.contributionCalendar.weeks | .[].contributionDays |.[] | {date: (.date), num:(.contributionCount)}]' > out.json
Then you can generate the calendar with
go run github.com/Its-Just-Nans/go-calendar@latest -k date -c num -i out.json -o contributions.svg