Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
Time Structures

Structures for representing and working with time and date components. More...

Topics

 Time structure conversions
 
 Time structure formatting
 

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.
 
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 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 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 bool time_shield::is_valid_tz (const T &time_zone)
 Alias for is_valid_time_zone_offset function.
 
template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time (const T &time) noexcept
 Checks the correctness of the specified time.
 
template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date (const T &date) noexcept
 Checks the correctness of the specified date.
 
template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date_time (const T &date_time) noexcept
 Checks the correctness of a date and time.
 
DateStruct time_shield::create_date_struct (const long year, const int mon=1, const int day=1)
 Creates a DateStruct instance.
 
DateTimeStruct time_shield::create_date_time_struct (const long year, const int mon=1, const int day=1, const int hour=0, const int min=0, const int sec=0, const int ms=0)
 Creates a DateTimeStruct instance.
 
TimeStruct time_shield::create_time_struct (const int hour, const int min, const int sec=0, const int ms=0)
 Creates a TimeStruct instance.
 
template<class T1, class T2 = ts_t>
T1 time_shield::to_dt (T2 ts)
 Alias for to_date_time function.
 
template<class T1, class T2 = ts_t>
T1 time_shield::to_dt_struct (T2 ts)
 Alias for to_date_time function.
 
template<class T>
time_shield::to_dt_ms (ts_ms_t ts)
 Alias for to_date_time_ms function.
 
template<class T>
time_shield::to_dt_struct_ms (ts_ms_t ts)
 Alias for to_date_time_ms function.
 
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::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>
constexpr fts_t time_shield::to_ftimestamp (const T &date_time)
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr fts_t time_shield::to_fts (const T &date_time)
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr fts_t time_shield::fts (const T &date_time)
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr fts_t time_shield::ftimestamp (const T &date_time)
 Alias for dt_to_ftimestamp.
 
