Skip to content

isInDaylightSaving

isInDaylightSaving(value: string): boolean
import { isInDaylightSaving } from "@northguild/gmt/zoned/compare";

Check whether a zoned value’s instant falls within daylight saving time.

  • The third DST-related function in the roadmap, and distinct from the other two — see docs/dst-disambiguation.md for the full four-way split: hasDaylightSaving(timeZone) asks whether a zone observes DST at all (zone-level, no instant); listDstTransitions(timeZone, year) asks where a zone’s transitions fall (enumerates instants); isInDaylightSaving(value) asks whether this particular instant is currently in DST. disambiguation/offset (Group C) are a fourth, orthogonal concern: what to do when construction lands on an ambiguous or nonexistent instant.
  • Returns false for invalid input, and false for a zone that doesn’t observe DST at all.
Parameter Type Description
value string zoned ISO 8601 datetime string

true if the instant is in daylight saving time, false otherwise or on invalid input

isInDaylightSaving("2024-07-15T12:00:00-04:00[America/New_York]") // true
isInDaylightSaving("2024-01-15T12:00:00-05:00[America/New_York]") // false
isInDaylightSaving("2024-01-15T12:00:00+11:00[Australia/Sydney]") // true (southern-hemisphere summer)
isInDaylightSaving("2024-07-15T12:00:00+09:00[Asia/Tokyo]") // false (Asia/Tokyo has no DST)
isInDaylightSaving("invalid") // false

zoned/compare/isInDaylightSaving.ts