DEV Community

desgh white
desgh white

Posted on

Handling Time Zones in a Global Event Scheduler

A scheduler that works in UTC and converts only at display time is the standard advice. It is also wrong for a subset of cases: recurring events that the user intends to happen at a local time regardless of DST shifts.

Store the intent, not the instant

For a one-off event, store a UTC timestamp. For a recurring event, store the local time plus the IANA zone:

interface RecurringEvent {
  localTime: string;  // "14:30"
  tz: string;         // "Australia/Sydney"
  rrule: string;      // "FREQ=DAILY"
}
Enter fullscreen mode Exit fullscreen mode

When computing the next occurrence, resolve localTime in the given zone at that future date — not today's offset:

import { DateTime } from 'luxon';

function nextOccurrence(event: RecurringEvent): DateTime {
  const now = DateTime.now().setZone(event.tz);
  let next = now.set({ hour: 14, minute: 30, second: 0 });
  if (next <= now) next = next.plus({ days: 1 });
  return next;  // handles DST automatically
}
Enter fullscreen mode Exit fullscreen mode

The Australia edge case

Australia has zones that shift by 30 minutes (Adelaide, +09:30 / +10:30). An event platform serving Australian users like Herovegas needs to handle half-hour offsets; truncating to whole hours breaks scheduling twice a year.

Display

Always show the user's local time first, with an optional UTC parenthetical:

Starts: 2:30 PM AEDT (03:30 UTC)
Enter fullscreen mode Exit fullscreen mode

Never show just UTC — most users cannot do the conversion in their head, especially with half-hour offsets.

Takeaway

UTC-only storage is correct for instants. For recurring events, store the zone and resolve lazily. The two patterns coexist in any non-trivial scheduler.

Top comments (0)