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.

28 lines • 1.64 kB
/** 2^62: the label of the TAI second that began 1970 TAI (Bernstein, TAI64 § labels). */ export declare const TAI64_SECONDS_OFFSET = 4611686018427387904n; /** * GMT's reading grammar for a TAI64, TAI64N or TAI64NA label in hex text: an optional `@`, 16 hex * digits of seconds, then optionally 8 of nanoseconds, then optionally 8 of attoseconds. Either * case. Only the 24-digit lowercase `@` form is daemontools' text; the rest is GMT's rule. * Groups: 1 seconds, 2 nanoseconds, 3 attoseconds. */ export declare const tai64LabelText: RegExp; /** * Read a TAI64, TAI64N or TAI64NA label as TAI nanoseconds since 1970-01-01T00:00:00 TAI. * Returns `null` for anything that is not a whole label, a second before 1970 TAI or at 2^63 * and above (reserved), and a counter above 999999999. Attoseconds are validated, then dropped. * * @example parseTai64Label("@400000002a2b2c2d00000000") // 707472429000000000n * @example parseTai64Label("@3fffffffffffffff") // null (before 1970 TAI) * @example parseTai64Label("@400000002a2b2c2d00000000 mark") // null (not a whole label) */ export declare function parseTai64Label(value: unknown): bigint | null; /** * Write TAI nanoseconds since 1970-01-01T00:00:00 TAI as a TAI64N text label: `@` and 24 * lowercase hex digits. The seconds floor, so a negative value names the last nanosecond of * the second before it. Callers pass only values in the 1972 to 9999 range. * * @example formatTai64nLabel(707472429000000000n) // "@400000002a2b2c2d00000000" * @example formatTai64nLabel(-1n) // "@3fffffffffffffff3b9ac9ff" */ export declare function formatTai64nLabel(tai: bigint): string;