Skip to content

feat: add timezone selector and fix timezone conversion bug - #127

Merged
Railly merged 1 commit into
crafter-station:mainfrom
webtaken:webtaken/timezone-selector-fix
May 25, 2026
Merged

feat: add timezone selector and fix timezone conversion bug#127
Railly merged 1 commit into
crafter-station:mainfrom
webtaken:webtaken/timezone-selector-fix

Conversation

@webtaken

Copy link
Copy Markdown
Collaborator

Summary

  • Add a LATAM timezone selector (19 timezones) to the event creation/edit form using SearchableSelect
  • Fix bug where event dates were stored with wrong UTC offset due to timezone-unaware parsing

Bug Details

When creating an event with a non-default timezone, dates were stored incorrectly. The form sent bare datetime strings (e.g. 2026-03-28T22:45) which new Date() parsed in the server's local timezone instead of the event's selected timezone.

Example: Creating an event at 10:45 PM Buenos Aires (ART, UTC-3):

  • Expected in DB: 2026-03-29T01:45:00Z (22:45 + 3h)
  • Actual in DB: 2026-03-29T03:45:00Z (parsed as server timezone UTC-5 instead)

This caused the detail page to show "domingo 29 de marzo, 12:45 AM (ART)" instead of the correct "sábado 28 de marzo, 10:45 PM (ART)", and the countdown to display ~4h 52m instead of ~2h 52m.

Fix

Use fromZonedTime() from date-fns-tz to properly convert local event times to UTC before storage, in both createEvent and updateEvent flows.

Files Changed

  • lib/event-utils.ts — Export TIMEZONE_ABBRS at module level, add TIMEZONE_OPTIONS
  • lib/actions/events.ts — Use fromZonedTime() for date conversion in createEvent
  • components/org/creation/org-event-form-minimal.tsx — Add timezone selector, use fromZonedTime() in edit mode

Test plan

  • Create event with Buenos Aires timezone at a specific time, verify DB stores correct UTC
  • Verify detail page shows the time in the event's timezone with correct label (ART)
  • Verify countdown shows correct time remaining relative to viewer's local time
  • Edit an existing event, verify timezone pre-populates correctly
  • bun run build passes

🤖 Generated with Claude Code

@vercel

vercel Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

@webtaken is attempting to deploy a commit to the Crafter Station Team on Vercel.

A member of the Team first needs to authorize it.

Add a LATAM timezone selector to the event creation and edit form.

Convert event-local date inputs with fromZonedTime before storing UTC timestamps.

Pre-fill edit form date and time values in the event timezone instead of the browser timezone.
@Railly
Railly force-pushed the webtaken/timezone-selector-fix branch from d260d38 to 7aeaf03 Compare May 25, 2026 18:42
@Railly
Railly merged commit 0723041 into crafter-station:main May 25, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants