diff --git a/lib/validations.ts b/lib/validations.ts index 744c84a47..01d096533 100644 --- a/lib/validations.ts +++ b/lib/validations.ts @@ -321,7 +321,7 @@ const baseStreakParamsSchema = z.object({ (val) => { if (!val) return true; const yearNum = parseInt(val, 10); - const currentYear = new Date().getFullYear(); + const currentYear = new Date().getUTCFullYear(); return /^\d{4}$/.test(val) && yearNum >= 2008 && yearNum <= currentYear; }, { @@ -672,7 +672,7 @@ export const wrappedParamsSchema = z.object({ (val) => { if (!val) return true; const yearNum = parseInt(val, 10); - const currentYear = new Date().getFullYear(); + const currentYear = new Date().getUTCFullYear(); return /^\d{4}$/.test(val) && yearNum >= 2008 && yearNum <= currentYear; }, { diff --git a/lib/validations.year.test.ts b/lib/validations.year.test.ts index 5830012d0..d33c8ec07 100644 --- a/lib/validations.year.test.ts +++ b/lib/validations.year.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect } from 'vitest'; import { streakParamsSchema, wrappedParamsSchema } from './validations'; -const CURRENT_YEAR = new Date().getFullYear(); +const CURRENT_YEAR = new Date().getUTCFullYear(); const EXPECTED_ERROR = 'GitHub was founded in 2008. Please provide a year of 2008 or later.'; function getYearError(result: {