Skip to content
Timezones & DST Edge Cases
step 1/5

Reading — step 1 of 5

Read

~1 min readSchedule Computation

Timezones & DST Edge Cases

DST (Daylight Saving Time) creates two thorny cases:

Spring-forward (the gap) — On the day clocks jump from 2:00am to 3:00am, 2:30am does not exist. A cron entry like 30 2 * * * should fire once at 3:00am (the next valid time), not skip the day entirely.

Fall-back (the overlap) — On the day clocks repeat 1:00am-2:00am, a cron entry like 30 1 * * * could fire twice. Most schedulers (cron itself, k8s CronJob) fire exactly once on the first occurrence.

The safe algorithm: schedule in UTC. Convert the user's tz to UTC at storage time, do all next_run() math in UTC, then convert back for display. This sidesteps DST entirely — but it changes when "midnight in Tokyo" lands on the wall clock if the user's tz changes.

Real-world cron uses local time and accepts the DST edge cases. Modern schedulers (k8s, systemd timers) let you specify the timezone explicitly.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…