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