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.

41 lines • 1.91 kB
import { Temporal } from "./temporal.js"; /** * Read a Unix epoch argument on the local wall clock of the shared `unix/` options, or null when * anything is invalid. For the `parse*FromUnix` accessors, which only read fields. * * - `value` follows the one epoch grammar (`parseUnixEpochValue`). * - `epochUnit` accepts singular or 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 is invalid (see * `normalizeZoneFrame`). * * @param value Unix epoch number or digit string * @param options optional `{ epochUnit, timeZone }` * @returns the local wall clock, or null * * @example unixWallClock(0)?.toString() // "1970-01-01T00:00:00" * @example unixWallClock("86400", { epochUnit: "second", timeZone: "Asia/Tokyo" })?.hour // 9 * @example unixWallClock(45870000, { timeZone: "-00:44:30" })?.toString() // "1970-01-01T12:00:00" * @example unixWallClock(0, { timeZone: "Asia/Tokio" }) // null */ export declare function unixWallClock(value: unknown, options?: { epochUnit?: unknown; timeZone?: unknown; }): Temporal.PlainDateTime | null; /** * The core of `parseUnitFromUnix` and the `parse*FromUnix` accessors: one field of a Unix epoch's * local wall clock, as a zero-padded string. Never throws. * * @param value Unix epoch number or digit string * @param unit the field to read * @param options already-checked `{ epochUnit, timeZone, weekStartsOn }` * @returns the field, or `""` when `value`, `unit` or an option is invalid * * @example unixUnitString(0, "year", {}) // "1970" * @example unixUnitString(0, "fortnight", {}) // "" */ export declare function unixUnitString(value: unknown, unit: unknown, options: { epochUnit?: unknown; timeZone?: unknown; weekStartsOn?: unknown; } | undefined): string;