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.

33 lines • 1.66 kB
import { PtpTimestamp } from "../types/ptp.js"; /** One past the largest PTP seconds value: 2^48 (RFC 8877 section 4.3, 80 - 32 bits). */ export declare const PTP_SECONDS_LIMIT = 281474976710656n; /** The `int16` minimum of `currentUtcOffset` (RFC 8575 section 3, `time-properties-ds`). */ export declare const PTP_UTC_OFFSET_MIN = -32768; /** The `int16` maximum of `currentUtcOffset` (RFC 8575 section 3, `time-properties-ds`). */ export declare const PTP_UTC_OFFSET_MAX = 32767; /** * Read a caller's value as a PTP timestamp with `bigint` seconds. * * `seconds` is a `bigint` or a safe-integer `number` from 0 to 2^48 - 1, and `nanoseconds` an * integer from 0 to 999 999 999. Both are required. The result is a new object, never the caller's. * Never throws: a throwing getter or a revoked Proxy returns `null`. * * @param value candidate record * @returns the timestamp, or `null` when `value` is not a valid PTP timestamp * * @example readPtpTimestamp({ seconds: 5, nanoseconds: 1 }) // { seconds: 5n, nanoseconds: 1 } * @example readPtpTimestamp({ seconds: 281474976710656n, nanoseconds: 0 }) // null * @example readPtpTimestamp({ seconds: 0n, nanos: 0 }) // null */ export declare function readPtpTimestamp(value: unknown): PtpTimestamp | null; /** * Whether a value is a PTP `currentUtcOffset`: an integer `number` in the `int16` range. * * @param value candidate offset * @returns `true` for an integer from -32768 to 32767 * * @example isPtpUtcOffset(37) // true * @example isPtpUtcOffset(40000) // false * @example isPtpUtcOffset("37") // false */ export declare function isPtpUtcOffset(value: unknown): value is number;