getDstTransitions
Signature
Section titled “Signature”getDstTransitions(timeZone: string, year: number): DstTransition[]import { getDstTransitions } from "@northguild/gmt/zoned/get";List every DST transition instant for an IANA timezone within a given year.
- A “transition” is any UTC offset change: a spring-forward gap (nonexistent local time) or a fall-back overlap (ambiguous local time) — see
docs/dst-disambiguation.mdfor the gap/overlap terminology. This is distinct fromhasDaylightSaving(whether a zone observes DST at all) and from thedisambiguation/offsetoptions (what to do when constructing a single instant that lands in a gap/overlap). - Most zones have 0 or 2 transitions per year; some (e.g.
Africa/Casablanca, which pauses DST for Ramadan) can have more. - Returns
[]for an invalid timeZone, a non-integer year, or a valid zone with zero transitions in that year (not an error case).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
timeZone |
string |
IANA timeZone identifier |
year |
number |
calendar year to scan (must be an integer) |
Returns
Section titled “Returns”array of { instant, offsetBefore, offsetAfter }, in chronological order
Related types
Section titled “Related types”Examples
Section titled “Examples”getDstTransitions("America/New_York", 2024)// [// { instant: "2024-03-10T07:00:00Z", offsetBefore: "-05:00", offsetAfter: "-04:00" },// { instant: "2024-11-03T06:00:00Z", offsetBefore: "-04:00", offsetAfter: "-05:00" },// ]getDstTransitions("Asia/Tokyo", 2024) // []getDstTransitions("Invalid/Zone", 2024) // []