Europe changed clocks on Sunday, the US does it next Sunday. Check your scheduled posts
说明与用途
在欧洲和美国夏令时转换周,使用固定偏移量的计划任务会错过一小时。解决方案是存储 IANA 时区,在运行时计算 UTC,给 cron 绑定时区,并对模糊时间进行幂等处理。
问题
Scheduled jobs, social posts, newsletters, and cron tasks misfire by an hour during the week when Europe and the US change daylight‑saving time offsets.
结果
By storing IANA zone names, computing UTC instants at run time, pinning cron zones, handling ambiguous hours idempotently, and updating the UI, scheduled tasks no longer misfire during DST transitions.
工作流
- Identify scheduled items stored with raw offsets and convert them to IANA zone names.
- Compute the next run UTC instant using the zone and local time (e.g., with Luxon’s setZone and plus).
- Pin cron jobs to the correct zone (CRON_TZ or node‑cron timezone option) or schedule hourly and check local time inside the job.
- Make jobs idempotent for ambiguous hours by using a run key such as jobId+localDate.
- Update UI to show the audience’s time zone next to the scheduled time.
- Audit the database or sheet for raw offsets, list items between now and Nov 2 that cross the US/EU gap, and test cross‑zone scheduling this week.
证据
Storing "9:00 +02:00" instead of "9:00 Europe/Madrid"
Store the IANA zone name next to the local time and compute the UTC instant for each run, not once at creation time.
Server cron in UTC, humans thinking in local time
Make jobs idempotent with a run key like jobId + localDate so the second one is a no‑op.
Show the audience’s zone next to the time, always.
- 记录日期: 2026-10-27T09:26:26.624Z