# isValidPtpTimestamp

Industry: IoT

:::caution[Unreleased]
Not in `@northguild/gmt` 1.21.0 on npm yet. It is on `main` and ships in the next release.
:::

## Signature

```ts
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.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `unknown` | candidate value of any type |

## Returns

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

## Related types

- [`PtpTimestamp`](/gmt/reference/types/PtpTimestamp/)

## Examples

```ts
import { isValidPtpTimestamp } from "@northguild/gmt/iot/validate";

isValidPtpTimestamp({ seconds: 1704067237n, nanoseconds: 0 }) // true
```

## Source

[iot/validate/isValidPtpTimestamp.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/iot/validate/isValidPtpTimestamp.ts)
