@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.
22 lines • 1.42 kB
TypeScript
import { Temporal } from "./temporal.js";
import { RoundingOptions } from "../types/rounding-options.js";
import "../types/index.js";
/**
* `start.until(end, { largestUnit, ...rounding })` for two PlainDates in the same calendar.
*
* - Without rounding options the difference goes through the Temporal compat layer's
* `calendarDateUntil`, which is the polyfill's own `until` for `iso8601` and the TC39
* `NonISODateUntil` answer for other calendars (CORE-6 D1, D6, D7 and the corrected calendars).
* - With `smallestUnit`, `roundingIncrement` or `roundingMode`, a calendar whose compat is needed
* goes through `plainDateUntilWithRounding` (TC39 `DifferenceTemporalPlainDate` in the plain
* context, `GetUTCEpochNanoseconds`); every other calendar is the polyfill's own `until`.
*
* @param start PlainDate the difference starts from
* @param end PlainDate in the same calendar
* @param largestUnit a date unit, singular or plural
* @param options optional DifferenceOptions rounding controls
* @returns the difference as a Temporal.Duration; throws RangeError on invalid input
*
* @example plainDateUntil(Temporal.PlainDate.from("2024-01-31"), Temporal.PlainDate.from("2024-03-01"), "months").toString() // "P1M1D"
*/
export declare function plainDateUntil(start: Temporal.PlainDate, end: Temporal.PlainDate, largestUnit: string, options?: RoundingOptions<Temporal.DateUnit>): Temporal.Duration;