|
| Timestamp (uint64_t value=0) |
|
| Timestamp (uint32_t seconds, uint32_t fraction) |
|
| Timestamp (std::chrono::system_clock::duration duration) |
|
| Timestamp (std::chrono::system_clock::time_point timePoint) |
|
uint32_t | seconds () const |
| Returns the number of seconds of the NTP timestamp.
|
|
uint32_t | fraction () const |
| Returns the fraction of a second of the NTP timestamp.
|
|
uint64_t | value () const |
| Returns the NTP timestamp in long format.
|
|
std::chrono::system_clock::duration | duration () const |
| Returns the NTP timestamp as a system time duration.
|
|
bool | operator== (const Timestamp &other) const |
| Equality operator.
|
|
bool | operator!= (const Timestamp &other) const |
| Inequality operator.
|
|
std::chrono::system_clock::duration | operator- (const Timestamp &other) const |
| Returns the result of subtracting other from this timestamp as a system time duration.
|
|
Timestamp is an immutable class representing a NTP timestamp.
A NTP timestamp is a 64-bit, unsigned fixed-point number in seconds relative to the prime epoch "1900-01-01 00:00:00". It includes a 32-bit unsigned seconds field spanning 136 years and a 32-bit fraction field resolving 232 picoseconds. Timestamp handles the fractional part at the resolution of the operating system clock.
Era 0 includes dates from the prime epoch "1900-01-01 00:00:00" to "2036-02-07 06:28:15". The base date for era 1 is established when the timestamp field wraps around, that is, "2036-02-07 06:28:16" corresponds to "1900-01-01 00:00:00".
NTP timestamps are unsigned values, and operations on them produce results in the same or adjacent eras. The only arithmetic operation permitted on NTP timestamps is subtraction. It yields a time duration ranging from 136 years in the past to 136 years in the future.
Timestamp objects are comparable to each other in terms of equality through operators.
Default-constructed Timestamp objects have a value of zero, which is a special case representing unknown or unsynchronized time. Timestamp objects can also be constructed from integer and fractional parts, a system time duration, or a system time point. duration() can be used to convert the timestamp to a system time duration since the prime epoch.
- See also
- The unit tests in timestamp.h for further details.