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.



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