Time Shield Library
C++ library for working with time
|
Structures for representing and working with time and date components. More...
Classes | |
struct | time_shield::DateStruct |
Structure to represent a date. More... | |
struct | time_shield::DateTimeStruct |
Structure to represent date and time. More... | |
struct | time_shield::TimeStruct |
Structure to represent time. More... | |
struct | time_shield::TimeZoneStruct |
Structure to represent time zone information. More... | |
Functions | |
const DateStruct | time_shield::create_date_struct (int64_t year, int32_t mon=1, int32_t day=1) |
Creates a DateStruct instance. | |
const DateTimeStruct | time_shield::create_date_time_struct (int64_t year, int mon=1, int day=1, int hour=0, int min=0, int sec=0, int ms=0) |
Creates a DateTimeStruct instance. | |
template<class T1 , class T2 = ts_t> | |
T1 | time_shield::to_date_time (T2 ts) |
Converts a timestamp to a date-time structure. | |
template<class T1 , class T2 = ts_t> | |
T1 | time_shield::to_dt (T2 ts) |
Alias for to_date_time function. | |
template<class T > | |
T | time_shield::to_date_time_ms (ts_ms_t ts) |
Converts a timestamp in milliseconds to a date-time structure with milliseconds. | |
template<class T > | |
T | time_shield::to_dt_ms (ts_ms_t ts) |
Alias for to_date_time_ms function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::dt_to_timestamp (const T &date_time) |
Converts a date-time structure to a timestamp. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::to_timestamp (const T &date_time) |
Alias for dt_to_timestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::to_ts (const T &date_time) |
Alias for dt_to_timestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::ts (const T &date_time) |
Alias for dt_to_timestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::timestamp (const T &date_time) |
Alias for dt_to_timestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::dt_to_timestamp_ms (const T &date_time) |
Converts a date-time structure to a timestamp in milliseconds. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::to_timestamp_ms (const T &date_time) |
Alias for dt_to_timestamp_ms function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::to_ts_ms (const T &date_time) |
Alias for dt_to_timestamp_ms function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::ts_ms (const T &date_time) |
Alias for dt_to_timestamp_ms function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const ts_t | time_shield::timestamp_ms (const T &date_time) |
Alias for dt_to_timestamp_ms function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const fts_t | time_shield::dt_to_ftimestamp (const T &date_time) |
Converts a date-time structure to a floating-point timestamp. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const fts_t | time_shield::to_ftimestamp (const T &date_time) |
Alias for dt_to_ftimestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const fts_t | time_shield::to_fts (const T &date_time) |
Alias for dt_to_ftimestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const fts_t | time_shield::fts (const T &date_time) |
Alias for dt_to_ftimestamp function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const fts_t | time_shield::ftimestamp (const T &date_time) |
Alias for dt_to_ftimestamp function. | |
template<class T1 = Weekday, class T2 > | |
constexpr const T1 | time_shield::get_weekday_from_date (const T2 &date) |
Get the day of the week from a date structure. | |
template<class T1 = int, class T2 > | |
constexpr const T1 | time_shield::day_of_week_dt (const T2 &date) |
Alias for get_weekday_from_date function that accepts a date structure. | |
template<class T1 = int, class T2 > | |
constexpr const T1 | time_shield::day_of_week (const T2 &date) |
Alias for get_weekday_from_date function that accepts a date structure. | |
const TimeStruct | time_shield::create_time_struct (int16_t hour, int16_t min, int16_t sec=0, int16_t ms=0) |
Creates a TimeStruct instance. | |
const TimeZoneStruct | time_shield::create_time_zone_struct (int hour, int min, bool is_positive=true) |
Creates a TimeZoneStruct instance. | |
template<class T = TimeZoneStruct> | |
TIME_SHIELD_CONSTEXPR const bool | time_shield::is_valid_time_zone_offset (const T &time_zone) noexcept |
Check if the time zone is valid. | |
template<class T = TimeZoneStruct> | |
TIME_SHIELD_CONSTEXPR const bool | time_shield::is_valid_time_zone (const T &time_zone) |
Alias for is_valid_time_zone_offset function. | |
template<class T = TimeZoneStruct> | |
TIME_SHIELD_CONSTEXPR const bool | time_shield::is_valid_tz (const T &time_zone) |
Alias for is_valid_time_zone_offset function. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const bool | time_shield::is_valid_time (const T &time) noexcept |
Checks the correctness of the specified time. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const bool | time_shield::is_valid_date (const T &date) noexcept |
Checks the correctness of the specified date. | |
template<class T > | |
TIME_SHIELD_CONSTEXPR const bool | time_shield::is_valid_date_time (const T &date_time) noexcept |
Checks the correctness of a date and time. | |
Structures for representing and working with time and date components.
This group includes various structures used for representing time, date, and date-time combinations, along with related utility functions for creating and manipulating these structures.
TimeStruct
: Represents time components (hour, minute, second, millisecond).DateStruct
: Represents date components (year, month, day).DateTimeStruct
: Represents combined date and time components.TimeZoneStruct
: Represents time zone offsets.
|
inline |
Creates a DateStruct instance.
year | The year component of the date. |
mon | The month component of the date, defaults to 1 (January). |
day | The day component of the date, defaults to 1. |
Definition at line 25 of file date_struct.hpp.
|
inline |
Creates a DateTimeStruct instance.
year | The year component of the date. |
mon | The month component of the date, defaults to 1 (January). |
day | The day component of the date, defaults to 1. |
hour | The hour component of the time, defaults to 0. |
min | The minute component of the time, defaults to 0. |
sec | The second component of the time, defaults to 0. |
ms | The millisecond component of the time, defaults to 0. |
Definition at line 33 of file date_time_struct.hpp.
|
inline |
Creates a TimeStruct instance.
hour | The hour component of the time. |
min | The minute component of the time. |
sec | The second component of the time, defaults to 0. |
ms | The millisecond component of the time, defaults to 0. |
Definition at line 27 of file time_struct.hpp.
|
inline |
Creates a TimeZoneStruct instance.
hour | The hour component of the time. |
min | The minute component of the time. |
is_positive | True if the time zone offset is positive, false if negative. |
Definition at line 29 of file time_zone_struct.hpp.
|
constexpr |
Alias for get_weekday_from_date function that accepts a date structure.
Get the day of the week from a date structure.
This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).
date | Structure containing year, month, and day. |
Definition at line 2114 of file time_conversions.hpp.
|
constexpr |
Alias for get_weekday_from_date function that accepts a date structure.
Get the day of the week from a date structure.
This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).
date | Structure containing year, month, and day. |
Definition at line 2106 of file time_conversions.hpp.
|
inline |
Converts a date-time structure to a floating-point timestamp.
This function converts a given date and time structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure containing year, month, day, hour, minute, second, and millisecond fields. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 871 of file time_conversions.hpp.
|
inline |
Converts a date-time structure to a timestamp.
This function converts a given date and time to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 511 of file time_conversions.hpp.
|
inline |
Converts a date-time structure to a timestamp in milliseconds.
This function converts a given date-time structure to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 699 of file time_conversions.hpp.
|
inline |
Alias for dt_to_ftimestamp function.
Converts a date-time structure to a floating-point timestamp.
This function converts a given date and time structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure containing year, month, day, hour, minute, second, and millisecond fields. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 908 of file time_conversions.hpp.
|
inline |
Alias for dt_to_ftimestamp function.
Converts a date-time structure to a floating-point timestamp.
This function converts a given date and time structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure containing year, month, day, hour, minute, second, and millisecond fields. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 899 of file time_conversions.hpp.
|
constexpr |
Get the day of the week from a date structure.
This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).
date | Structure containing year, month, and day. |
Definition at line 2098 of file time_conversions.hpp.
|
inlinenoexcept |
Checks the correctness of the specified date.
T | The type of the date-time structure. |
date | Date-time structure. |
Definition at line 261 of file validation.hpp.
|
inlinenoexcept |
Checks the correctness of a date and time.
T | The type of the date-time structure. |
date_time | Date-time structure. |
Definition at line 297 of file validation.hpp.
|
inlinenoexcept |
Checks the correctness of the specified time.
T | The type of the time structure. |
time | Time structure. |
Definition at line 214 of file validation.hpp.
|
inline |
Alias for is_valid_time_zone_offset function.
Check if the time zone is valid.
T | The type of the time zone structure (default is TimeZoneStruct). |
time_zone | The time zone structure containing hour and minute components. |
Definition at line 171 of file validation.hpp.
|
inlinenoexcept |
Check if the time zone is valid.
T | The type of the time zone structure (default is TimeZoneStruct). |
time_zone | The time zone structure containing hour and minute components. |
Definition at line 162 of file validation.hpp.
|
inline |
Alias for is_valid_time_zone_offset function.
Check if the time zone is valid.
T | The type of the time zone structure (default is TimeZoneStruct). |
time_zone | The time zone structure containing hour and minute components. |
Definition at line 180 of file validation.hpp.
|
inline |
Alias for dt_to_timestamp function.
Converts a date-time structure to a timestamp.
This function converts a given date and time to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 553 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp_ms function.
Converts a date-time structure to a timestamp in milliseconds.
This function converts a given date-time structure to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 735 of file time_conversions.hpp.
T1 time_shield::to_date_time | ( | T2 | ts | ) |
Converts a timestamp to a date-time structure.
This function converts a timestamp (usually an integer representing seconds since epoch) to a custom date-time structure. The default type for the timestamp is int64_t.
T1 | The date-time structure type to be returned. |
T2 | The type of the timestamp (default is int64_t). |
ts | The timestamp to be converted. |
Definition at line 233 of file time_conversions.hpp.
|
inline |
Converts a timestamp in milliseconds to a date-time structure with milliseconds.
T | The type of the date-time structure to return. |
ts | The timestamp in milliseconds to convert. |
Definition at line 346 of file time_conversions.hpp.
T1 time_shield::to_dt | ( | T2 | ts | ) |
Alias for to_date_time function.
Converts a timestamp to a date-time structure.
This function converts a timestamp (usually an integer representing seconds since epoch) to a custom date-time structure. The default type for the timestamp is int64_t.
T1 | The date-time structure type to be returned. |
T2 | The type of the timestamp (default is int64_t). |
ts | The timestamp to be converted. |
Definition at line 334 of file time_conversions.hpp.
|
inline |
Alias for to_date_time_ms function.
Converts a timestamp in milliseconds to a date-time structure with milliseconds.
T | The type of the date-time structure to return. |
ts | The timestamp in milliseconds to convert. |
Definition at line 356 of file time_conversions.hpp.
|
inline |
Alias for dt_to_ftimestamp function.
Converts a date-time structure to a floating-point timestamp.
This function converts a given date and time structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure containing year, month, day, hour, minute, second, and millisecond fields. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 881 of file time_conversions.hpp.
|
inline |
Alias for dt_to_ftimestamp function.
Converts a date-time structure to a floating-point timestamp.
This function converts a given date and time structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure containing year, month, day, hour, minute, second, and millisecond fields. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 890 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp function.
Converts a date-time structure to a timestamp.
This function converts a given date and time to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 526 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp_ms function.
Converts a date-time structure to a timestamp in milliseconds.
This function converts a given date-time structure to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 708 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp function.
Converts a date-time structure to a timestamp.
This function converts a given date and time to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 535 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp_ms function.
Converts a date-time structure to a timestamp in milliseconds.
This function converts a given date-time structure to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 717 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp function.
Converts a date-time structure to a timestamp.
This function converts a given date and time to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 544 of file time_conversions.hpp.
|
inline |
Alias for dt_to_timestamp_ms function.
Converts a date-time structure to a timestamp in milliseconds.
This function converts a given date-time structure to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).
T | The type of the date-time structure. |
date_time | The date-time structure. |
std::invalid_argument | if the date-time combination is invalid. |
Definition at line 726 of file time_conversions.hpp.