Commit 861eb58

Dan Carroll <dancarroll@gmail.com>
2024-12-19 17:06:30
Add new badge that is granted for committing code on a Leap day (#104)
* Add support for guessing Boston/MA timezones * Add new badge that is granted for committing code on a Leap day * Change date back to the 29th * Remove unnecessary src/all-badges/leap-day * Update badge image to frog
1 parent e9e62b1
Changed files (3)
badges/leap-day/leap-day.png
Binary file
badges/leap-day/leap-day.ts
@@ -0,0 +1,25 @@
+import { Commit, define, latest } from '#src'
+
+export default define({
+  url: import.meta.url,
+  badges: ['leap-day'] as const,
+  present(data, grant) {
+    const commits: Commit[] = []
+
+    for (const repo of data.repos) {
+      for (const commit of repo.commits) {
+        const data = new Date(commit.committedDate)
+        if (data.getMonth() === 1 && data.getDate() === 29) {
+          commits.push(commit)
+        }
+      }
+    }
+
+    if (commits.length > 0) {
+      grant(
+        'leap-day',
+        'Happy February 29th! I committed on a Leap Day!',
+      ).evidenceCommits(...commits.sort(latest).slice(0, 6))
+    }
+  },
+})
badges/index.ts
@@ -12,6 +12,7 @@ export default [
   await import('./favorite-word/favorite-word.js'),
   await import('./fix-commit/fix-commit.js'),
   await import('./github-anniversary/github-anniversary.js'),
+  await import('./leap-day/leap-day.js'),
   await import('./mass-delete-commit/mass-delete-commit.js'),
   await import('./my-badges-contributor/my-badges-contributor.js'),
   await import('./old-issue/old-issue.js'),