![]() |
DDNet documentation
|
Namespaces | |
| namespace | TimestampFormat |
Enumerations | |
| enum class | ETimeFormat { ETimeFormat::DAYS , ETimeFormat::HOURS , ETimeFormat::MINS , ETimeFormat::HOURS_CENTISECS , ETimeFormat::MINS_CENTISECS , ETimeFormat::SECS_CENTISECS } |
Functions | |
| int64_t | time_timestamp () |
| void | str_timestamp (char *buffer, int buffer_size) |
| void | str_timestamp_format (char *buffer, int buffer_size, const char *format) |
| void | str_timestamp_ex (time_t time, char *buffer, int buffer_size, const char *format) |
| bool | timestamp_from_str (const char *string, const char *format, time_t *timestamp) |
| int64_t | time_milliseconds_from_seconds (float seconds) |
| int | str_time (int64_t centisecs, ETimeFormat format, char *buffer, int buffer_size) |
| int | str_time_float (float secs, ETimeFormat format, char *buffer, int buffer_size) |
Timestamp related functions.
|
strong |
Time formats for the str_time and str_time_float functions.
| Enumerator | |
|---|---|
| DAYS | |
| HOURS | |
| MINS | |
| HOURS_CENTISECS | |
| MINS_CENTISECS | |
| SECS_CENTISECS | |
| int str_time | ( | int64_t | centisecs, |
| ETimeFormat | format, | ||
| char * | buffer, | ||
| int | buffer_size ) |
Formats a time string.
| centisecs | Time in centiseconds. |
| format | Format of the time string, see ETimeFormat. |
| buffer | Pointer to a buffer that shall receive the timestamp string. |
| buffer_size | Size of the buffer. |
| int str_time_float | ( | float | secs, |
| ETimeFormat | format, | ||
| char * | buffer, | ||
| int | buffer_size ) |
Formats a time string.
| secs | Time in seconds. |
| format | Format of the time string, see ETimeFormat. |
| buffer | Pointer to a buffer that shall receive the timestamp string. |
| buffer_size | Size of the buffer. |
| void str_timestamp | ( | char * | buffer, |
| int | buffer_size ) |
Copies a timestamp of the current time in the format year-month-day_hour-minute-second to the string.
| buffer | Pointer to a buffer that shall receive the timestamp string. |
| buffer_size | Size of the buffer. |
| void str_timestamp_ex | ( | time_t | time, |
| char * | buffer, | ||
| int | buffer_size, | ||
| const char * | format ) |
Copies a timestamp of the given time in the given format to the string.
| time | The time value to represent as a string. |
| buffer | Pointer to a buffer that shall receive the timestamp string. |
| buffer_size | Size of the buffer. |
| format | Time formatting string. See https://cppreference.com/w/c/chrono/strftime.html for format description. See TimestampFormat for common formats. |
| void str_timestamp_format | ( | char * | buffer, |
| int | buffer_size, | ||
| const char * | format ) |
Copies a timestamp of the current time in the given format to the string.
| buffer | Pointer to a buffer that shall receive the timestamp string. |
| buffer_size | Size of the buffer. |
| format | Time formatting string. See https://cppreference.com/w/c/chrono/strftime.html for format description. See TimestampFormat for common formats. |
| int64_t time_milliseconds_from_seconds | ( | float | seconds | ) |
Returns the number of milliseconds from a time float.
Takes care to not introduce more rounding issues, which is what a naive std::roundf(seconds * 1000.0) would do.
| seconds | Time in seconds. |
| int64_t time_timestamp | ( | ) |
Retrieves the current time as a UNIX timestamp.
| bool timestamp_from_str | ( | const char * | string, |
| const char * | format, | ||
| time_t * | timestamp ) |
Parses a string into a timestamp following a specified format.
| string | Pointer to the string to parse. |
| format | The time format to use. See TimestampFormat for common formats. |
| timestamp | Pointer to the timestamp result. |