@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.
28 lines • 1.56 kB
TypeScript
import { Temporal } from "./temporal.js";
import { FractionalDigit } from "../types/fractional-digit.js";
import "../types/index.js";
/**
* Internal shared implementation for `startOfUtc` / `endOfUtc`.
*
* - Converts the UTC Instant to a ZonedDateTime, snaps to the start or end of
* the requested unit, then converts back to an Instant string.
* - Supports every Temporal `DateUnit` and `TimeUnit`.
* - `weekStartsOn` shifts the week boundary: `"monday"` (default) or `"sunday"`.
* - Ends are computed forward from `value`, never from the unit's start, so an end is returned
* even when its unit began before the first representable instant (`-271821-04-20T00:00:00Z`).
* A start that lies before that instant returns "".
* - `fractionalSecondDigits` overrides the default sub-second precision for the
* returned Instant string. An end is written at nanosecond precision by default (next start
* − 1 ns); a start defaults to 3 for millisecond, 6 for microsecond, 9 for nanosecond, and 0
* for all coarser units.
*
* @param value ISO UTC datetime string
* @param unit Temporal.DateUnit | Temporal.TimeUnit to snap to
* @param options optional: weekStartsOn, fractionalSecondDigits
* @param isEnd false for start-of-unit, true for end-of-unit
* @returns UTC Instant string, or "" on invalid input
*/
export declare function startOrEndOfUtc(value: string, unit: Temporal.SmallestUnit<Temporal.DateTimeUnit>, options: {
weekStartsOn?: "monday" | "sunday";
fractionalSecondDigits?: FractionalDigit;
}, isEnd: boolean): string;