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.

30 lines • 2.15 kB
import { Temporal } from "../temporal.js"; import { DurationRoundOptions, RoundingSettings, Unit } from "./operations.js"; /** * True when a length from `zoned` must take the spec path (defect 5): the runtime would mismeasure * it, or the specification has no value for it. `length` is the target's exact time, or a duration * to add to `zoned`. At most four wall-clock resolutions, and no loop. * * - `zoned` is either pass of a repeated wall clock, which the runtime mismeasures. * - `target` is. A forward window's end bound can only fall short of the target when its nominal wall * clock is past the target's and its exact time is before it, so a backward transition lies between * them and the target's wall clock repeats. A date difference that disagrees in sign needs the same. * - `target` is earlier, and the window's end bound is in a gap. Its nominal wall clock is at or * before the target's, and `"compatible"` moves it forward past the target. The bound falls at * the origin's time of day, on the target's date or the one before it, as a gap is at most 24 hours. * * An addition that throws, or a wall clock that cannot be resolved near a range limit, is left to the * range-limit fallbacks. */ export declare function originNeedsSpecPath(zoned: Temporal.ZonedDateTime, length: bigint | Temporal.Duration): boolean; /** * Defect 5: `Duration#total` by the spec when `originNeedsSpecPath` holds. Time units subtract exact * times, so only a date unit can reach it. Where the specification has no value this throws. */ export declare function originTotalBySpec(duration: Temporal.Duration, unitOption: string, unit: Unit, zoned: Temporal.ZonedDateTime | null): number | null; /** * Defect 5: `Duration#round` by the spec when `originNeedsSpecPath` holds. The `largestUnit` decides: * a date one builds a date difference even when `smallestUnit` is an hour. Where the specification * has no value this throws. */ export declare function originRoundBySpec(duration: Temporal.Duration, roundTo: DurationRoundOptions, settings: RoundingSettings, zoned: Temporal.ZonedDateTime | null): Temporal.Duration | null;