@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
27 lines (26 loc) • 1.38 kB
TypeScript
import type { Temporal } from "@js-temporal/polyfill";
import type { DateTimeUnit } from "../types/index.js";
/**
* Return the start of the specified date-time `unit` for a `Temporal.ZonedDateTime`.
*
* - Always uses Monday as the week start (consistent with `startOfZoned` semantics).
* - Day-and-below units truncate by instant via `round({ roundingMode: "trunc" })`, which
* resolves DST correctly — a local day whose midnight is skipped starts at 01:00.
* - Does NOT validate the unit — caller ensures it is a DateTimeUnit.
*
* @param source Temporal.ZonedDateTime to truncate
* @param unit DateTimeUnit to truncate to
* @returns Temporal.ZonedDateTime at the start of the specified unit
*/
export declare function getStartOfZonedUnit(source: Temporal.ZonedDateTime, unit: DateTimeUnit): Temporal.ZonedDateTime;
/**
* Extract the whole-unit span from a `Temporal.Duration` measured with `largestUnit: unit`.
*
* - Floors the field so a partial trailing amount never inflates a boundary count.
* - Does NOT validate the unit — caller ensures the duration was measured in it.
*
* @param duration Temporal.Duration produced by `until({ largestUnit: unit })`
* @param unit DateTimeUnit the duration was measured in
* @returns whole number of units spanned
*/
export declare function getUnitSpan(duration: Temporal.Duration, unit: DateTimeUnit): number;