OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
messaging.contracts.common.timestamp Namespace Reference

Common Unix-epoch timestamp wire representation. More...

Classes

class  Timestamp
 Decoded OpenRoadCode wire timestamp. More...

Functions

None validate_timestamp (Mapping[str, Any] payload)
 Validate the common timestamp wire contract.
Timestamp decode_timestamp (Mapping[str, Any] payload)
 Validate and decode a common wire timestamp.
dict[str, int] encode_timestamp (datetime timestamp)
 Encode a datetime as unsigned Unix epoch seconds plus nanoseconds.

Detailed Description

Common Unix-epoch timestamp wire representation.

Function Documentation

◆ encode_timestamp()

dict[str, int] messaging.contracts.common.timestamp.encode_timestamp ( datetime timestamp)

Encode a datetime as unsigned Unix epoch seconds plus nanoseconds.

Wire contract:

  • seconds: uint64 whole seconds since 1970-01-01T00:00:00 UTC
  • nanoseconds: uint32 fractional nanoseconds, range 0..999,999,999

Naive datetimes are interpreted as UTC. Python's datetime has microsecond resolution, so nanoseconds produced from a datetime are currently multiples of 1,000. The wire contract intentionally preserves nanosecond capacity for future higher-resolution sources.