Skip to content

isValidPtpTimestamp

  • Device and sensor time on industrial networks: Precision Time Protocol timestamps, which count TAI, and the UTC offset a grandmaster announces.
isValidPtpTimestamp(value: unknown): value is PtpTimestamp | { seconds: number; nanoseconds: number; }

Return true when value is a PTP timestamp record that ptpToUtc reads. It checks the ranges of the 80-bit PTP (IEEE 1588) timestamp: 32 bits of nanoseconds (RFC 8877 section 4.3) and the other 48 bits (80 - 32) of seconds, the nanoseconds in 0 to 10^9 - 1.

  • seconds is a bigint, or a safe-integer number, from 0 to 2^48 - 1.
  • nanoseconds is an integer number from 0 to 999 999 999.
  • Both members are required. Extra members are ignored.
  • It checks the record, not a conversion. A record that passes can still make ptpToUtc return "": when the result would fall before 1970 ({ seconds: 0n, nanoseconds: 0 } with an offset of 37), or past Temporal’s last instant, +275760-09-13T00:00:00Z.
  • It narrows value to a PTP timestamp record. Never throws: a Proxy or a throwing getter is not a valid record.
ParameterTypeDescription
valueunknowncandidate value of any type

true for a PTP timestamp record, or false on invalid input

import { isValidPtpTimestamp } from "@northguild/gmt/iot/validate";
isValidPtpTimestamp({ seconds: 1704067237n, nanoseconds: 0 }) // true
output 

iot/validate/isValidPtpTimestamp.ts

© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.