Skip to content

parseTimestamp

parseTimestamp(value): Timestamp

parseTimestamp parses a timestamp from the supported types and representations:

  • a CEL Timestamp, a google.protobuf.Timestamp message, or a native Date
  • RFC 3339 / RFC 3339 Nano strings (for example "2023-01-01T00:00:00Z")
  • Unix epoch seconds as a bigint
  • Unix epoch seconds as a number, whose fractional part becomes nanoseconds
  • strings holding either of the two numeric forms

Timestamps outside the supported range [minUnixTime, maxUnixTime] are rejected.

This is the port of upstream’s ParseTimestamp. Go’s distinct int/int32/int64 and float32/float64 cases collapse into bigint and number, and json.Number has no TypeScript analogue — a numeric string reaches the same parsing path.

unknown

Timestamp

when the value is not a supported type, is malformed, or is out of range.