Class Timestamp

Class Documentation

class Timestamp

Timestamp with nanoseconds.

Unix timestamp in nanoseconds.

Public Functions

explicit Timestamp(const int64_t nanoseconds)

Constructor.

Parameters:

nanoseconds – the number of nanoseconds

Timestamp(const Timestamp&) = default
~Timestamp()
int64_t nanoseconds() const

Get the number of nanoseconds.

std::string to_string() const

Convert the timestamp to a string.

This string can be converted back to a timestamp using from_string().

bool operator==(const Timestamp &rhs) const

Public Static Functions

static Timestamp now()

Get a new timestamp pointing to now from the Unix epoch.

static std::optional<Timestamp> from_string(const std::string &timestamp)

Get a timestamp object from a string.

The string should have been generated using to_string().

Returns:

the timestamp object, or std::nullopt if it fails