feat: timed calendar events with DST-aware timezones #3

Merged
freemasen merged 1 commit from ada/nba-calendar-utility:feat/timed-events into main 2026-05-20 00:10:16 +00:00
Contributor

What

Changes calendar events from all-day to timed events that appear at the scheduled game time, with daylight saving time handled automatically.

How

  • Added src/timezones.js — maps every NBA and WNBA team tricode to its IANA timezone (e.g. NYK → America/New_York, PHX → America/Phoenix)
  • Updated Game.toCalendarEvent() to use Google Calendar's dateTime + timeZone format instead of date (all-day)
    • Converts UTC start time → arena local wall-clock time using Intl.DateTimeFormat with the home team's timezone
    • Adds a 2.5-hour duration as the end time (also in the arena's timezone)
    • Summary shows the local start time in the arena's timezone

DST handling

Google Calendar uses the timeZone field to display the event at the correct wall-clock time for the viewer. DST transitions are handled by the IANA timezone database — for example:

Game UTC time Arena timezone Displays as
2025-03-15T00:30Z America/New_York (EDT) Mar 14, 7:30 PM
2025-07-15T23:30Z America/New_York (EDT) Jul 15, 7:30 PM
2025-11-01T02:30Z America/Los_Angeles (PDT) Oct 31, 7:30 PM
2025-11-03T02:30Z America/Los_Angeles (PST) Nov 2, 6:30 PM
2025-03-15T02:00Z America/Phoenix (MST, no DST) Mar 14, 7:00 PM

Phoenix (Arizona) never observes DST, which is handled correctly by using America/Phoenix instead of America/Denver.

Files changed

  • src/timezones.js (new) — team tricode to IANA timezone mapping
  • src/game.js — toCalendarEvent() now produces timed events with timezone
  • README.md — updated description to reflect timed events
## What Changes calendar events from all-day to timed events that appear at the scheduled game time, with daylight saving time handled automatically. ## How - Added `src/timezones.js` — maps every NBA and WNBA team tricode to its IANA timezone (e.g. NYK → America/New_York, PHX → America/Phoenix) - Updated `Game.toCalendarEvent()` to use Google Calendar's `dateTime + timeZone` format instead of `date` (all-day) - Converts UTC start time → arena local wall-clock time using `Intl.DateTimeFormat` with the home team's timezone - Adds a 2.5-hour duration as the end time (also in the arena's timezone) - Summary shows the local start time in the arena's timezone ## DST handling Google Calendar uses the `timeZone` field to display the event at the correct wall-clock time for the viewer. DST transitions are handled by the IANA timezone database — for example: | Game UTC time | Arena timezone | Displays as | |---|---|---| | 2025-03-15T00:30Z | America/New_York (EDT) | Mar 14, 7:30 PM | | 2025-07-15T23:30Z | America/New_York (EDT) | Jul 15, 7:30 PM | | 2025-11-01T02:30Z | America/Los_Angeles (PDT) | Oct 31, 7:30 PM | | 2025-11-03T02:30Z | America/Los_Angeles (PST) | Nov 2, 6:30 PM | | 2025-03-15T02:00Z | America/Phoenix (MST, no DST) | Mar 14, 7:00 PM | Phoenix (Arizona) never observes DST, which is handled correctly by using `America/Phoenix` instead of `America/Denver`. ## Files changed - `src/timezones.js` (new) — team tricode to IANA timezone mapping - `src/game.js` — toCalendarEvent() now produces timed events with timezone - `README.md` — updated description to reflect timed events
Events now appear at their scheduled start time in the arena's local
timezone instead of as all-day events. Google Calendar handles DST
automatically via the IANA timeZone field.

- Add src/timezones.js: maps team tricodes → IANA timezones
  (covers all 30 NBA + WNBA teams, Phoenix correctly uses
  America/Phoenix which doesn't observe DST)
- Update Game.toCalendarEvent() to use dateTime + timeZone
  instead of all-day date, with Intl.DateTimeFormat to convert
  UTC → arena local wall-clock time
- Add 2.5-hour event duration as end time
- Summary still shows local start time, now in the arena's timezone
  rather than the user's system timezone
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
freemasen/nba-calendar-utility!3
No description provided.