constexpr fts_t time_shield::to_ftimestamp (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
constexpr fts_t time_shield::to_fts (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
constexpr fts_t time_shield::fts (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
constexpr fts_t time_shield::ftimestamp (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::get_dow (const T2 &date)
 Alias for get_weekday_from_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::dow_from_date (const T2 &date)
 Alias for get_weekday_from_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::weekday_of (const T2 &date)
 Alias for get_weekday_from_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::day_of_week_dt (const T2 &date)
 Alias for get_weekday_from_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::day_of_week (const T2 &date)
 Alias for get_weekday_from_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::dow (const T2 &date)
 Alias for get_weekday_from_date.
 
template<class T1 = DateTimeStruct, class T2 = ts_t>
T1 time_shield::to_date_time (T2 ts)
 Converts a timestamp to a date-time structure.
 
template<class 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>
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::dt_to_timestamp_ms (const T &date_time)
 Converts a date-time structure to a timestamp in milliseconds.
 
TIME_SHIELD_CONSTEXPR const ts_t time_shield::tm_to_timestamp_ms (const std::tm *timeinfo)
 Converts a std::tm structure to a timestamp in milliseconds.
 
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 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.
 

Detailed Description

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.

Included Structures:

Example Usage:

auto time = time_shield::create_time_struct(12, 30, 45); // 12:30:45
auto date = time_shield::create_date_struct(2024, 11, 25); // 2024-11-25
auto date_time = time_shield::create_date_time_struct(2024, 11, 25, 12, 30, 45);
auto tz = time_shield::to_time_zone_struct(3600); // +01:00
const TimeZoneStruct to_time_zone_struct(tz_t offset)
Converts an integer to a TimeZoneStruct.
const DateStruct create_date_struct(int64_t year, int32_t mon=1, int32_t day=1)
Creates a DateStruct instance.
const TimeStruct create_time_struct(int16_t hour, int16_t min, int16_t sec=0, int16_t ms=0)
Creates a TimeStruct instance.
const DateTimeStruct 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.

Function Documentation

◆ create_date_struct() [1/2]

DateStruct time_shield::create_date_struct ( const long year,
const int mon = 1,
const int day = 1 )

Creates a DateStruct instance.

Parameters
yearThe year component of the date.
monThe month component of the date, defaults to 1 (January).
dayThe day component of the date, defaults to 1.
Returns
A DateStruct instance with the provided date components.

Definition at line 37 of file date_struct.mqh.

◆ create_date_struct() [2/2]

const DateStruct time_shield::create_date_struct ( int64_t year,
int32_t mon = 1,
int32_t day = 1 )
inline

Creates a DateStruct instance.

Parameters
yearThe year component of the date.
monThe month component of the date, defaults to 1 (January).
dayThe day component of the date, defaults to 1.
Returns
A DateStruct instance with the provided date components.

Definition at line 26 of file date_struct.hpp.

◆ create_date_time_struct() [1/2]

DateTimeStruct time_shield::create_date_time_struct ( const long year,
const int mon = 1,
const int day = 1,
const int hour = 0,
const int min = 0,
const int sec = 0,
const int ms = 0 )

Creates a DateTimeStruct instance.

Parameters
yearThe year component of the date.
monThe month component of the date, defaults to 1 (January).
dayThe day component of the date, defaults to 1.
hourThe hour component of the time, defaults to 0.
minThe minute component of the time, defaults to 0.
secThe second component of the time, defaults to 0.
msThe millisecond component of the time, defaults to 0.
Returns
A DateTimeStruct instance with the provided date and time components.

Definition at line 46 of file date_time_struct.mqh.

◆ create_date_time_struct() [2/2]

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 )
inline

Creates a DateTimeStruct instance.

Parameters
yearThe year component of the date.
monThe month component of the date, defaults to 1 (January).
dayThe day component of the date, defaults to 1.
hourThe hour component of the time, defaults to 0.
minThe minute component of the time, defaults to 0.
secThe second component of the time, defaults to 0.
msThe millisecond component of the time, defaults to 0.
Returns
A DateTimeStruct instance with the provided date and time components.

Definition at line 34 of file date_time_struct.hpp.

◆ create_time_struct() [1/2]

TimeStruct time_shield::create_time_struct ( const int hour,
const int min,
const int sec = 0,
const int ms = 0 )

Creates a TimeStruct instance.

Parameters
hourThe hour component of the time.
minThe minute component of the time.
secThe second component of the time, defaults to 0.
msThe millisecond component of the time, defaults to 0.
Returns
A TimeStruct instance with the provided time components.

Definition at line 40 of file time_struct.mqh.

◆ create_time_struct() [2/2]

const TimeStruct time_shield::create_time_struct ( int16_t hour,
int16_t min,
int16_t sec = 0,
int16_t ms = 0 )
inline

Creates a TimeStruct instance.

Parameters
hourThe hour component of the time.
minThe minute component of the time.
secThe second component of the time, defaults to 0.
msThe millisecond component of the time, defaults to 0.
Returns
A TimeStruct instance with the provided time components.

Definition at line 28 of file time_struct.hpp.

◆ create_time_zone_struct()

TimeZoneStruct time_shield::create_time_zone_struct ( int hour,
int min,
bool is_positive = true )
inline

Creates a TimeZoneStruct instance.

Parameters
hourThe hour component of the time.
minThe minute component of the time.
is_positiveTrue if the time zone offset is positive, false if negative.
Returns
A TimeZoneStruct instance with the provided time components.

Definition at line 32 of file time_zone_struct.hpp.

◆ day_of_week()

template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
T1 time_shield::day_of_week ( const T2 & date)
constexpr

Alias for get_weekday_from_date.

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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1796 of file time_conversion_aliases.hpp.

◆ day_of_week_dt()

template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
T1 time_shield::day_of_week_dt ( const T2 & date)
constexpr

Alias for get_weekday_from_date.

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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1788 of file time_conversion_aliases.hpp.

◆ dow()

template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
T1 time_shield::dow ( const T2 & date)
constexpr

Alias for get_weekday_from_date.

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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1804 of file time_conversion_aliases.hpp.

◆ dow_from_date()

template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
T1 time_shield::dow_from_date ( const T2 & date)
constexpr

Alias for get_weekday_from_date.

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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1772 of file time_conversion_aliases.hpp.

◆ dt_to_ftimestamp()

template<class T>
TIME_SHIELD_CONSTEXPR const fts_t time_shield::dt_to_ftimestamp ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 815 of file time_conversions.hpp.

◆ dt_to_timestamp()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::dt_to_timestamp ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 673 of file time_conversions.hpp.

◆ dt_to_timestamp_ms()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::dt_to_timestamp_ms ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 748 of file time_conversions.hpp.

◆ ftimestamp() [1/2]

fts_t time_shield::ftimestamp ( const std::tm * timeinfo)
constexpr

Alias for tm_to_ftimestamp.

Converts a std::tm structure to a floating-point timestamp.

This function converts a given std::tm structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to the std::tm structure containing the date and time.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1446 of file time_conversion_aliases.hpp.

◆ ftimestamp() [2/2]

template<class T>
fts_t time_shield::ftimestamp ( const T & date_time)
constexpr

Alias for dt_to_ftimestamp.

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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1416 of file time_conversion_aliases.hpp.

◆ fts() [1/2]

fts_t time_shield::fts ( const std::tm * timeinfo)
constexpr

Alias for tm_to_ftimestamp.

Converts a std::tm structure to a floating-point timestamp.

This function converts a given std::tm structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to the std::tm structure containing the date and time.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1439 of file time_conversion_aliases.hpp.

◆ fts() [2/2]

template<class T>
fts_t time_shield::fts ( const T & date_time)
constexpr

Alias for dt_to_ftimestamp.

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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1408 of file time_conversion_aliases.hpp.

◆ get_dow()

template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
T1 time_shield::get_dow ( const T2 & date)
constexpr

Alias for get_weekday_from_date.

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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1764 of file time_conversion_aliases.hpp.

◆ get_weekday_from_date()

template<class T1 = Weekday, class T2>
const T1 time_shield::get_weekday_from_date ( const T2 & date)
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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1593 of file time_conversions.hpp.

◆ is_valid_date()

template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date ( const T & date)
inlinenoexcept

Checks the correctness of the specified date.

Template Parameters
TThe type of the date-time structure.
Parameters
dateDate-time structure.
Returns
true if the date is valid, false otherwise.

Definition at line 262 of file validation.hpp.

◆ is_valid_date_time()

template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date_time ( const T & date_time)
inlinenoexcept

Checks the correctness of a date and time.

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeDate-time structure.
Returns
true if the date and time are valid, false otherwise.

Definition at line 298 of file validation.hpp.

◆ is_valid_time()

template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time ( const T & time)
inlinenoexcept

Checks the correctness of the specified time.

Template Parameters
TThe type of the time structure.
Parameters
timeTime structure.
Returns
true if the time is valid, false otherwise.

Definition at line 215 of file validation.hpp.

◆ is_valid_time_zone()

template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time_zone ( const T & time_zone)
inline

Alias for is_valid_time_zone_offset function.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone structure (default is TimeZoneStruct).
Parameters
time_zoneThe time zone structure containing hour and minute components.
Returns
True if the time zone is valid, false otherwise.

Definition at line 172 of file validation.hpp.

◆ is_valid_time_zone_offset()

template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time_zone_offset ( const T & time_zone)
inlinenoexcept

Check if the time zone is valid.

Template Parameters
TThe type of the time zone structure (default is TimeZoneStruct).
Parameters
time_zoneThe time zone structure containing hour and minute components.
Returns
True if the time zone is valid, false otherwise.

Definition at line 163 of file validation.hpp.

◆ is_valid_tz()

template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_tz ( const T & time_zone)
inline

Alias for is_valid_time_zone_offset function.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone structure (default is TimeZoneStruct).
Parameters
time_zoneThe time zone structure containing hour and minute components.
Returns
True if the time zone is valid, false otherwise.

Definition at line 181 of file validation.hpp.

◆ timestamp()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::timestamp ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 718 of file time_conversion_aliases.hpp.

◆ timestamp_ms()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::timestamp_ms ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1277 of file time_conversion_aliases.hpp.

◆ tm_to_timestamp_ms()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::tm_to_timestamp_ms ( const std::tm * timeinfo)
inline

Converts a std::tm structure to a timestamp in milliseconds.

This function converts a given std::tm structure to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp in milliseconds representing the given date and time.

Definition at line 763 of file time_conversions.hpp.

◆ to_date_time()

template<class T1 = DateTimeStruct, class T2 = ts_t>
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.

Template Parameters
T1The date-time structure type to be returned.
T2The type of the timestamp (default is int64_t).
Parameters
tsThe timestamp to be converted.
Returns
A date-time structure of type T1.

Definition at line 461 of file time_conversions.hpp.

◆ to_date_time_ms()

template<class T>
T time_shield::to_date_time_ms ( ts_ms_t ts)
inline

Converts a timestamp in milliseconds to a date-time structure with milliseconds.

Template Parameters
TThe type of the date-time structure to return.
Parameters
tsThe timestamp in milliseconds to convert.
Returns
T A date-time structure with the corresponding date and time components.

Definition at line 566 of file time_conversions.hpp.

◆ to_dt()

template<class T1, class T2 = ts_t>
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.

Template Parameters
T1The date-time structure type to be returned.
T2The type of the timestamp (default is int64_t).
Parameters
tsThe timestamp to be converted.
Returns
A date-time structure of type T1.

Definition at line 243 of file time_conversion_aliases.hpp.

◆ to_dt_ms()

template<class T>
T time_shield::to_dt_ms ( ts_ms_t ts)
inline

Alias for to_date_time_ms function.

Converts a timestamp in milliseconds to a date-time structure with milliseconds.

Template Parameters
TThe type of the date-time structure to return.
Parameters
tsThe timestamp in milliseconds to convert.
Returns
T A date-time structure with the corresponding date and time components.

Definition at line 261 of file time_conversion_aliases.hpp.

◆ to_dt_struct()

template<class T1, class T2 = ts_t>
T1 time_shield::to_dt_struct ( 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.

Template Parameters
T1The date-time structure type to be returned.
T2The type of the timestamp (default is int64_t).
Parameters
tsThe timestamp to be converted.
Returns
A date-time structure of type T1.

Definition at line 251 of file time_conversion_aliases.hpp.

◆ to_dt_struct_ms()

template<class T>
T time_shield::to_dt_struct_ms ( ts_ms_t ts)
inline

Alias for to_date_time_ms function.

Converts a timestamp in milliseconds to a date-time structure with milliseconds.

Template Parameters
TThe type of the date-time structure to return.
Parameters
tsThe timestamp in milliseconds to convert.
Returns
T A date-time structure with the corresponding date and time components.

Definition at line 269 of file time_conversion_aliases.hpp.

◆ to_ftimestamp() [1/2]

fts_t time_shield::to_ftimestamp ( const std::tm * timeinfo)
constexpr

Alias for tm_to_ftimestamp.

Converts a std::tm structure to a floating-point timestamp.

This function converts a given std::tm structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to the std::tm structure containing the date and time.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1425 of file time_conversion_aliases.hpp.

◆ to_ftimestamp() [2/2]

template<class T>
fts_t time_shield::to_ftimestamp ( const T & date_time)
constexpr

Alias for dt_to_ftimestamp.

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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1392 of file time_conversion_aliases.hpp.

◆ to_fts() [1/2]

fts_t time_shield::to_fts ( const std::tm * timeinfo)
constexpr

Alias for tm_to_ftimestamp.

Converts a std::tm structure to a floating-point timestamp.

This function converts a given std::tm structure to a floating-point timestamp, which is the number of seconds (with fractional milliseconds) since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to the std::tm structure containing the date and time.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1432 of file time_conversion_aliases.hpp.

◆ to_fts() [2/2]

template<class T>
fts_t time_shield::to_fts ( const T & date_time)
constexpr

Alias for dt_to_ftimestamp.

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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1400 of file time_conversion_aliases.hpp.

◆ to_timestamp()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::to_timestamp ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 691 of file time_conversion_aliases.hpp.

◆ to_timestamp_ms()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::to_timestamp_ms ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1250 of file time_conversion_aliases.hpp.

◆ to_ts()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::to_ts ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 700 of file time_conversion_aliases.hpp.

◆ to_ts_ms()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::to_ts_ms ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1259 of file time_conversion_aliases.hpp.

◆ ts()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::ts ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 709 of file time_conversion_aliases.hpp.

◆ ts_ms()

template<class T>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::ts_ms ( const T & date_time)
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).

Template Parameters
TThe type of the date-time structure.
Parameters
date_timeThe date-time structure.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1268 of file time_conversion_aliases.hpp.

◆ weekday_of()

template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
T1 time_shield::weekday_of ( const T2 & date)
constexpr

Alias for get_weekday_from_date.

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).

Parameters
dateStructure containing year, month, and day.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1780 of file time_conversion_aliases.hpp.