Time-stamp utility functions. More...
Go to the source code of this file.
Macros | |
#define | QSC_TIMESTAMP_EPOCH_START 1900ULL |
The year starting the epoch. | |
#define | QSC_TIMESTAMP_SECONDS_PER_MINUTE 60ULL |
The number of seconds in a minute. | |
#define | QSC_TIMESTAMP_SECONDS_PER_HOUR (QSC_TIMESTAMP_SECONDS_PER_MINUTE * 60ULL) |
The number of seconds in an hour. | |
#define | QSC_TIMESTAMP_SECONDS_PER_DAY (QSC_TIMESTAMP_SECONDS_PER_HOUR * 24ULL) |
The number of seconds in a day. | |
#define | QSC_TIMESTAMP_STRING_SIZE 20ULL |
The size of the time-stamp string. | |
Functions | |
QSC_EXPORT_API void | qsc_timestamp_current_date (char output[QSC_TIMESTAMP_STRING_SIZE]) |
Get the calendar date from the current locale. | |
QSC_EXPORT_API void | qsc_timestamp_current_datetime (char output[QSC_TIMESTAMP_STRING_SIZE]) |
Get the calendar date and time from the current locale. Time-stamp string format is YYYY-MM-DD HH-MM-SS. | |
QSC_EXPORT_API void | qsc_timestamp_current_time (char output[QSC_TIMESTAMP_STRING_SIZE]) |
Get the local time. | |
QSC_EXPORT_API uint64_t | qsc_timestamp_epochtime_seconds (void) |
Get the date and time from the current locale in seconds from epoch. | |
QSC_EXPORT_API void | qsc_timestamp_time_struct_to_string (char output[QSC_TIMESTAMP_STRING_SIZE], const struct tm *tstruct) |
Convert a time structure to a date and time string. Time-stamp string format is YYYY-MM-DD HH-MM-SS. | |
QSC_EXPORT_API void | qsc_timestamp_string_to_time_struct (struct tm *tstruct, const char input[QSC_TIMESTAMP_STRING_SIZE]) |
Convert a date and time string to a time structure. Time-stamp string format must be YYYY-MM-DD HH-MM-SS. | |
QSC_EXPORT_API uint64_t | qsc_timestamp_datetime_seconds_remaining (const char basetime[QSC_TIMESTAMP_STRING_SIZE], const char comptime[QSC_TIMESTAMP_STRING_SIZE]) |
Compare a base date-time with another future date-time string, and return the difference in seconds. if the comparison date is less than the base date, the return is zero. Time-stamp string format must be YYYY-MM-DD HH-MM-SS. | |
QSC_EXPORT_API uint64_t | qsc_timestamp_datetime_to_seconds (const char input[QSC_TIMESTAMP_STRING_SIZE]) |
Convert the date-time string to a seconds from epoch unsigned 64-bit integer. | |
QSC_EXPORT_API uint64_t | qsc_timestamp_datetime_utc (void) |
Get the calendar date and time for utc time. | |
QSC_EXPORT_API void | qsc_timestamp_seconds_to_datetime (uint64_t tsec, char output[QSC_TIMESTAMP_STRING_SIZE]) |
Convert a seconds count from epoch-time to a date-time string. | |
Time-stamp utility functions.
This header provides a collection of functions for retrieving and formatting time-stamp information from the system clock. It supports operations for obtaining the current calendar date, current local time, and current date-time in a formatted string ("YYYY-MM-DD HH-MM-SS"). In addition, it includes a stopwatch functionality to measure elapsed time in milliseconds and functions to convert between epoch time and human-readable date-time strings.
QSC_EXPORT_API void qsc_timestamp_current_date | ( | char | output[QSC_TIMESTAMP_STRING_SIZE] | ) |
Get the calendar date from the current locale.
output | [char*] The output date string |
QSC_EXPORT_API void qsc_timestamp_current_datetime | ( | char | output[QSC_TIMESTAMP_STRING_SIZE] | ) |
Get the calendar date and time from the current locale. Time-stamp string format is YYYY-MM-DD HH-MM-SS.
output | [char*] The output time and date string |
QSC_EXPORT_API void qsc_timestamp_current_time | ( | char | output[QSC_TIMESTAMP_STRING_SIZE] | ) |
Get the local time.
output | [char*] The output time string |
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_seconds_remaining | ( | const char | basetime[QSC_TIMESTAMP_STRING_SIZE], |
const char | comptime[QSC_TIMESTAMP_STRING_SIZE] ) |
Compare a base date-time with another future date-time string, and return the difference in seconds. if the comparison date is less than the base date, the return is zero. Time-stamp string format must be YYYY-MM-DD HH-MM-SS.
basetime | [const char*] The base time string |
comptime | [const char*] The future time string |
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_to_seconds | ( | const char | input[QSC_TIMESTAMP_STRING_SIZE] | ) |
Convert the date-time string to a seconds from epoch unsigned 64-bit integer.
input | [const char*] The input date-time string |
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_utc | ( | void | ) |
Get the calendar date and time for utc time.
QSC_EXPORT_API uint64_t qsc_timestamp_epochtime_seconds | ( | void | ) |
Get the date and time from the current locale in seconds from epoch.
QSC_EXPORT_API void qsc_timestamp_seconds_to_datetime | ( | uint64_t | tsec, |
char | output[QSC_TIMESTAMP_STRING_SIZE] ) |
Convert a seconds count from epoch-time to a date-time string.
tsec | [uint64_t] The number of seconds between the clock epoch time and now |
output | [char*] The output time and date string |
QSC_EXPORT_API void qsc_timestamp_string_to_time_struct | ( | struct tm * | tstruct, |
const char | input[QSC_TIMESTAMP_STRING_SIZE] ) |
Convert a date and time string to a time structure. Time-stamp string format must be YYYY-MM-DD HH-MM-SS.
tstruct | [struct tm*] The time struct to be populated |
input | [const char*] The input time and date string |
QSC_EXPORT_API void qsc_timestamp_time_struct_to_string | ( | char | output[QSC_TIMESTAMP_STRING_SIZE], |
const struct tm * | tstruct ) |
Convert a time structure to a date and time string. Time-stamp string format is YYYY-MM-DD HH-MM-SS.
output | [char*] The output time and date string |
tstruct | [const struct tm*] The populated time structure |