Skip to content

Conversation

@Bima42
Copy link
Contributor

@Bima42 Bima42 commented Dec 21, 2025

What is this PR about?

Problem:
The TimeBadge component was always displaying UTC+00:00 regardless of the actual server timezone.

The client was calculating the offset by converting dates to strings using toLocaleString, then parsing those strings back into Date objects. When JavaScript parses a date string like "1/15/2025, 9:00:00 AM" with new Date(), it interprets it in the browser's local timezone, not the intended timezone. Both dates ended up in the same timezone, so the offset was always zero.

Fix:
I moved the offset calculation to the server side. The server now returns the offset along with the timezone and time. We use Intl.DateTimeFormat.

Extracted the offset calculation logic to utils/time.ts as getUtcOffset(timeZone) with comprehensive tests covering various timezones including edge cases like half-hour offsets (India UTC+05:30), invalid inputs, and the UTC special case.

Issues related (if applicable)

closes #3328

@Bima42 Bima42 requested a review from Siumauricio as a code owner December 21, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant