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.

40 lines • 2.36 kB
import { Temporal } from "../temporal.js"; import { DurationRelativeTo } from "../../types/duration-relative-to.js"; import "../../types/index.js"; import { DurationRoundOptions, RoundingSettings, Unit } from "./operations.js"; /** * Units whose nudge window can miss its target: only a month, or a year that carries months with it. * A week or a day is a fixed count of days, so `relativeTo + r1 units` never has to constrain. */ export declare function isNudgeWindowUnit(unit: Unit | undefined): boolean; /** * Defect 4: `Duration#total` by the spec when the polyfill would divide the month fraction by the * wrong month. Returns null whenever the defect cannot apply, leaving the polyfill's own answer. */ export declare function monthTotalBySpec(duration: Temporal.Duration, unitOption: string, unit: Unit, relativeTo: DurationRelativeTo | undefined, zoned: Temporal.ZonedDateTime | null): number | null; /** * Defect 4: `Duration#round` by the spec when the polyfill would round over a nudge window that * does not contain the target. Returns null whenever the defect cannot apply, leaving the * polyfill's own answer. */ export declare function monthRoundBySpec(duration: Temporal.Duration, roundTo: DurationRoundOptions, settings: RoundingSettings, zoned: Temporal.ZonedDateTime | null): Temporal.Duration | null; /** * `PlainDateTime#until` / `#since`, correct when the polyfill would round over a nudge window that * does not contain the target (defect 4). * * The plain difference functions round through the polyfill directly, because neither the range * limits nor the non-ISO calendars reach them the way they reach the zoned ones. A calendar * `smallestUnit` measured from a day that a month add would constrain is the one case that does, so * it takes the spec path and everything else stays the polyfill's own call. * * @param one the earlier plain datetime * @param two the later plain datetime * @param options Temporal difference options, passed through unchanged when the defect cannot apply * @returns the difference; throws where TC39 Temporal throws */ export declare function plainUntilWithRounding(one: Temporal.PlainDateTime, two: Temporal.PlainDateTime, options?: { largestUnit?: unknown; smallestUnit?: unknown; roundingIncrement?: number; roundingMode?: Temporal.RoundingMode; }): Temporal.Duration;