UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

33 lines • 1.94 kB
import { Temporal } from "./temporal.js"; /** * Whether an instant is in daylight saving time, read from the zone's offset changes alone. * * The rule: daylight time runs from a forward change of the clocks to the backward change that * undoes it. A backward change undoes the most recent forward change of the same size that is not * yet undone, and only if it comes less than 365 days after it. An instant is in daylight time when * it is at or after such a forward change and before the backward change paired with it. * * A forward change that is never undone, or undone a year or more later, is a change of standard * time (`Europe/Istanbul` 2016, `Europe/Moscow` 2011 to 2014), as is any backward change with no * forward change to undo (`Asia/Almaty` 2024). * * This is GMT's own definition, not the tz database's daylight flag, which no JavaScript API * exposes and offsets do not determine. * * Cost: one transition lookup forward, then one back, and more only outside the ordinary summer * case. A paired change is less than 365 days away, so every lookup is given that limit and reads * no further: with GMT's own search (temporalCompat D13) at most 74 offset samples and 51 reads to * pin a change, for any zone and any instant. * * @param zoned the instant, in the zone to read * @returns true in daylight time, false in standard time or when the walk exceeds its bound */ export declare function isInDaylightTime(zoned: Temporal.ZonedDateTime): boolean; /** * Whether a zone observes daylight saving time as of an instant: the instant is in daylight time, * or a daylight period begins within the 365 days after it. Same rule as `isInDaylightTime`. * * @param zoned the instant to judge from, in the zone to read * @returns true when the zone observes daylight time then, false otherwise or past the walk bound */ export declare function observesDaylightTime(zoned: Temporal.ZonedDateTime): boolean;