master
1import { Commit, define, latest } from '#src'
2
3export default define({
4 url: import.meta.url,
5 badges: ['summer-solstice-commits', 'winter-solstice-commits'] as const,
6 present(data, grant) {
7 const summerSolsticeCommits: Commit[] = []
8 const winterSolsticeCommits: Commit[] = []
9
10 for (const repo of data.repos) {
11 for (const commit of repo.commits) {
12 const date = new Date(commit.committedDate)
13 // June 21st, approx. 15:00 UTC
14 if (
15 date.getMonth() === 5 &&
16 date.getDate() === 21 &&
17 date.getUTCHours() >= 14 &&
18 date.getUTCHours() < 16
19 ) {
20 summerSolsticeCommits.push(commit)
21 }
22 // December 21st, approx. 22:00 UTC
23 if (
24 date.getMonth() === 11 &&
25 date.getDate() === 21 &&
26 date.getUTCHours() >= 21 &&
27 date.getUTCHours() < 23
28 ) {
29 winterSolsticeCommits.push(commit)
30 }
31 }
32 }
33
34 if (summerSolsticeCommits.length > 0) {
35 grant(
36 'summer-solstice-commits',
37 'I commit in the Summer solstice.',
38 ).evidenceCommits(...summerSolsticeCommits.sort(latest).slice(0, 6))
39 }
40 if (winterSolsticeCommits.length > 0) {
41 grant(
42 'winter-solstice-commits',
43 'I commit in the Winter solstice.',
44 ).evidenceCommits(...winterSolsticeCommits.sort(latest).slice(0, 6))
45 }
46 },
47})