ReferenceClientTime Types

Time Types

High-precision time types for timestamps, durations, and ranges.

Synnax stores timestamps with nanosecond precision, which exceeds what native types in most languages can represent. The client libraries provide utility classes for working with high-precision timestamps, durations, and time ranges.

TimeStamp

The TimeStamp class represents a 64-bit nanosecond-precision UTC timestamp. It stores the number of nanoseconds elapsed since the Unix epoch (January 1, 1970).

Constructing a TimeStamp

There are several easy ways to construct a TimeStamp:

Any of these formats can be passed to common methods used throughout the Synnax client. The union of these formats is called a CrudeTimeStamp. Examples include read, write, open_iterator, open_streamer, and

open_writer.

Converting to a Date/Datetime

You can convert a TimeStamp to a native date object:

Arithmetic

You can perform arithmetic on TimeStamp objects:

Comparisons

You can compare TimeStamp objects:

Accessing the Underlying Value

You can access the underlying nanosecond value:

TimeSpan

The TimeSpan class represents a 64-bit nanosecond-precision duration. It stores a duration as nanoseconds and provides utility methods for working with time intervals.

Constructing a TimeSpan

You can construct a TimeSpan directly from a number of nanoseconds, but it’s generally easier to use the utility constants or functions:

Performing Arithmetic

You can perform arithmetic on TimeSpan objects:

Accessing the Underlying Value

You can access the underlying nanosecond value:

TimeRange

The TimeRange class represents a range of time marked by a start and end TimeStamp. A TimeRange is start-inclusive and end-exclusive.

Constructing a TimeRange

You can construct a TimeRange from two timestamps in any of the formats that TimeStamp supports:

Checking if a TimeStamp is in a TimeRange

You can check if a TimeStamp is contained in a TimeRange using the contains method:

Checking if Two TimeRanges Overlap

You can check if two TimeRange objects overlap using the overlapsWith method:

Getting the TimeSpan of a TimeRange

You can get the TimeSpan of a TimeRange using the span property:

Limitations

Synnax stores timestamps as 64-bit integers representing the number of nanoseconds elapsed since the Unix epoch in UTC. The client libraries use specialized types to preserve this precision, but there are limitations to be aware of when converting to native types.