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.

27 lines • 1.5 kB
import { Temporal } from "./temporal.js"; /** * Internal shared implementation for `startOfUnix` / `endOfUnix` and the quarter functions. * * - Converts the epoch to a ZonedDateTime, snaps to the start or end of the * requested unit, then converts back to an epoch number. * - `unit` is already resolved to a singular Temporal `DateUnit` / `TimeUnit` by the public caller, * or `"quarter"` from `startOfQuarterForUnix` / `endOfQuarterForUnix` only. * - `value` follows the one epoch grammar (`parseUnixEpochValue`); `epochUnit` accepts singular * and plural names and defaults to `"milliseconds"`. * - `timeZone` defaults to `"UTC"`; `"local"` is the system zone; a time zone identifier or a * stored UTC offset (`±HH:MM[:SS]`) is read as written; anything else returns null. * - `weekStartsOn` other than `"monday"` or `"sunday"` returns null. * - The boundary is always the real local bucket from `internal/zonedBucket.ts` — a start never * after `value`, an end never before it. * * @param value Unix epoch number or digit string * @param unit resolved unit to snap to * @param options optional: epochUnit, timeZone, weekStartsOn * @param isEnd false for start-of-unit, true for end-of-unit * @returns Unix epoch number, or null on invalid input */ export declare function startOrEndOfUnix(value: unknown, unit: Temporal.DateTimeUnit | "quarter", options: { epochUnit?: unknown; timeZone?: string; weekStartsOn?: unknown; }, isEnd: boolean): number | null;