@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.51 kB
TypeScript
import { NanosecondTruncationUnit } from "../precision/calculate/truncateNanoseconds.js";
/**
* The core of every reader that turns an epoch-nanosecond count into a UTC instant string
* (`fromNanoseconds` without a zone, the identifier and foreign-epoch readers). Returns "" for
* `null`, for a value that is not a `bigint` (the polyfill would coerce a number or a string,
* so the type is checked first) and for a count outside the range `Temporal.Instant` holds
* (`fromEpochNanoseconds` throws there).
*/
export declare function instantStringFromEpochNanoseconds(nanoseconds: bigint | null): string;
/**
* The core of `fromNanoseconds`: an epoch-nanosecond count as an instant string, or as a zoned
* string when `timeZone` is given. Never throws.
*
* @returns what `fromNanoseconds` returns, for the same arguments
*
* @example zonedStringFromEpochNanoseconds(0n) // "1970-01-01T00:00:00Z"
* @example zonedStringFromEpochNanoseconds(0n, "Asia/Tokyo") // "1970-01-01T09:00:00+09:00[Asia/Tokyo]"
*/
export declare function zonedStringFromEpochNanoseconds(nanoseconds: bigint, timeZone?: string): string;
/**
* The core of `truncateNanoseconds`: a count rounded toward the past to a millisecond or
* microsecond boundary. Never throws.
*
* @returns what `truncateNanoseconds` returns, for the same arguments
*
* @example truncateEpochNanoseconds(1_234_567n, "ms") // 1_000_000n
*/
export declare function truncateEpochNanoseconds(nanoseconds: bigint, unit: NanosecondTruncationUnit): bigint;