utcToPtp
Signature
Section titled “Signature”utcToPtp(value: string, currentUtcOffset: number): PtpTimestamp | nullConverts a UTC instant to the PTP (IEEE 1588) timestamp a grandmaster announcing currentUtcOffset would send.
- The result is the instant’s seconds since 1970-01-01T00:00:00Z plus the offset, counted as TAI from 1970-01-01T00:00:00 TAI. It is the inverse of
ptpToUtcfor the same offset. currentUtcOffsetis TAI − UTC as announced. It is required, has no default, and must be an integer from −32 768 to 32 767. The sameptpTimescaleandcurrentUtcOffsetValidpreconditions asptpToUtcapply: call it only when the grandmaster announces both as true.- Accepts
Zor a numeric offset (2024-01-01T02:00:00+02:00). An offset-less string, a zone or calendar annotation, and a second of60returnnull. With one offset for the whole call, an inserted second has no reading of its own. secondscomes back as abigint, and every nanosecond written in the input is kept.- Returns
nullfor an instant before 1970-01-01T00:00:00Z, whichptpToUtcwould refuse, and for a result below 0 seconds. It never throws.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO 8601 instant string with Z or a numeric offset |
currentUtcOffset | number | TAI − UTC in seconds, as announced: an integer from -32768 to 32767 |
Returns
Section titled “Returns”the { seconds, nanoseconds } record, or null on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { utcToPtp } from "@northguild/gmt/iot/convert";
utcToPtp("2024-01-01T00:00:00Z", 37) // { seconds: 1704067237n, nanoseconds: 0 }Source
Section titled “Source”© 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.