Classes and functions for handling time.
| Return | Name | Description |
|---|---|---|
std::time_t | now | Returns the current wall-clock time as a UTC time_t (seconds since epoch). |
double | clockSecs | Returns the elapsed process time in decimal seconds using a monotonic clock. |
std::string | print | Formats a broken-down time value using the given strftime format string. |
std::string | printLocal | Formats the current local time using the given strftime format string. |
std::string | printUTC | Formats the current UTC time using the given strftime format string. |
std::tm | toLocal | Converts a time_t value to a broken-down local time structure. Uses thread-safe native functions (localtime_r / localtime_s). |
std::tm | toUTC | Converts a time_t value to a broken-down UTC time structure. Uses thread-safe native functions (gmtime_r / gmtime_s). |
std::string | getLocal | Returns the current local time as an ISO8601 formatted string. |
std::string | getUTC | Returns the current UTC time as an ISO8601 formatted string. |
uint64_t | hrtime | Returns the current high-resolution monotonic time in nanoseconds. |
std::time_t now()Returns the current wall-clock time as a UTC time_t (seconds since epoch).
Current UTC time in seconds since the Unix epoch.
double clockSecs()Returns the elapsed process time in decimal seconds using a monotonic clock.
Process time in seconds.
std::string print(const std::tm & dt, const char * fmt)Formats a broken-down time value using the given strftime format string.
dt Broken-down time to format.
fmt strftime format string (default: ISO8601Format).
Formatted time string.
std::string printLocal(const char * fmt)Formats the current local time using the given strftime format string.
fmt strftime format string (default: ISO8601Format).Formatted local time string.
std::string printUTC(const char * fmt)Formats the current UTC time using the given strftime format string.
fmt strftime format string (default: ISO8601Format).Formatted UTC time string.
std::tm toLocal(const std::time_t & time)Converts a time_t value to a broken-down local time structure. Uses thread-safe native functions (localtime_r / localtime_s).
time UTC time value to convert.Broken-down local time.
std::tm toUTC(const std::time_t & time)Converts a time_t value to a broken-down UTC time structure. Uses thread-safe native functions (gmtime_r / gmtime_s).
time UTC time value to convert.Broken-down UTC time.
std::string getLocal()Returns the current local time as an ISO8601 formatted string.
ISO8601 local time string.
std::string getUTC()Returns the current UTC time as an ISO8601 formatted string.
ISO8601 UTC time string.
uint64_t hrtime()Returns the current high-resolution monotonic time in nanoseconds.
Current time in nanoseconds (suitable for measuring intervals).
| Return | Name | Description |
|---|---|---|
const int64_t | kNumMillisecsPerSec static | Constants for calculating time. |
const int64_t | kNumMicrosecsPerSec static | |
const int64_t | kNumNanosecsPerSec static | |
const int64_t | kNumMicrosecsPerMillisec static | |
const int64_t | kNumNanosecsPerMillisec static | |
const int64_t | kNumNanosecsPerMicrosec static | |
const char * | ISO8601Format static | The date/time format defined in the ISO 8601 standard. This is the default format used throughout the library for consistency. |
static
const int64_t kNumMillisecsPerSec = (1000)Constants for calculating time.
static
const int64_t kNumMicrosecsPerSec = (1000000)static
const int64_t kNumNanosecsPerSec = (1000000000)static
const int64_t kNumMicrosecsPerMillisec = kNumMicrosecsPerSec / kNumMillisecsPerSecstatic
const int64_t kNumNanosecsPerMillisec = kNumNanosecsPerSec / kNumMillisecsPerSecstatic
const int64_t kNumNanosecsPerMicrosec = kNumNanosecsPerSec / kNumMicrosecsPerSecstatic
const char * ISO8601Format = "%Y-%m-%dT%H:%M:%SZ"The date/time format defined in the ISO 8601 standard. This is the default format used throughout the library for consistency.
Examples: 2005-01-01T12:00:00+01:00 2005-01-01T11:00:00Z