@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.
12 lines • 777 B
TypeScript
import { Temporal } from "./temporal.js";
export declare function toInstantFromUtc(value: string): Temporal.Instant | null;
/**
* Resolve a `reference` option to an instant: the parsed UTC string when one is given, else now.
*
* @param reference a UTC ISO string the caller has validated, or undefined (and `""`) for now
* @returns the instant, or null when the string does not parse or the clock is unavailable
* @example toReferenceInstantFromUtc("2024-03-15T12:00:00Z")?.toString() // "2024-03-15T12:00:00Z"
* @example toReferenceInstantFromUtc(undefined) instanceof Temporal.Instant // true (now)
* @example toReferenceInstantFromUtc("not-a-date") // null
*/
export declare function toReferenceInstantFromUtc(reference: string | undefined): Temporal.Instant | null;