DST transitions handled; gap or overlap slots are skipped or disambiguated
Why it matters
DST transitions create two temporal anomalies that break naive slot generators: a spring-forward gap (2:00–2:59 AM does not exist) and a fall-back overlap (1:00–1:59 AM occurs twice). CWE-682 (Incorrect Calculation) and ISO 25010 functional correctness both apply. A slot generator that iterates wall-clock minutes without DST awareness will produce bookable slots at 2:30 AM on the spring transition — a time that literally does not exist in that timezone. When a customer confirms such a booking, the confirmation timestamp resolves to an ambiguous or invalid time, causing silent downstream errors in reminders, calendar exports, and host notifications.
Severity rationale
Info because DST failures affect only two days per year in affected timezones, but on those days they can produce invalid appointment times that propagate silently through reminders and exports.
Remediation
Generate slots in UTC and convert to the display timezone using an IANA library rather than iterating local wall-clock minutes. IANA libraries skip spring-gap times automatically.
// src/lib/availability.ts
import { toZonedTime } from 'date-fns-tz'
export function generateSlots(date: Date, tz: string, stepMinutes = 30): Date[] {
const slots: Date[] = []
const startUtc = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))
for (let i = 0; i < 24 * 60; i += stepMinutes) {
const utcSlot = new Date(startUtc.getTime() + i * 60_000)
try {
const zoned = toZonedTime(utcSlot, tz)
slots.push(zoned)
} catch {
// Non-existent DST gap time — skip
}
}
return slots
}
For fall-back overlaps, store the UTC value rather than the local wall-clock time so the two 1:30 AM slots are unambiguous in the database.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Calendar & Availability Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-682 — Incorrect Calculation — manual offset arithmetic produces invalid slot times during DST gaps
- iso-25010:2011 · functional-correctness — Functional Correctness — slot generation must not produce non-existent DST gap times
Taxons
History
- 2026-04-18·v1.0.0·Initial import from booking-calendar-availability·automated