From 0abb5fcd4f0ac4999645899f6999a399670a6dba Mon Sep 17 00:00:00 2001 From: nishtha-agarwal-211 Date: Sun, 23 Aug 2026 11:10:28 +0530 Subject: [PATCH] fix(dateHelpers): evaluate processCommitTimestamps in a timezone-agnostic manner --- utils/dateHelpers.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/utils/dateHelpers.ts b/utils/dateHelpers.ts index ae72c58a2..79ae7aca0 100644 --- a/utils/dateHelpers.ts +++ b/utils/dateHelpers.ts @@ -12,15 +12,13 @@ export function processCommitTimestamps(commitDates?: (string | Date)[] | null): return metrics; } - commitDates.forEach((dateString) => { - if (!dateString) return; - const date = new Date(dateString); + commitDates.forEach((dateItem) => { + if (!dateItem) return; + const date = new Date(dateItem); if (isNaN(date.getTime())) return; - // Use getUTCHours() instead of getHours() to ensure timezone-agnostic - // results — getHours() returns local time which causes test failures - // in non-UTC timezones like IST (UTC+5:30). - const hour = date.getUTCHours(); + const hour = + typeof dateItem === 'string' ? getAuthorLocalHour(dateItem) : dateItem.getUTCHours(); if (hour >= 6 && hour < 12) { metrics.morning++;