From 8387ed5a337c234e465fd176490ef0b6a3900afe Mon Sep 17 00:00:00 2001 From: nishupr Date: Sun, 21 Jun 2026 20:57:32 +0530 Subject: [PATCH] fix(wrapped): use tz parameter for default year calculation The default year (when customYear is not provided) was calculated using the server's local timezone via new Date().getFullYear(), even though the route already accepts and uses a tz parameter for timezone-aware data fetching elsewhere in the same handler. This caused a mismatch near year boundaries for users in timezones different from the server. Now uses Intl.DateTimeFormat with the provided tz, consistent with the pattern in app/api/streak/route.ts. Closes #6242 --- app/api/wrapped/route.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/api/wrapped/route.ts b/app/api/wrapped/route.ts index 7c45a7355..17637e778 100644 --- a/app/api/wrapped/route.ts +++ b/app/api/wrapped/route.ts @@ -60,7 +60,11 @@ export async function GET(request: Request) { tz, } = parseResult.data; - const year = customYear || new Date().getFullYear().toString(); + const year = + customYear || + (tz + ? new Intl.DateTimeFormat('en-CA', { timeZone: tz, year: 'numeric' }).format(new Date()) + : new Date().getFullYear().toString()); const themeName = theme || 'dark'; const isAutoTheme = themeName === 'auto';