Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_shield Namespace Reference

Main namespace for the Time Shield library. More...

Classes

struct  DateStruct
 Structure to represent a date. More...
 
struct  DateTimeStruct
 Structure to represent date and time. More...
 
struct  TimeStruct
 Structure to represent time. More...
 
struct  TimeZoneStruct
 Structure to represent time zone information. More...
 

Typedefs

typedef int64_t year_t
 Integer year type.
 
typedef int64_t uday_t
 Integer unix day type.
 
typedef int64_t ts_t
 Integer timestamp type.
 
typedef int64_t ts_ms_t
 Integer timestamp milliseconds type.
 
typedef int64_t ts_us_t
 Integer timestamp microseconds type.
 
typedef double fts_t
 Floating point timestamp type.
 
typedef double oadate_t
 Automation date type (OADate) floating point.
 
typedef double jd_t
 Julian Date type floating point.
 
typedef double mjd_t
 Modified Julian Date type floating point.
 
typedef uint64_t jdn_t
 Julian Day Number type.
 
typedef int tz_t
 

Enumerations

enum  FormatType { UPPERCASE_NAME = 0 , SHORT_NAME , FULL_NAME }
 Enumeration of the format options for representing a weekday or month. More...
 
enum  Weekday {
  SUN = 0 , MON , TUE , WED ,
  THU , FRI , SAT
}
 Enumeration of the days of the week. More...
 
enum  Month {
  JAN = 1 , FEB , MAR , APR ,
  MAY , JUN , JUL , AUG ,
  SEP , OCT , NOV , DEC
}
 Enumeration of the months of the year. More...
 
enum  TimeZone {
  GMT , UTC , EET , CET ,
  WET , EEST , CEST , WEST ,
  UNKNOWN
}
 Enumeration of the time zones. More...
 
enum  MoonPhase {
  WAXING_CRESCENT , FIRST_QUARTER , WAXING_GIBBOUS , FULL_MOON ,
  WANING_GIBBOUS , LAST_QUARTER , WANING_CRESCENT , NEW_MOON
}
 Enumeration of the moon phases. More...
 
enum  TimeFormatType {
  ISO8601_WITH_TZ , ISO8601_NO_TZ , MQL5_FULL , MQL5_DATE_ONLY ,
  MQL5_TIME_ONLY , AMERICAN_MONTH_DAY , EUROPEAN_MONTH_DAY , AMERICAN_TIME ,
  EUROPEAN_TIME
}
 Enumeration of time format types. More...
 

Functions

const DateStruct create_date_struct (const int64_t &year, const int &mon=1, const int &day=1)
 Creates a DateStruct instance.
 
const DateTimeStruct create_date_time_struct (const int64_t &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.
 
const char * to_cstr (const Weekday &value, const FormatType &format=UPPERCASE_NAME)
 Converts a Weekday enum value to a string.
 
const std::string & to_str (const Weekday &value, const FormatType &format=UPPERCASE_NAME)
 Converts a Weekday enum value to a string.
 
const char * to_cstr (const Month &value, const FormatType &format=UPPERCASE_NAME)
 Converts a Month enum value to a string.
 
const std::string & to_str (const Month &value, const FormatType &format=UPPERCASE_NAME)
 Converts a Month enum value to a string.
 
const char * to_cstr (const TimeZone &value, const FormatType &format=UPPERCASE_NAME)
 Converts a TimeZone enum value to a string.
 
const std::string & to_str (const TimeZone &value, const FormatType &format=UPPERCASE_NAME)
 Converts a TimeZone enum value to a string.
 
template<class T = int>
constexpr const T ns_of_sec (const fts_t &ts) noexcept
 Get the nanosecond part of the second from a floating-point timestamp.
 
template<class T = int>
constexpr const T us_of_sec (const fts_t &ts) noexcept
 Get the microsecond part of the second from a floating-point timestamp.
 
template<class T = int>
constexpr const T ms_of_sec (const fts_t &ts) noexcept
 Get the millisecond part of the second from a floating-point timestamp.
 
template<class T = int>
constexpr const T ms_of_ts (const ts_ms_t &ts) noexcept
 Get the millisecond part of the timestamp.
 
template<class T >
constexpr const ts_ms_t sec_to_ms_impl (const T &t, std::true_type) noexcept
 
template<class T >
constexpr const ts_ms_t sec_to_ms_impl (const T &t, std::false_type) noexcept
 
template<class T1 = ts_ms_t, class T2 >
constexpr const T1 sec_to_ms (const T2 &ts) noexcept
 Converts a timestamp from seconds to milliseconds.
 
constexpr const ts_ms_t fsec_to_ms (const fts_t &ts) noexcept
 Converts a floating-point timestamp from seconds to milliseconds.
 
template<class T1 = ts_t, class T2 = ts_ms_t>
constexpr const T1 ms_to_sec (const T2 &ts_ms) noexcept
 Converts a timestamp from milliseconds to seconds.
 
template<class T = ts_ms_t>
constexpr const fts_t ms_to_fsec (const T &ts_ms) noexcept
 Converts a timestamp from milliseconds to floating-point seconds.
 
template<class T = year_t>
constexpr const T get_unix_year (const ts_t &ts) noexcept
 Converts a UNIX timestamp to a year.
 
template<class T = year_t>
constexpr const T unix_year (const ts_t &ts) noexcept
 Alias for get_unix_year function.
 
template<class T = year_t>
constexpr const T to_unix_year (const ts_t &ts) noexcept
 Alias for get_unix_year function.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR const T hour24_to_12 (const T &hour) noexcept
 Converts a 24-hour format hour to a 12-hour format.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR const T h24_to_h12 (const T &hour) noexcept
 Alias for hour24_to_12 function.
 
template<class T1 , class T2 = ts_t>
T1 to_date_time (const T2 &ts)
 Converts a timestamp to a date-time structure.
 
template<class T1 , class T2 = ts_t>
T1 to_dt (const T2 &ts)
 Alias for to_date_time function.
 
template<class T >
to_date_time_ms (const ts_ms_t &ts)
 Converts a timestamp in milliseconds to a date-time structure with milliseconds.
 
template<class T >
to_dt_ms (const ts_ms_t &ts)
 Alias for to_date_time_ms function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t to_timestamp (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
 Converts a date and time to a timestamp.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t to_ts (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
 Alias for to_timestamp function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t get_ts (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
 Alias for to_timestamp function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t ts (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
 Alias for to_timestamp function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t timestamp (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
 Alias for to_timestamp function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t get_timestamp (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
 Alias for to_timestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t dt_to_timestamp (const T &date_time)
 Converts a date-time structure to a timestamp.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t to_timestamp (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t to_ts (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t ts (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t timestamp (const T &date_time)
 Alias for dt_to_timestamp function.
 
TIME_SHIELD_CONSTEXPR const ts_t tm_to_timestamp (const std::tm *timeinfo)
 Converts a std::tm structure to a timestamp.
 
TIME_SHIELD_CONSTEXPR const ts_t to_timestamp (const std::tm *timeinfo)
 Alias for tm_to_timestamp function.
 
TIME_SHIELD_CONSTEXPR const ts_t to_ts (const std::tm *timeinfo)
 Alias for tm_to_timestamp function.
 
TIME_SHIELD_CONSTEXPR const ts_t ts (const std::tm *timeinfo)
 Alias for tm_to_timestamp function.
 
TIME_SHIELD_CONSTEXPR const ts_t timestamp (const std::tm *timeinfo)
 Alias for tm_to_timestamp function.
 
TIME_SHIELD_CONSTEXPR const ts_t ts_from_tm (const std::tm *timeinfo)
 Alias for tm_to_timestamp function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t to_timestamp_ms (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T2 &ms=0)
 Converts a date and time to a timestamp in milliseconds.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t to_ts_ms (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T2 &ms=0)
 Alias for to_timestamp_ms function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t ts_ms (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T2 &ms=0)
 Alias for to_timestamp_ms function.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t timestamp_ms (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T2 &ms=0)
 Alias for to_timestamp_ms function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t 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 to_timestamp_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t to_ts_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t ts_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const ts_t timestamp_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t tm_to_timestamp_ms (const std::tm *timeinfo)
 Converts a std::tm structure to a timestamp in milliseconds.
 
TIME_SHIELD_CONSTEXPR const ts_t to_timestamp_ms (const std::tm *timeinfo)
 Alias for tm_to_timestamp_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t to_ts_ms (const std::tm *timeinfo)
 Alias for tm_to_timestamp_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t ts_ms (const std::tm *timeinfo)
 Alias for tm_to_timestamp_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t timestamp_ms (const std::tm *timeinfo)
 Alias for tm_to_timestamp_ms function.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t to_ftimestamp (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T3 &ms=0)
 Converts a date and time to a floating-point timestamp.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t to_fts (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T3 &ms=0)
 Alias for to_ftimestamp function.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t fts (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T3 &ms=0)
 Alias for to_ftimestamp function.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t ftimestamp (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T3 &ms=0)
 Alias for to_ftimestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const fts_t 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 to_ftimestamp (const T &date_time)
 Alias for dt_to_ftimestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const fts_t to_fts (const T &date_time)
 Alias for dt_to_ftimestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const fts_t fts (const T &date_time)
 Alias for dt_to_ftimestamp function.
 
template<class T >
TIME_SHIELD_CONSTEXPR const fts_t ftimestamp (const T &date_time)
 Alias for dt_to_ftimestamp function.
 
TIME_SHIELD_CONSTEXPR const fts_t tm_to_ftimestamp (const std::tm *timeinfo)
 Converts a std::tm structure to a floating-point timestamp.
 
TIME_SHIELD_CONSTEXPR const fts_t to_ftimestamp (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp function.
 
TIME_SHIELD_CONSTEXPR const fts_t to_fts (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp function.
 
TIME_SHIELD_CONSTEXPR const fts_t fts (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp function.
 
TIME_SHIELD_CONSTEXPR const fts_t ftimestamp (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp function.
 
template<class T = uday_t>
constexpr const T get_unix_day (const ts_t &ts=ts()) noexcept
 Get UNIX day.
 
template<class T = uday_t>
constexpr const T unix_day (const ts_t &ts=ts()) noexcept
 Alias for get_unix_day function.
 
template<class T = uday_t>
constexpr const T uday (const ts_t &ts=ts()) noexcept
 Alias for get_unix_day function.
 
template<class T = int>
constexpr const T get_days_difference (const ts_t &start, const ts_t &stop) noexcept
 Get the number of days between two timestamps.
 
template<class T = int>
constexpr const T get_days (const ts_t &start, const ts_t &stop) noexcept
 Alias for get_days_difference function.
 
template<class T = int>
constexpr const T days (const ts_t &start, const ts_t &stop) noexcept
 Alias for get_days_difference function.
 
template<class T = uday_t>
constexpr const T get_unix_day_ms (const ts_ms_t &t_ms=ts_ms()) noexcept
 Get UNIX day from milliseconds timestamp.
 
template<class T = uday_t>
constexpr const T unix_day_ms (const ts_ms_t &t_ms=ts_ms()) noexcept
 Alias for get_unix_day_ms function.
 
template<class T = uday_t>
constexpr const T uday_ms (const ts_ms_t &t_ms=ts_ms()) noexcept
 Alias for get_unix_day_ms function.
 
template<class T = ts_t>
constexpr const T unix_day_to_timestamp (const uday_t &unix_day) noexcept
 Convert a UNIX day to a timestamp.
 
template<class T = ts_t>
constexpr const T unix_day_to_ts (const uday_t &unix_day) noexcept
 Alias for unix_day_to_timestamp function.
 
template<class T = ts_t>
constexpr const T uday_to_ts (const uday_t &unix_day) noexcept
 Alias for unix_day_to_timestamp function.
 
template<class T = int64_t>
constexpr const T get_unix_min (const ts_t &ts=ts())
 Get UNIX minute.
 
template<class T = int64_t>
constexpr const T unix_min (const ts_t &ts=ts())
 Alias for get_unix_min function.
 
template<class T = int64_t>
constexpr const T to_unix_min (const ts_t &ts=ts())
 Alias for get_unix_min function.
 
template<class T = int64_t>
constexpr const T umin (const ts_t &ts=ts())
 Alias for get_unix_min function.
 
template<class T = int>
constexpr const T sec_of_day (const ts_t &ts=ts())
 Get the second of the day.
 
template<class T = int>
constexpr const T sec_of_day_ms (const ts_ms_t &ts_ms) noexcept
 Get the second of the day from milliseconds timestamp.
 
template<class T1 = int, class T2 = int>
constexpr const T1 sec_of_day (const T2 &hour, const T2 &min, const T2 &sec) noexcept
 Get the second of the day.
 
template<class T = int>
constexpr const T sec_of_min (const ts_t &ts=ts())
 Get the second of the minute.
 
template<class T = int>
constexpr const T sec_of_hour (const ts_t &ts=ts())
 Get the second of the hour.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T get_year (const ts_t &ts=ts())
 Get the year from the timestamp.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T year (const ts_t &ts=ts())
 Alias for get_year function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T to_year (const ts_t &ts=ts())
 Alias for get_year function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T get_year_ms (const ts_ms_t &ts_ms=ts_ms())
 Get the year from the timestamp in milliseconds.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T year_ms (const ts_ms_t &ts_ms=ts_ms())
 Alias for get_year_ms function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T to_year_ms (const ts_ms_t &ts_ms=ts_ms())
 Alias for get_year_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t start_of_year (const ts_t &ts) noexcept
 Get the start of the year timestamp.
 
TIME_SHIELD_CONSTEXPR const ts_t year_start (const ts_t &ts=ts())
 Alias for start_of_year function.
 
TIME_SHIELD_CONSTEXPR const ts_t year_begin (const ts_t &ts=ts())
 Alias for start_of_year function.
 
TIME_SHIELD_CONSTEXPR const ts_ms_t start_of_year_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the start of the year timestamp in milliseconds.
 
TIME_SHIELD_CONSTEXPR const ts_t year_start_ms (const ts_t &ts_ms=ts_ms())
 Alias for start_of_year_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t year_begin_ms (const ts_t &ts_ms=ts_ms())
 Alias for start_of_year_ms function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_t start_of_year_date (const T &year)
 Get the timestamp of the start of the year.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_t year_start_date (const T &year)
 Alias for start_of_year_date function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_t year_begin_date (const T &year)
 Alias for start_of_year_date function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t start_of_year_date_ms (const T &year)
 Get the timestamp in milliseconds of the start of the year.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t year_start_date_ms (const T &year)
 Alias for start_of_year_date_ms function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t year_begin_date_ms (const T &year)
 Alias for start_of_year_date_ms function.
 
TIME_SHIELD_CONSTEXPR ts_t end_of_year (const ts_t &ts=ts())
 Get the end-of-year timestamp.
 
TIME_SHIELD_CONSTEXPR const ts_t year_end (const ts_t &ts=ts())
 Alias for end_of_year function.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t end_of_year_ms (const ts_ms_t &ts_ms=ts_ms())
 Get the timestamp in milliseconds of the end of the year.
 
TIME_SHIELD_CONSTEXPR const ts_ms_t year_end_ms (const ts_ms_t &ts_ms=ts_ms())
 Alias for end_of_year_ms function.
 
template<class T = int>
const T day_of_year (const ts_t &ts=ts())
 Get the day of the year.
 
template<class T = Month>
TIME_SHIELD_CONSTEXPR const T month_of_year (const ts_t &ts) noexcept
 Get the month of the year.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR const T day_of_month (const ts_t &ts)
 Get the day of the month.
 
template<class T1 = int, class T2 = year_t, class T3 = int>
constexpr const T1 num_days_in_month (const T2 &year, const T3 &month) noexcept
 Get the number of days in a month.
 
template<class T1 = int, class T2 = year_t, class T3 = int>
constexpr const T1 days_in_month (const T2 &year, const T3 &month) noexcept
 Alias for num_days_in_month function.
 
template<class T1 = int>
TIME_SHIELD_CONSTEXPR const T1 num_days_in_month_ts (const ts_t &ts=ts()) noexcept
 Get the number of days in the month of the given timestamp.
 
template<class T1 = int>
constexpr const T1 num_days_in_month (const ts_t &ts=ts()) noexcept
 Alias for num_days_in_month_ts function.
 
template<class T1 = int>
constexpr const T1 days_in_month (const ts_t &ts=ts()) noexcept
 Alias for num_days_in_month_ts function.
 
template<class T1 = int, class T2 = year_t>
constexpr const T1 num_days_in_year (const T2 &year) noexcept
 Get the number of days in a given year.
 
template<class T1 = int, class T2 = year_t>
constexpr const T1 days_in_year (const T2 &year) noexcept
 Alias for num_days_in_year function.
 
template<class T = int>
constexpr const T num_days_in_year_ts (const ts_t &ts=ts())
 Get the number of days in the current year.
 
template<class T = int>
constexpr const T days_in_year_ts (const ts_t &ts=ts())
 Alias for num_days_in_year_ts function.
 
constexpr const ts_t start_of_day (const ts_t &ts=ts()) noexcept
 Get the start of the day timestamp.
 
constexpr const ts_t day_start (const ts_t &ts=ts()) noexcept
 Alias for start_of_day function.
 
template<class T = int>
constexpr const ts_t start_of_prev_day (const ts_t &ts=ts(), const T &days=1)
 Get timestamp of the start of the previous day.
 
template<class T = int>
constexpr const ts_t previous_day_start (const ts_t &ts=ts(), const T &days=1)
 Alias for start_of_prev_day function.
 
constexpr const ts_t start_of_day_sec (const ts_ms_t &ts_ms=ts_ms())
 Get the start of the day timestamp in seconds.
 
constexpr const ts_t day_start_sec (const ts_ms_t &ts_ms=ts_ms())
 Alias for start_of_day_sec function.
 
constexpr const ts_ms_t start_of_day_ms (const ts_ms_t &ts_ms=ts_ms())
 Get the start of the day timestamp in milliseconds.
 
constexpr const ts_ms_t day_start_ms (const ts_ms_t &ts_ms=ts_ms())
 Alias for start_of_day_ms function.
 
template<class T = int>
constexpr const ts_t start_of_next_day (const ts_t &ts, const T &days=1)
 Get timestamp of the first day after a specified number of days.
 
template<class T = int>
constexpr const ts_t next_day_start (const ts_t &ts, const T &days=1)
 Alias for start_of_next_day function.
 
constexpr const ts_t end_of_day (const ts_t &ts=ts()) noexcept
 Get the timestamp at the end of the day.
 
constexpr const ts_t day_end (const ts_t &ts=ts()) noexcept
 Alias for end_of_day function.
 
constexpr const ts_t end_of_day_sec (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the timestamp at the end of the day in seconds.
 
constexpr const ts_t day_end_sec (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Alias for end_of_day_sec function.
 
constexpr const ts_ms_t end_of_day_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the timestamp at the end of the day in milliseconds.
 
constexpr const ts_ms_t day_end_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Alias for end_of_day_ms function.
 
template<class T1 = Weekday, class T2 = year_t, class T3 = int>
constexpr const T1 day_of_week_date (const T2 &year, const T3 &month, const T3 &day)
 Get the day of the week.
 
template<class T1 = Weekday, class T2 = year_t, class T3 = int>
constexpr const T1 get_weekday (const T2 &year, const T3 &month, const T3 &day)
 Alias for day_of_week_date function.
 
template<class T1 = Weekday, class T2 = year_t, class T3 = int>
constexpr const T1 day_of_week (const T2 &year, const T3 &month, const T3 &day)
 Alias for day_of_week_date function.
 
template<class T1 = Weekday, class T2 >
constexpr const T1 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 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 day_of_week (const T2 &date)
 Alias for get_weekday_from_date function that accepts a date structure.
 
template<class T = Weekday>
constexpr const T get_weekday_from_ts (const ts_t &ts) noexcept
 Get the weekday from a timestamp.
 
template<class T = Weekday>
constexpr const T day_of_week (const ts_t &ts) noexcept
 Alias for get_weekday_from_ts function.
 
template<class T = Weekday>
constexpr const T get_weekday_from_ts_ms (const ts_ms_t &ts_ms)
 Get the weekday from a timestamp in milliseconds.
 
template<class T = Weekday>
constexpr const T day_of_week_ms (const ts_ms_t &ts_ms)
 Alias for get_weekday_from_ts_ms function.
 
TIME_SHIELD_CONSTEXPR const ts_t start_of_month (const ts_t &ts=ts())
 Get the timestamp at the start of the current month.
 
TIME_SHIELD_CONSTEXPR const ts_t month_begin (const ts_t &ts=ts())
 Alias for start_of_month function.
 
TIME_SHIELD_CONSTEXPR const ts_t end_of_month (const ts_t &ts=ts())
 Get the last timestamp of the current month.
 
TIME_SHIELD_CONSTEXPR const ts_t last_day_of_month (const ts_t &ts=ts())
 Alias for end_of_month function.
 
TIME_SHIELD_CONSTEXPR const ts_t last_sunday_of_month (const ts_t &ts=ts())
 Get the timestamp of the last Sunday of the current month.
 
TIME_SHIELD_CONSTEXPR const ts_t final_sunday_of_month (const ts_t &ts=ts())
 Alias for last_sunday_of_month function.
 
template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR const T1 last_sunday_month_day (const T2 &year, const T3 &month)
 Get the day of the last Sunday of the given month and year.
 
template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR const T1 final_sunday_month_day (const T2 &year, const T3 &month)
 Alias for last_sunday_month_day function.
 
constexpr const ts_t start_of_hour (const ts_t &ts=ts()) noexcept
 Get the timestamp at the start of the hour.
 
constexpr const ts_t hour_begin (const ts_t &ts=ts()) noexcept
 Alias for start_of_hour function.
 
constexpr const ts_t start_of_hour_sec (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the timestamp at the start of the hour.
 
constexpr const ts_t hour_begin_sec (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Alias for start_of_hour_sec function.
 
constexpr const ts_ms_t start_of_hour_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the timestamp at the start of the hour. This function sets the minute and second to zero.
 
constexpr const ts_ms_t hour_begin_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Alias for start_of_hour_ms function.
 
constexpr const ts_t end_of_hour (const ts_t &ts=ts()) noexcept
 Get the timestamp at the end of the hour. This function sets the minute and second to 59.
 
constexpr const ts_t finish_of_hour (const ts_t &ts=ts()) noexcept
 Alias for end_of_hour function.
 
constexpr const ts_t end_of_hour_sec (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the timestamp at the end of the hour.
 
constexpr const ts_t finish_of_hour_sec (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Alias for end_of_hour_sec function.
 
constexpr const ts_ms_t end_of_hour_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Get the timestamp at the end of the hour.
 
constexpr const ts_ms_t finish_of_hour_ms (const ts_ms_t &ts_ms=ts_ms()) noexcept
 Alias for end_of_hour_ms function.
 
template<class T = int>
constexpr const T hour_of_day (const ts_t &ts=ts()) noexcept
 Get the hour of the day.
 
template<class T = int>
constexpr const T hour_in_day (const ts_t &ts=ts()) noexcept
 Alias for hour_of_day function.
 
constexpr const ts_t start_of_week (const ts_t &ts=ts())
 Get the timestamp of the beginning of the week.
 
constexpr const ts_t week_begin (const ts_t &ts=ts())
 Alias for start_of_week function.
 
constexpr const ts_t end_of_week (const ts_t &ts=ts())
 Get the timestamp of the end of the week.
 
constexpr const ts_t finish_of_week (const ts_t &ts=ts())
 Alias for end_of_week function.
 
constexpr const ts_t start_of_saturday (const ts_t &ts=ts())
 Get the timestamp of the start of Saturday.
 
constexpr const ts_t saturday_begin (const ts_t &ts=ts())
 Alias for start_of_saturday function.
 
constexpr const ts_t start_of_min (const ts_t &ts=ts()) noexcept
 Get the timestamp of the beginning of the minute.
 
constexpr const ts_t min_begin (const ts_t &ts=ts()) noexcept
 Alias for start_of_min function.
 
constexpr const ts_t end_of_min (const ts_t &ts=ts()) noexcept
 Get the timestamp of the end of the minute.
 
constexpr const ts_t finish_of_min (const ts_t &ts=ts()) noexcept
 Alias for end_of_min function.
 
template<class T = int>
constexpr const T min_of_day (const ts_t &ts=ts()) noexcept
 Get minute of day. This function returns a value between 0 to 1439 (minute of day).
 
template<class T = int>
constexpr const T min_of_hour (const ts_t &ts=ts()) noexcept
 Get minute of hour. This function returns a value between 0 to 59.
 
template<class T = int>
constexpr const ts_t start_of_period (const T &p, const ts_t &ts=ts())
 Get the timestamp of the start of the period.
 
template<class T = int>
constexpr const ts_t end_of_period (const T &p, const ts_t &ts=ts())
 Get the timestamp of the end of the period.
 
template<class T = TimeZoneStruct>
const TimeZoneStruct to_time_zone (const tz_t &offset)
 Converts an integer to a time zone structure.
 
void process_format_impl (const char &last_char, const size_t &repeat_count, const ts_t &ts, const tz_t &utc_offset, const DateTimeStruct &dt, std::string &result)
 
template<class T = ts_t>
const std::string to_string (const std::string &format_str, const T &timestamp, const tz_t &utc_offset=0)
 Convert timestamp to string with custom format.
 
template<class T = ts_t>
const std::string to_str (const std::string &format_str, const T &timestamp, const tz_t &utc_offset=0)
 Alias for to_string function.
 
template<class T = ts_t>
const std::string to_iso8601_str (const T &ts)
 Converts a timestamp to an ISO8601 string.
 
template<class T = ts_t>
const std::string to_iso8601_date_str (const T &ts)
 Converts a timestamp to an ISO8601 date string.
 
template<class T = ts_t>
const std::string to_iso8601_time_str (const T &ts)
 Converts a timestamp to an ISO8601 time string.
 
template<class T = ts_t>
const std::string to_iso8601_time_utc_str (const T &ts)
 Converts a timestamp to an ISO8601 UTC time string.
 
template<class T = ts_t>
const std::string to_iso8601_utc_str (const T &ts)
 Converts a timestamp to an ISO8601 string in UTC format.
 
const std::string to_iso8601_utc_str_ms (const ts_ms_t &ts_ms)
 Converts a timestamp in milliseconds to an ISO8601 string in UTC format.
 
const std::string to_iso8601_str_ms (const ts_ms_t &ts_ms)
 Converts a timestamp in milliseconds to an ISO8601 string.
 
template<class T = ts_t>
const std::string to_iso8601_str (const T &ts, const tz_t &utc_offset)
 Converts a timestamp to an ISO8601 string with timezone offset.
 
const std::string to_iso8601_str_ms (const ts_ms_t &ts_ms, const tz_t &utc_offset)
 Converts a timestamp in milliseconds to an ISO8601 string with timezone offset.
 
const std::string to_mql5_date_time_str (const ts_t &ts)
 Converts a timestamp to a string in MQL5 date and time format.
 
const std::string to_mql5_full_str (const ts_t &ts)
 Alias for to_mql5_date_time_str function.
 
const std::string to_mql5_date_str (const ts_t &ts)
 Converts a timestamp to a string in MQL5 date format.
 
const std::string to_mql5_time_str (const ts_t &ts)
 Converts a timestamp to a string in MQL5 time format.
 
template<class T = Month>
const T get_month_number (const std::string &month)
 Get the month number by name.
 
template<class T = Month>
const T month_of_year (const std::string &month)
 Alias for get_month_number function.
 
template<class T = Month>
const bool try_get_month_number (const std::string &month, T &value)
 Get the month number by name, with output parameter.
 
template<class T = Month>
const bool get_month_number (const std::string &month, T &value)
 Alias for try_get_month_number function.
 
template<class T = Month>
const bool month_of_year (const std::string &month, T &value)
 Alias for try_get_month_number function.
 
const bool parse_time_zone (const std::string &tz_str, TimeZoneStruct &tz)
 Parse a time zone string into a TimeZoneStruct.
 
const bool parse_tz (const std::string &tz_str, TimeZoneStruct &tz)
 Alias for parse_time_zone function.
 
const bool parse_iso8601 (const std::string &input, DateTimeStruct &dt, TimeZoneStruct &tz)
 Parse a date and time string in ISO8601 format.
 
const bool str_to_ts (const std::string &str, ts_t &ts)
 Convert an ISO8601 string to a timestamp (ts_t).
 
const bool str_to_ts_ms (const std::string &str, ts_ms_t &ts)
 Convert an ISO8601 string to a millisecond timestamp (ts_ms_t).
 
const bool str_to_fts (const std::string &str, fts_t &ts)
 Convert an ISO8601 string to a floating-point timestamp (fts_t).
 
const ts_t ts (const std::string &str)
 Convert an ISO8601 string to a timestamp (ts_t).
 
const ts_ms_t ts_ms (const std::string &str)
 Convert an ISO8601 string to a millisecond timestamp (ts_ms_t).
 
const fts_t fts (const std::string &str)
 Convert an ISO8601 string to a floating-point timestamp (fts_t).
 
const ts_t ts (const char *str)
 Convert an ISO8601 C-style string to a timestamp (ts_t).
 
const ts_ms_t ts_ms (const char *str)
 Convert an ISO8601 C-style string to a millisecond timestamp (ts_ms_t).
 
const fts_t fts (const char *str)
 Convert an ISO8601 C-style string to a floating-point timestamp (fts_t).
 
const TimeStruct create_time_struct (const int &hour, const int &min, const int &sec=0, const int &ms=0)
 Creates a TimeStruct instance.
 
const struct timespec get_timespec_impl () noexcept
 Get the current timespec.
 
template<class T = int>
const T ns_of_sec () noexcept
 Get the nanosecond part of the current second.
 
template<class T = int>
const T us_of_sec () noexcept
 Get the microsecond part of the current second.
 
template<class T = int>
const T ms_of_sec () noexcept
 Get the millisecond part of the current second.
 
const ts_t ts () noexcept
 Get the current UTC timestamp in seconds.
 
const ts_t timestamp () noexcept
 Get the current UTC timestamp in seconds.
 
const fts_t fts () noexcept
 Get the current UTC timestamp in floating-point seconds.
 
const fts_t ftimestamp () noexcept
 Get the current UTC timestamp in floating-point seconds.
 
const ts_ms_t ts_ms () noexcept
 Get the current UTC timestamp in milliseconds.
 
const ts_ms_t timestamp_ms () noexcept
 Get the current UTC timestamp in milliseconds.
 
const ts_ms_t now () noexcept
 Get the current UTC timestamp in milliseconds.
 
const ts_us_t ts_us () noexcept
 Get the current UTC timestamp in microseconds.
 
const ts_us_t timestamp_us () noexcept
 Get the current UTC timestamp in microseconds.
 
const TimeZoneStruct create_time_zone_struct (const int &hour, const int &min, const bool &is_positive=true)
 Creates a TimeZoneStruct instance.
 
const TimeZoneStruct to_time_zone_struct (const tz_t &offset)
 Converts an integer to a TimeZoneStruct.
 
const TimeZoneStruct to_tz (const tz_t &offset)
 Alias for to_time_zone_struct function.
 
const std::string time_zone_struct_to_string (const TimeZoneStruct &tz)
 Converts a TimeZoneStruct to a string representation.
 
const std::string to_string (const TimeZoneStruct &tz)
 Alias for time_zone_struct_to_string function.
 
const std::string to_str (const TimeZoneStruct &tz)
 Alias for time_zone_struct_to_string function.
 
const tz_t time_zone_struct_to_offset (const TimeZoneStruct &tz)
 Converts a TimeZoneStruct to a single integer representation.
 
const tz_t tz_to_offset (const TimeZoneStruct &tz)
 Alias for time_zone_struct_to_offset function.
 
const tz_t to_offset (const TimeZoneStruct &tz)
 Alias for time_zone_struct_to_offset function.
 
template<class T = year_t>
constexpr const bool is_leap_year_date (const T &year) noexcept
 Checks if the given year is a leap year.
 
template<class T = year_t>
constexpr const bool check_leap_year (const T &year) noexcept
 Alias for is_leap_year_date function.
 
template<class T = year_t>
constexpr const bool leap_year (const T &year) noexcept
 Alias for is_leap_year_date function.
 
TIME_SHIELD_CONSTEXPR const bool is_leap_year_ts (const ts_t &ts)
 Checks if the given year is a leap year.
 
TIME_SHIELD_CONSTEXPR const bool leap_year_ts (const ts_t &ts)
 Alias for is_leap_year_ts function.
 
TIME_SHIELD_CONSTEXPR const bool check_leap_year_ts (const ts_t &ts)
 Alias for is_leap_year_ts function.
 
TIME_SHIELD_CONSTEXPR const bool is_leap_year (const ts_t &ts)
 Alias for is_leap_year_ts function.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR const bool is_valid_time_zone (const T &hour, const T &min) noexcept
 Check if the time zone is valid.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR bool is_valid_tz (const T &hour, const T &min)
 Alias for is_valid_time_zone function.
 
template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR const bool 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 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 is_valid_tz (const T &time_zone)
 Alias for is_valid_time_zone_offset function.
 
template<class T1 = int, class T2 = int>
TIME_SHIELD_CONSTEXPR const bool is_valid_time (const T1 &hour, const T1 &min, const T1 &sec, const T2 &ms=0) noexcept
 Checks the correctness of the specified time.
 
template<class T >
TIME_SHIELD_CONSTEXPR const bool is_valid_time (const T &time) noexcept
 Checks the correctness of the specified time.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const bool is_valid_date (const T1 &year, const T2 &month, const T2 &day) noexcept
 Checks the correctness of the specified date.
 
template<class T >
TIME_SHIELD_CONSTEXPR const bool is_valid_date (const T &date) noexcept
 Checks the correctness of the specified date.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const bool is_valid_date_time (const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0, const T3 &ms=0) noexcept
 Checks the correctness of a date and time.
 
template<class T >
TIME_SHIELD_CONSTEXPR const bool is_valid_date_time (const T &date_time) noexcept
 Checks the correctness of a date and time.
 
TIME_SHIELD_CONSTEXPR const bool is_day_off (const ts_t &ts) noexcept
 Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).
 
TIME_SHIELD_CONSTEXPR const bool is_weekend (const ts_t &ts) noexcept
 Alias for is_day_off function.
 
template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool is_day_off_unix_day (const T &unix_day) noexcept
 Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.
 
template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool is_weekend_unix_day (const T &unix_day) noexcept
 Alias for is_day_off_unix_day function.
 

Variables

constexpr int64_t NS_PER_US = 1000
 Nanoseconds per microsecond.
 
constexpr int64_t NS_PER_MS = 1000000
 Nanoseconds per millisecond.
 
constexpr int64_t NS_PER_SEC = 1000000000
 Nanoseconds per second.
 
constexpr int64_t US_PER_SEC = 1000000
 Microseconds per second.
 
constexpr int64_t MS_PER_SEC = 1000
 Milliseconds per second.
 
constexpr int64_t MS_PER_MIN = 60000
 Milliseconds per minute.
 
constexpr int64_t MS_PER_HALF_HOUR = 1800000
 Milliseconds per half hour.
 
constexpr int64_t MS_PER_HOUR = 3600000
 Milliseconds per hour.
 
constexpr int64_t MS_PER_DAY = 86400000
 Milliseconds per day.
 
constexpr int64_t SEC_PER_MIN = 60
 Seconds per minute.
 
constexpr int64_t SEC_PER_HALF_HOUR = 1800
 Seconds per half hour.
 
constexpr int64_t SEC_PER_HOUR = 3600
 Seconds per hour.
 
constexpr int64_t SEC_PER_DAY = 86400
 Seconds per day.
 
constexpr int64_t SEC_PER_YEAR = 31536000
 Seconds per year (365 days)
 
constexpr int64_t AVG_SEC_PER_YEAR = 31557600
 Average seconds per year (365.25 days)
 
constexpr int64_t SEC_PER_LEAP_YEAR = 31622400
 Seconds per leap year (366 days)
 
constexpr int64_t SEC_PER_4_YEARS = 126230400
 Seconds per 4 years.
 
constexpr int64_t SEC_PER_FIRST_100_YEARS = 3155760000
 Seconds per first 100 years.
 
constexpr int64_t SEC_PER_100_YEARS = 3155673600
 Seconds per 100 years.
 
constexpr int64_t SEC_PER_400_YEARS = 12622780800
 Seconds per 400 years.
 
constexpr int64_t MAX_SEC_PER_DAY = 86399
 Maximum seconds per day.
 
constexpr int64_t MIN_PER_HOUR = 60
 Minutes per hour.
 
constexpr int64_t MIN_PER_DAY = 1440
 Minutes per day.
 
constexpr int64_t MIN_PER_WEEK = 10080
 Minutes per week.
 
constexpr int64_t MIN_PER_MONTH = 40320
 Minutes per month (28 days)
 
constexpr int64_t MAX_MOON_MIN = 42523
 Maximum lunar minutes.
 
constexpr int64_t HOURS_PER_DAY = 24
 Hours per day.
 
constexpr int64_t DAYS_PER_WEEK = 7
 Days per week.
 
constexpr int64_t DAYS_PER_LEAP_YEAR = 366
 Days per leap year.
 
constexpr int64_t DAYS_PER_YEAR = 365
 Days per year.
 
constexpr int64_t DAYS_PER_4_YEARS = 1461
 Days per 4 years.
 
const int64_t MONTHS_PER_YEAR = 12
 Months per year.
 
const int64_t MAX_DAYS_PER_MONTH = 31
 Maximum days per month.
 
const int64_t LEAP_YEAR_PER_100_YEAR = 24
 Leap years per 100 years.
 
const int64_t LEAP_YEAR_PER_400_YEAR = 97
 Leap years per 400 years.
 
constexpr int64_t UNIX_EPOCH = 1970
 Start year of UNIX time.
 
constexpr int64_t OLE_EPOCH = 25569
 OLE automation date since UNIX epoch.
 
constexpr int64_t MAX_YEAR = 292277022000LL
 Maximum representable year.
 
constexpr int64_t MIN_YEAR = -2967369602200LL
 Minimum representable year.
 
constexpr int64_t ERROR_YEAR = 9223372036854770000LL
 Error year value.
 
constexpr int64_t MAX_TIMESTAMP = 9223371890843040000LL
 Maximum timestamp value.
 
constexpr int64_t ERROR_TIMESTAMP = 9223372036854770000LL
 Error timestamp value.
 
constexpr double MAX_OADATE = std::numeric_limits<double>::max()
 Maximum OLE automation date.
 
constexpr double AVG_DAYS_PER_YEAR = 365.25
 Average days per year.
 

Detailed Description

Main namespace for the Time Shield library.

The time_shield namespace contains all the core components and functions of the Time Shield library. It includes various utilities for working with time and dates, their formatting, conversion, and validation.

Typedef Documentation

◆ fts_t

typedef double time_shield::fts_t

Floating point timestamp type.

Definition at line 18 of file types.hpp.

◆ jd_t

typedef double time_shield::jd_t

Julian Date type floating point.

Definition at line 20 of file types.hpp.

◆ jdn_t

typedef uint64_t time_shield::jdn_t

Julian Day Number type.

Definition at line 22 of file types.hpp.

◆ mjd_t

typedef double time_shield::mjd_t

Modified Julian Date type floating point.

Definition at line 21 of file types.hpp.

◆ oadate_t

typedef double time_shield::oadate_t

Automation date type (OADate) floating point.

Definition at line 19 of file types.hpp.

◆ ts_ms_t

typedef int64_t time_shield::ts_ms_t

Integer timestamp milliseconds type.

Definition at line 16 of file types.hpp.

◆ ts_t

typedef int64_t time_shield::ts_t

Integer timestamp type.

Definition at line 15 of file types.hpp.

◆ ts_us_t

typedef int64_t time_shield::ts_us_t

Integer timestamp microseconds type.

Definition at line 17 of file types.hpp.

◆ tz_t

typedef int time_shield::tz_t

Definition at line 23 of file types.hpp.

◆ uday_t

typedef int64_t time_shield::uday_t

Integer unix day type.

Definition at line 14 of file types.hpp.

◆ year_t

typedef int64_t time_shield::year_t

Integer year type.

Definition at line 13 of file types.hpp.

Enumeration Type Documentation

◆ FormatType

Enumeration of the format options for representing a weekday or month.

Enumerator
UPPERCASE_NAME 

Uppercase short name.

SHORT_NAME 

Short name.

FULL_NAME 

Full name.

Definition at line 15 of file enums.hpp.

◆ Month

Enumeration of the months of the year.

Enumerator
JAN 

January.

FEB 

February.

MAR 

March.

APR 

April.

MAY 

May.

JUN 

June.

JUL 

July.

AUG 

August.

SEP 

September.

OCT 

October.

NOV 

November.

DEC 

December.

Definition at line 85 of file enums.hpp.

◆ MoonPhase

Enumeration of the moon phases.

Enumerator
WAXING_CRESCENT 

Waxing Crescent Moon.

FIRST_QUARTER 

First Quarter Moon.

WAXING_GIBBOUS 

Waxing Gibbous Moon.

FULL_MOON 

Full Moon.

WANING_GIBBOUS 

Waning Gibbous Moon.

LAST_QUARTER 

Last Quarter Moon.

WANING_CRESCENT 

Waning Crescent Moon.

NEW_MOON 

New Moon.

Definition at line 234 of file enums.hpp.

◆ TimeFormatType

Enumeration of time format types.

Enumerator
ISO8601_WITH_TZ 

ISO8601 format with time zone (e.g., "2024-06-06T12:30:45+03:00")

ISO8601_NO_TZ 

ISO8601 format without time zone (e.g., "2024-06-06T12:30:45")

MQL5_FULL 

MQL5 time format (e.g., "2024.06.06 12:30:45")

MQL5_DATE_ONLY 

MQL5 date format (e.g., "2024.06.06")

MQL5_TIME_ONLY 

MQL5 time format (e.g., "12:30:45")

AMERICAN_MONTH_DAY 

American date format (e.g., "06/06/2024")

EUROPEAN_MONTH_DAY 

European date format (e.g., "06.06.2024")

AMERICAN_TIME 

American time format (e.g., "12:30 PM")

EUROPEAN_TIME 

European time format (e.g., "12:30")

Definition at line 246 of file enums.hpp.

◆ TimeZone

Enumeration of the time zones.

Enumerator
GMT 

Greenwich Mean Time.

UTC 

Coordinated Universal Time.

EET 

Eastern European Time.

CET 

Central European Time.

WET 

Western European Time.

EEST 

Eastern European Summer Time.

CEST 

Central European Summer Time.

WEST 

Western European Summer Time.

UNKNOWN 

Unknown Time Zone.

Definition at line 165 of file enums.hpp.

◆ Weekday

Enumeration of the days of the week.

Enumerator
SUN 

Sunday.

MON 

Monday.

TUE 

Tuesday.

WED 

Wednesday.

THU 

Thursday.

FRI 

Friday.

SAT 

Saturday.

Definition at line 22 of file enums.hpp.

Function Documentation

◆ check_leap_year()

template<class T = year_t>
const bool time_shield::check_leap_year ( const T & year)
constexprnoexcept

Alias for is_leap_year_date function.

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 27 of file validation.hpp.

◆ check_leap_year_ts()

TIME_SHIELD_CONSTEXPR const bool time_shield::check_leap_year_ts ( const ts_t & ts)

Alias for is_leap_year_ts function.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 86 of file validation.hpp.

◆ create_date_struct()

const DateStruct time_shield::create_date_struct ( const int64_t & year,
const int & mon = 1,
const int & 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 23 of file date_struct.hpp.

◆ create_date_time_struct()

const DateTimeStruct time_shield::create_date_time_struct ( const int64_t & 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 )
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 31 of file date_time_struct.hpp.

◆ create_time_struct()

const TimeStruct time_shield::create_time_struct ( const int & hour,
const int & min,
const int & sec = 0,
const int & 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 25 of file time_struct.hpp.

◆ create_time_zone_struct()

const TimeZoneStruct time_shield::create_time_zone_struct ( const int & hour,
const int & min,
const 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 27 of file time_zone_struct.hpp.

◆ day_end()

const ts_t time_shield::day_end ( const ts_t & ts = ts())
constexprnoexcept

Alias for end_of_day function.

Get the timestamp at the end of the day.

This function sets the hour to 23, minute to 59, and second to 59.

Parameters
tsTimestamp.
Returns
Timestamp at the end of the day.

Definition at line 1731 of file time_conversions.hpp.

◆ day_end_ms()

const ts_ms_t time_shield::day_end_ms ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Alias for end_of_day_ms function.

Get the timestamp at the end of the day in milliseconds.

This function sets the hour to 23, minute to 59, second to 59, and millisecond to 999.

Parameters
ts_msTimestamp in milliseconds.
Returns
Timestamp at the end of the day in milliseconds.

Definition at line 1767 of file time_conversions.hpp.

◆ day_end_sec()

const ts_t time_shield::day_end_sec ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Alias for end_of_day_sec function.

Get the timestamp at the end of the day in seconds.

This function sets the hour to 23, minute to 59, and second to 59.

Parameters
ts_msTimestamp in milliseconds.
Returns
Timestamp at the end of the day in seconds.

Definition at line 1749 of file time_conversions.hpp.

◆ day_of_month()

template<class T = int>
TIME_SHIELD_CONSTEXPR const T time_shield::day_of_month ( const ts_t & ts)
inline

Get the day of the month.

This function returns the day of the month for the specified timestamp.

Parameters
tsTimestamp.
Returns
Day of the month.

Definition at line 1491 of file time_conversions.hpp.

◆ day_of_week() [1/3]

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

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

Definition at line 1826 of file time_conversions.hpp.

◆ day_of_week() [2/3]

template<class T1 = Weekday, class T2 = year_t, class T3 = int>
const T1 time_shield::day_of_week ( const T2 & year,
const T3 & month,
const T3 & day )
constexpr

Alias for day_of_week_date function.

Get the day of the week.

Parameters
yearYear.
monthMonth of the year.
dayDay of the month.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1798 of file time_conversions.hpp.

◆ day_of_week() [3/3]

template<class T = Weekday>
const T time_shield::day_of_week ( const ts_t & ts)
constexprnoexcept

Alias for get_weekday_from_ts function.

Get the weekday from a timestamp.

Parameters
tsTimestamp.
Returns
Weekday (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1843 of file time_conversions.hpp.

◆ day_of_week_date()

template<class T1 = Weekday, class T2 = year_t, class T3 = int>
const T1 time_shield::day_of_week_date ( const T2 & year,
const T3 & month,
const T3 & day )
constexpr

Get the day of the week.

Parameters
yearYear.
monthMonth of the year.
dayDay of the month.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1779 of file time_conversions.hpp.

◆ day_of_week_dt()

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

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

Definition at line 1819 of file time_conversions.hpp.

◆ day_of_week_ms()

template<class T = Weekday>
const T time_shield::day_of_week_ms ( const ts_ms_t & ts_ms)
constexpr

Alias for get_weekday_from_ts_ms function.

Get the weekday from a timestamp in milliseconds.

Parameters
ts_msTimestamp in milliseconds.
Returns
Weekday (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1860 of file time_conversions.hpp.

◆ day_of_year()

template<class T = int>
const T time_shield::day_of_year ( const ts_t & ts = ts())
inline

Get the day of the year.

This function returns the day of the year for the specified timestamp.

Parameters
tsTimestamp.
Returns
Day of the year.

Definition at line 1448 of file time_conversions.hpp.

◆ day_start()

const ts_t time_shield::day_start ( const ts_t & ts = ts())
constexprnoexcept

Alias for start_of_day function.

Get the start of the day timestamp.

This function returns the timestamp at the start of the day. The function sets the hours, minutes, and seconds to zero.

Parameters
tsTimestamp.
Returns
Start of the day timestamp.

Definition at line 1633 of file time_conversions.hpp.

◆ day_start_ms()

const ts_ms_t time_shield::day_start_ms ( const ts_ms_t & ts_ms = ts_ms())
constexpr

Alias for start_of_day_ms function.

Get the start of the day timestamp in milliseconds.

This function returns the timestamp at the start of the day in milliseconds. The function sets the hours, minutes, seconds, and milliseconds to zero.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of the day timestamp in milliseconds.

Definition at line 1692 of file time_conversions.hpp.

◆ day_start_sec()

const ts_t time_shield::day_start_sec ( const ts_ms_t & ts_ms = ts_ms())
constexpr

Alias for start_of_day_sec function.

Get the start of the day timestamp in seconds.

This function returns the timestamp at the start of the day in seconds. The function sets the hours, minutes, and seconds to zero.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of the day timestamp in seconds.

Definition at line 1673 of file time_conversions.hpp.

◆ days()

template<class T = int>
const T time_shield::days ( const ts_t & start,
const ts_t & stop )
constexprnoexcept

Alias for get_days_difference function.

Get the number of days between two timestamps.

This function calculates the number of days between two timestamps.

Template Parameters
TThe type of the return value, defaults to int.
Parameters
startThe timestamp of the start of the period.
stopThe timestamp of the end of the period.
Returns
The number of days between start and stop.

Definition at line 958 of file time_conversions.hpp.

◆ days_in_month() [1/2]

template<class T1 = int, class T2 = year_t, class T3 = int>
const T1 time_shield::days_in_month ( const T2 & year,
const T3 & month )
constexprnoexcept

Alias for num_days_in_month function.

Get the number of days in a month.

This function calculates and returns the number of days in the specified month and year.

Parameters
yearYear as an integer.
monthMonth as an integer.
Returns
The number of days in the given month and year.

Definition at line 1540 of file time_conversions.hpp.

◆ days_in_month() [2/2]

template<class T1 = int>
const T1 time_shield::days_in_month ( const ts_t & ts = ts())
constexprnoexcept

Alias for num_days_in_month_ts function.

Get the number of days in the month of the given timestamp.

This function calculates and returns the number of days in the month of the specified timestamp.

Parameters
tsThe timestamp to extract month and year from.
Returns
The number of days in the month of the given timestamp.

Definition at line 1572 of file time_conversions.hpp.

◆ days_in_year()

template<class T1 = int, class T2 = year_t>
const T1 time_shield::days_in_year ( const T2 & year)
constexprnoexcept

Alias for num_days_in_year function.

Get the number of days in a given year.

This function calculates and returns the number of days in the specified year.

Parameters
yearYear.
Returns
Number of days in the given year.

Definition at line 1593 of file time_conversions.hpp.

◆ days_in_year_ts()

template<class T = int>
const T time_shield::days_in_year_ts ( const ts_t & ts = ts())
constexpr

Alias for num_days_in_year_ts function.

Get the number of days in the current year.

This function calculates and returns the number of days in the current year based on the provided timestamp.

Parameters
tsTimestamp.
Returns
Number of days in the current year.

Definition at line 1614 of file time_conversions.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 823 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 473 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 656 of file time_conversions.hpp.

◆ end_of_day()

const ts_t time_shield::end_of_day ( const ts_t & ts = ts())
constexprnoexcept

Get the timestamp at the end of the day.

This function sets the hour to 23, minute to 59, and second to 59.

Parameters
tsTimestamp.
Returns
Timestamp at the end of the day.

Definition at line 1725 of file time_conversions.hpp.

◆ end_of_day_ms()

const ts_ms_t time_shield::end_of_day_ms ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Get the timestamp at the end of the day in milliseconds.

This function sets the hour to 23, minute to 59, second to 59, and millisecond to 999.

Parameters
ts_msTimestamp in milliseconds.
Returns
Timestamp at the end of the day in milliseconds.

Definition at line 1761 of file time_conversions.hpp.

◆ end_of_day_sec()

const ts_t time_shield::end_of_day_sec ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Get the timestamp at the end of the day in seconds.

This function sets the hour to 23, minute to 59, and second to 59.

Parameters
ts_msTimestamp in milliseconds.
Returns
Timestamp at the end of the day in seconds.

Definition at line 1743 of file time_conversions.hpp.

◆ end_of_hour()

const ts_t time_shield::end_of_hour ( const ts_t & ts = ts())
constexprnoexcept

Get the timestamp at the end of the hour. This function sets the minute and second to 59.

Parameters
tsTimestamp (default: current timestamp).
Returns
Timestamp at the end of the hour.

Definition at line 2001 of file time_conversions.hpp.

◆ end_of_hour_ms()

const ts_ms_t time_shield::end_of_hour_ms ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Get the timestamp at the end of the hour.

This function sets the minute and second to 59.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the end of the hour in milliseconds.

Definition at line 2037 of file time_conversions.hpp.

◆ end_of_hour_sec()

const ts_t time_shield::end_of_hour_sec ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Get the timestamp at the end of the hour.

This function sets the minute and second to 59.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the end of the hour in seconds.

Definition at line 2019 of file time_conversions.hpp.

◆ end_of_min()

const ts_t time_shield::end_of_min ( const ts_t & ts = ts())
constexprnoexcept

Get the timestamp of the end of the minute.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the end of the minute.

Definition at line 2144 of file time_conversions.hpp.

◆ end_of_month()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::end_of_month ( const ts_t & ts = ts())
inline

Get the last timestamp of the current month.

This function returns the last timestamp of the current month, setting the day to the last day of the month and the time to 23:59:59.

Parameters
tsTimestamp (default is current timestamp)
Returns
Last timestamp of the current month

Definition at line 1892 of file time_conversions.hpp.

◆ end_of_period()

template<class T = int>
const ts_t time_shield::end_of_period ( const T & p,
const ts_t & ts = ts() )
constexpr

Get the timestamp of the end of the period.

Parameters
pPeriod duration in seconds.
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the end of the period.

Definition at line 2194 of file time_conversions.hpp.

◆ end_of_week()

const ts_t time_shield::end_of_week ( const ts_t & ts = ts())
constexpr

Get the timestamp of the end of the week.

This function finds the timestamp of the end of the week, which corresponds to the end of Saturday.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the end of the week.

Definition at line 2095 of file time_conversions.hpp.

◆ end_of_year()

TIME_SHIELD_CONSTEXPR ts_t time_shield::end_of_year ( const ts_t & ts = ts())
inline

Get the end-of-year timestamp.

This function finds the last timestamp of the current year.

Parameters
tsTimestamp.
Returns
End-of-year timestamp.

Definition at line 1355 of file time_conversions.hpp.

◆ end_of_year_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::end_of_year_ms ( const ts_ms_t & ts_ms = ts_ms())
inline

Get the timestamp in milliseconds of the end of the year.

This function finds the last timestamp of the current year in milliseconds.

Parameters
ts_msTimestamp in milliseconds.
Returns
End-of-year timestamp in milliseconds.

Definition at line 1429 of file time_conversions.hpp.

◆ final_sunday_month_day()

template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR const T1 time_shield::final_sunday_month_day ( const T2 & year,
const T3 & month )
inline

Alias for last_sunday_month_day function.

Get the day of the last Sunday of the given month and year.

This function returns the day of the last Sunday of the specified month and year.

Parameters
yearYear
monthMonth (1 = January, 12 = December)
Returns
Day of the last Sunday of the given month and year

Definition at line 1939 of file time_conversions.hpp.

◆ final_sunday_of_month()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::final_sunday_of_month ( const ts_t & ts = ts())
inline

Alias for last_sunday_of_month function.

Get the timestamp of the last Sunday of the current month.

This function returns the timestamp of the last Sunday of the current month, setting the day to the last Sunday and the time to 00:00:00.

Parameters
tsTimestamp (default is current timestamp)
Returns
Timestamp of the last Sunday of the current month

Definition at line 1917 of file time_conversions.hpp.

◆ finish_of_hour()

const ts_t time_shield::finish_of_hour ( const ts_t & ts = ts())
constexprnoexcept

Alias for end_of_hour function.

Get the timestamp at the end of the hour. This function sets the minute and second to 59.

Parameters
tsTimestamp (default: current timestamp).
Returns
Timestamp at the end of the hour.

Definition at line 2007 of file time_conversions.hpp.

◆ finish_of_hour_ms()

const ts_ms_t time_shield::finish_of_hour_ms ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Alias for end_of_hour_ms function.

Get the timestamp at the end of the hour.

This function sets the minute and second to 59.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the end of the hour in milliseconds.

Definition at line 2043 of file time_conversions.hpp.

◆ finish_of_hour_sec()

const ts_t time_shield::finish_of_hour_sec ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Alias for end_of_hour_sec function.

Get the timestamp at the end of the hour.

This function sets the minute and second to 59.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the end of the hour in seconds.

Definition at line 2025 of file time_conversions.hpp.

◆ finish_of_min()

const ts_t time_shield::finish_of_min ( const ts_t & ts = ts())
constexprnoexcept

Alias for end_of_min function.

Get the timestamp of the end of the minute.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the end of the minute.

Definition at line 2150 of file time_conversions.hpp.

◆ finish_of_week()

const ts_t time_shield::finish_of_week ( const ts_t & ts = ts())
constexpr

Alias for end_of_week function.

Get the timestamp of the end of the week.

This function finds the timestamp of the end of the week, which corresponds to the end of Saturday.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the end of the week.

Definition at line 2101 of file time_conversions.hpp.

◆ fsec_to_ms()

const ts_ms_t time_shield::fsec_to_ms ( const fts_t & ts)
constexprnoexcept

Converts a floating-point timestamp from seconds to milliseconds.

Parameters
tsTimestamp in floating-point seconds.
Returns
ts_ms_t Timestamp in milliseconds.

Definition at line 94 of file time_conversions.hpp.

◆ ftimestamp() [1/4]

const fts_t time_shield::ftimestamp ( )
inlinenoexcept

Get the current UTC timestamp in floating-point seconds.

Returns
fts_t Current UTC timestamp in floating-point seconds.

Definition at line 77 of file time_utils.hpp.

◆ ftimestamp() [2/4]

TIME_SHIELD_CONSTEXPR const fts_t time_shield::ftimestamp ( const std::tm * timeinfo)
inline

Alias for tm_to_ftimestamp function.

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 900 of file time_conversions.hpp.

◆ ftimestamp() [3/4]

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

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 856 of file time_conversions.hpp.

◆ ftimestamp() [4/4]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t time_shield::ftimestamp ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T3 & ms = 0 )
inline

Alias for to_ftimestamp function.

Converts a date and time to a floating-point timestamp.

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

Template Parameters
T1The type of the year parameter (default is year_t).
T2The type of the month, day, hour, minute, and second parameters (default is int).
T3The type of the millisecond parameter (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 799 of file time_conversions.hpp.

◆ fts() [1/6]

const fts_t time_shield::fts ( )
inlinenoexcept

Get the current UTC timestamp in floating-point seconds.

Returns
fts_t Current UTC timestamp in floating-point seconds.

Definition at line 70 of file time_utils.hpp.

◆ fts() [2/6]

const fts_t time_shield::fts ( const char * str)
inline

Convert an ISO8601 C-style string to a floating-point timestamp (fts_t).

This function parses a string in ISO8601 format and converts it to a floating-point timestamp. If the parsing fails, it returns 0.

Parameters
strThe ISO8601 C-style string.
Returns
The floating-point timestamp if successful, 0 otherwise.

Definition at line 303 of file time_parser.hpp.

◆ fts() [3/6]

const fts_t time_shield::fts ( const std::string & str)
inline

Convert an ISO8601 string to a floating-point timestamp (fts_t).

This function parses a string in ISO8601 format and converts it to a floating-point timestamp. If the parsing fails, it returns 0.

Parameters
strThe ISO8601 string.
Returns
The floating-point timestamp if successful, 0 otherwise.

Definition at line 269 of file time_parser.hpp.

◆ fts() [4/6]

TIME_SHIELD_CONSTEXPR const fts_t time_shield::fts ( const std::tm * timeinfo)
inline

Alias for tm_to_ftimestamp function.

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 893 of file time_conversions.hpp.

◆ fts() [5/6]

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

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 848 of file time_conversions.hpp.

◆ fts() [6/6]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t time_shield::fts ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T3 & ms = 0 )
inline

Alias for to_ftimestamp function.

Converts a date and time to a floating-point timestamp.

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

Template Parameters
T1The type of the year parameter (default is year_t).
T2The type of the month, day, hour, minute, and second parameters (default is int).
T3The type of the millisecond parameter (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 785 of file time_conversions.hpp.

◆ get_days()

template<class T = int>
const T time_shield::get_days ( const ts_t & start,
const ts_t & stop )
constexprnoexcept

Alias for get_days_difference function.

Get the number of days between two timestamps.

This function calculates the number of days between two timestamps.

Template Parameters
TThe type of the return value, defaults to int.
Parameters
startThe timestamp of the start of the period.
stopThe timestamp of the end of the period.
Returns
The number of days between start and stop.

Definition at line 951 of file time_conversions.hpp.

◆ get_days_difference()

template<class T = int>
const T time_shield::get_days_difference ( const ts_t & start,
const ts_t & stop )
constexprnoexcept

Get the number of days between two timestamps.

This function calculates the number of days between two timestamps.

Template Parameters
TThe type of the return value, defaults to int.
Parameters
startThe timestamp of the start of the period.
stopThe timestamp of the end of the period.
Returns
The number of days between start and stop.

Definition at line 944 of file time_conversions.hpp.

◆ get_month_number() [1/2]

template<class T = Month>
const T time_shield::get_month_number ( const std::string & month)

Get the month number by name.

Template Parameters
TThe return type, default is Month enum.
Parameters
monthThe name of the month as a string.
Returns
The month number corresponding to the given name.
Exceptions
std::invalid_argumentif the month name is invalid.

Definition at line 30 of file time_parser.hpp.

◆ get_month_number() [2/2]

template<class T = Month>
const bool time_shield::get_month_number ( const std::string & month,
T & value )

Alias for try_get_month_number function.

Get the month number by name, with output parameter.

Template Parameters
TThe type for the month number, default is Month enum.
Parameters
monthThe name of the month as a string.
valueThe reference to store the month number if found.
Returns
True if the month name is valid, false otherwise.

Definition at line 101 of file time_parser.hpp.

◆ get_timespec_impl()

const struct timespec time_shield::get_timespec_impl ( )
inlinenoexcept

Get the current timespec.

Returns
struct timespec The current timespec.

Definition at line 16 of file time_utils.hpp.

◆ get_timestamp()

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::get_timestamp ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0 )
inline

Alias for to_timestamp function.

Converts a date and time 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
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 451 of file time_conversions.hpp.

◆ get_ts()

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::get_ts ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0 )
inline

Alias for to_timestamp function.

Converts a date and time 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
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 412 of file time_conversions.hpp.

◆ get_unix_day()

template<class T = uday_t>
const T time_shield::get_unix_day ( const ts_t & ts = ts())
constexprnoexcept

Get UNIX day.

This function returns the number of days elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is unix_day_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of days since the UNIX epoch.

Definition at line 915 of file time_conversions.hpp.

◆ get_unix_day_ms()

template<class T = uday_t>
const T time_shield::get_unix_day_ms ( const ts_ms_t & t_ms = ts_ms())
constexprnoexcept

Get UNIX day from milliseconds timestamp.

This function returns the number of days elapsed since the UNIX epoch, given a timestamp in milliseconds.

Template Parameters
TThe return type of the function (default is unix_day_t).
Parameters
t_msTimestamp in milliseconds (default is current timestamp in milliseconds).
Returns
Number of days since the UNIX epoch.

Definition at line 972 of file time_conversions.hpp.

◆ get_unix_min()

template<class T = int64_t>
const T time_shield::get_unix_min ( const ts_t & ts = ts())
constexpr

Get UNIX minute.

This function returns the number of minutes elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is int64_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of minutes since the UNIX epoch.

Definition at line 1028 of file time_conversions.hpp.

◆ get_unix_year()

template<class T = year_t>
const T time_shield::get_unix_year ( const ts_t & ts)
constexprnoexcept

Converts a UNIX timestamp to a year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
tsUNIX timestamp.
Returns
T Year corresponding to the given timestamp.

Definition at line 124 of file time_conversions.hpp.

◆ get_weekday()

template<class T1 = Weekday, class T2 = year_t, class T3 = int>
const T1 time_shield::get_weekday ( const T2 & year,
const T3 & month,
const T3 & day )
constexpr

Alias for day_of_week_date function.

Get the day of the week.

Parameters
yearYear.
monthMonth of the year.
dayDay of the month.
Returns
Day of the week (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1791 of file time_conversions.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 1812 of file time_conversions.hpp.

◆ get_weekday_from_ts()

template<class T = Weekday>
const T time_shield::get_weekday_from_ts ( const ts_t & ts)
constexprnoexcept

Get the weekday from a timestamp.

Parameters
tsTimestamp.
Returns
Weekday (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1836 of file time_conversions.hpp.

◆ get_weekday_from_ts_ms()

template<class T = Weekday>
const T time_shield::get_weekday_from_ts_ms ( const ts_ms_t & ts_ms)
constexpr

Get the weekday from a timestamp in milliseconds.

Parameters
ts_msTimestamp in milliseconds.
Returns
Weekday (SUN = 0, MON = 1, ... SAT = 6).

Definition at line 1853 of file time_conversions.hpp.

◆ get_year()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T time_shield::get_year ( const ts_t & ts = ts())
inline

Get the year from the timestamp.

This function returns the year of the specified timestamp in seconds since the Unix epoch.

Template Parameters
TThe return type of the function (default is year_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Year of the specified timestamp.

Definition at line 1131 of file time_conversions.hpp.

◆ get_year_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T time_shield::get_year_ms ( const ts_ms_t & ts_ms = ts_ms())
inline

Get the year from the timestamp in milliseconds.

This function returns the year of the specified timestamp in milliseconds since the Unix epoch.

Template Parameters
TThe return type of the function (default is year_t).
Parameters
ts_msTimestamp in milliseconds (default is current timestamp).
Returns
Year of the specified timestamp.

Definition at line 1159 of file time_conversions.hpp.

◆ h24_to_h12()

template<class T = int>
TIME_SHIELD_CONSTEXPR const T time_shield::h24_to_h12 ( const T & hour)
inlinenoexcept

Alias for hour24_to_12 function.

Converts a 24-hour format hour to a 12-hour format.

Template Parameters
TNumeric type of the hour (default is int).
Parameters
hourThe hour in 24-hour format to convert.
Returns
The hour in 12-hour format.

Definition at line 183 of file time_conversions.hpp.

◆ hour24_to_12()

template<class T = int>
TIME_SHIELD_CONSTEXPR const T time_shield::hour24_to_12 ( const T & hour)
inlinenoexcept

Converts a 24-hour format hour to a 12-hour format.

Template Parameters
TNumeric type of the hour (default is int).
Parameters
hourThe hour in 24-hour format to convert.
Returns
The hour in 12-hour format.

Definition at line 175 of file time_conversions.hpp.

◆ hour_begin()

const ts_t time_shield::hour_begin ( const ts_t & ts = ts())
constexprnoexcept

Alias for start_of_hour function.

Get the timestamp at the start of the hour.

This function sets the minute and second to zero.

Parameters
tsTimestamp (default: current timestamp).
Returns
Timestamp at the start of the hour.

Definition at line 1957 of file time_conversions.hpp.

◆ hour_begin_ms()

const ts_ms_t time_shield::hour_begin_ms ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Alias for start_of_hour_ms function.

Get the timestamp at the start of the hour. This function sets the minute and second to zero.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the start of the hour in milliseconds.

Definition at line 1991 of file time_conversions.hpp.

◆ hour_begin_sec()

const ts_t time_shield::hour_begin_sec ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Alias for start_of_hour_sec function.

Get the timestamp at the start of the hour.

This function sets the minute and second to zero.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the start of the hour in seconds.

Definition at line 1975 of file time_conversions.hpp.

◆ hour_in_day()

template<class T = int>
const T time_shield::hour_in_day ( const ts_t & ts = ts())
constexprnoexcept

Alias for hour_of_day function.

Get the hour of the day.

This function returns a value between 0 to 23 representing the hour of the day.

Parameters
tsTimestamp (default: current timestamp).
Returns
Hour of the day.

Definition at line 2063 of file time_conversions.hpp.

◆ hour_of_day()

template<class T = int>
const T time_shield::hour_of_day ( const ts_t & ts = ts())
constexprnoexcept

Get the hour of the day.

This function returns a value between 0 to 23 representing the hour of the day.

Parameters
tsTimestamp (default: current timestamp).
Returns
Hour of the day.

Definition at line 2056 of file time_conversions.hpp.

◆ is_day_off()

TIME_SHIELD_CONSTEXPR const bool time_shield::is_day_off ( const ts_t & ts)
inlinenoexcept

Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).

This function checks if the given timestamp falls on a weekend day, which is either Saturday or Sunday.

Parameters
tsTimestamp to check (default: current timestamp).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 273 of file validation.hpp.

◆ is_day_off_unix_day()

template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool time_shield::is_day_off_unix_day ( const T & unix_day)
inlinenoexcept

Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.

Parameters
unix_dayDay to check (number of days since Unix epoch).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 292 of file validation.hpp.

◆ is_leap_year()

TIME_SHIELD_CONSTEXPR const bool time_shield::is_leap_year ( const ts_t & ts)

Alias for is_leap_year_ts function.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 92 of file validation.hpp.

◆ is_leap_year_date()

template<class T = year_t>
const bool time_shield::is_leap_year_date ( const T & year)
constexprnoexcept

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 20 of file validation.hpp.

◆ is_leap_year_ts()

TIME_SHIELD_CONSTEXPR const bool time_shield::is_leap_year_ts ( const ts_t & ts)

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 48 of file validation.hpp.

◆ is_valid_date() [1/2]

template<class T >
TIME_SHIELD_CONSTEXPR const 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 223 of file validation.hpp.

◆ is_valid_date() [2/2]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const bool time_shield::is_valid_date ( const T1 & year,
const T2 & month,
const T2 & day )
inlinenoexcept

Checks the correctness of the specified date.

Template Parameters
T1The type of the year or day value (default is year_t).
T2The type of the month and day values (default is int).
Parameters
yearYear or day.
monthMonth.
dayDay or year.
Returns
true if the date is valid, false otherwise.

Definition at line 190 of file validation.hpp.

◆ is_valid_date_time() [1/2]

template<class T >
TIME_SHIELD_CONSTEXPR const 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 258 of file validation.hpp.

◆ is_valid_date_time() [2/2]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const bool time_shield::is_valid_date_time ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T3 & ms = 0 )
inlinenoexcept

Checks the correctness of a date and time.

Template Parameters
T1The type of the year or day value (default is year_t).
T2The type of the month and day values (default is int).
T3The type of the millisecond value (default is int).
Parameters
yearYear or day.
monthMonth.
dayDay or year.
hourHour (default is 0).
minMinute (default is 0).
secSecond (default is 0).
msMillisecond (default is 0).
Returns
true if the date and time are valid, false otherwise.

Definition at line 240 of file validation.hpp.

◆ is_valid_time() [1/2]

template<class T >
TIME_SHIELD_CONSTEXPR const 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 177 of file validation.hpp.

◆ is_valid_time() [2/2]

template<class T1 = int, class T2 = int>
TIME_SHIELD_CONSTEXPR const bool time_shield::is_valid_time ( const T1 & hour,
const T1 & min,
const T1 & sec,
const T2 & ms = 0 )
inlinenoexcept

Checks the correctness of the specified time.

Template Parameters
T1The type of the hour, minute, and second values (default is int).
T2The type of the millisecond value (default is int).
Parameters
hourHour
minMinute
secSecond
msMillisecond (default is 0).
Returns
true if the time is valid, false otherwise.

Definition at line 160 of file validation.hpp.

◆ is_valid_time_zone() [1/2]

template<class T = int>
TIME_SHIELD_CONSTEXPR const bool time_shield::is_valid_time_zone ( const T & hour,
const T & min )
inlinenoexcept

Check if the time zone is valid.

Template Parameters
TThe type of the time zone components (default is int).
Parameters
hourThe hour component of the time zone.
minThe minute component of the time zone.
Returns
True if the time zone is valid, false otherwise.

Definition at line 104 of file validation.hpp.

◆ is_valid_time_zone() [2/2]

template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR const 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 136 of file validation.hpp.

◆ is_valid_time_zone_offset()

template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR const 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 128 of file validation.hpp.

◆ is_valid_tz() [1/2]

template<class T = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_tz ( const T & hour,
const T & min )
inline

Alias for is_valid_time_zone function.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone components (default is int).
Parameters
hourThe hour component of the time zone.
minThe minute component of the time zone.
Returns
True if the time zone is valid, false otherwise.

Definition at line 115 of file validation.hpp.

◆ is_valid_tz() [2/2]

template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR const 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 144 of file validation.hpp.

◆ is_weekend()

TIME_SHIELD_CONSTEXPR const bool time_shield::is_weekend ( const ts_t & ts)
inlinenoexcept

Alias for is_day_off function.

Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).

This function checks if the given timestamp falls on a weekend day, which is either Saturday or Sunday.

Parameters
tsTimestamp to check (default: current timestamp).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 280 of file validation.hpp.

◆ is_weekend_unix_day()

template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool time_shield::is_weekend_unix_day ( const T & unix_day)
inlinenoexcept

Alias for is_day_off_unix_day function.

Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.

Parameters
unix_dayDay to check (number of days since Unix epoch).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 300 of file validation.hpp.

◆ last_day_of_month()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::last_day_of_month ( const ts_t & ts = ts())
inline

Alias for end_of_month function.

Get the last timestamp of the current month.

This function returns the last timestamp of the current month, setting the day to the last day of the month and the time to 23:59:59.

Parameters
tsTimestamp (default is current timestamp)
Returns
Last timestamp of the current month

Definition at line 1898 of file time_conversions.hpp.

◆ last_sunday_month_day()

template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR const T1 time_shield::last_sunday_month_day ( const T2 & year,
const T3 & month )
inline

Get the day of the last Sunday of the given month and year.

This function returns the day of the last Sunday of the specified month and year.

Parameters
yearYear
monthMonth (1 = January, 12 = December)
Returns
Day of the last Sunday of the given month and year

Definition at line 1931 of file time_conversions.hpp.

◆ last_sunday_of_month()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::last_sunday_of_month ( const ts_t & ts = ts())
inline

Get the timestamp of the last Sunday of the current month.

This function returns the timestamp of the last Sunday of the current month, setting the day to the last Sunday and the time to 00:00:00.

Parameters
tsTimestamp (default is current timestamp)
Returns
Timestamp of the last Sunday of the current month

Definition at line 1911 of file time_conversions.hpp.

◆ leap_year()

template<class T = year_t>
const bool time_shield::leap_year ( const T & year)
constexprnoexcept

Alias for is_leap_year_date function.

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 34 of file validation.hpp.

◆ leap_year_ts()

TIME_SHIELD_CONSTEXPR const bool time_shield::leap_year_ts ( const ts_t & ts)

Alias for is_leap_year_ts function.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 80 of file validation.hpp.

◆ min_begin()

const ts_t time_shield::min_begin ( const ts_t & ts = ts())
constexprnoexcept

Alias for start_of_min function.

Get the timestamp of the beginning of the minute.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the beginning of the minute.

Definition at line 2135 of file time_conversions.hpp.

◆ min_of_day()

template<class T = int>
const T time_shield::min_of_day ( const ts_t & ts = ts())
constexprnoexcept

Get minute of day. This function returns a value between 0 to 1439 (minute of day).

Parameters
tsTimestamp in seconds (default: current timestamp).
Returns
Minute of day.

Definition at line 2161 of file time_conversions.hpp.

◆ min_of_hour()

template<class T = int>
const T time_shield::min_of_hour ( const ts_t & ts = ts())
constexprnoexcept

Get minute of hour. This function returns a value between 0 to 59.

Parameters
tsTimestamp in seconds (default: current timestamp).
Returns
Minute of hour.

Definition at line 2172 of file time_conversions.hpp.

◆ month_begin()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::month_begin ( const ts_t & ts = ts())
inline

Alias for start_of_month function.

Get the timestamp at the start of the current month.

This function returns the timestamp at the start of the current month, setting the day to the first day of the month and the time to 00:00:00.

Parameters
tsTimestamp (default is current timestamp)
Returns
Timestamp at the start of the current month

Definition at line 1879 of file time_conversions.hpp.

◆ month_of_year() [1/3]

template<class T = Month>
const T time_shield::month_of_year ( const std::string & month)

Alias for get_month_number function.

Get the month number by name.

Template Parameters
TThe return type, default is Month enum.
Parameters
monthThe name of the month as a string.
Returns
The month number corresponding to the given name.
Exceptions
std::invalid_argumentif the month name is invalid.

Definition at line 59 of file time_parser.hpp.

◆ month_of_year() [2/3]

template<class T = Month>
const bool time_shield::month_of_year ( const std::string & month,
T & value )

Alias for try_get_month_number function.

Get the month number by name, with output parameter.

Template Parameters
TThe type for the month number, default is Month enum.
Parameters
monthThe name of the month as a string.
valueThe reference to store the month number if found.
Returns
True if the month name is valid, false otherwise.

Definition at line 108 of file time_parser.hpp.

◆ month_of_year() [3/3]

template<class T = Month>
TIME_SHIELD_CONSTEXPR const T time_shield::month_of_year ( const ts_t & ts)
inlinenoexcept

Get the month of the year.

This function returns the month of the year for the specified timestamp.

Parameters
tsTimestamp.
Returns
Month of the year.

Definition at line 1461 of file time_conversions.hpp.

◆ ms_of_sec() [1/2]

template<class T = int>
const T time_shield::ms_of_sec ( )
noexcept

Get the millisecond part of the current second.

Template Parameters
TType of the returned value (default is int).
Returns
T Millisecond part of the current second.

Definition at line 49 of file time_utils.hpp.

◆ ms_of_sec() [2/2]

template<class T = int>
const T time_shield::ms_of_sec ( const fts_t & ts)
constexprnoexcept

Get the millisecond part of the second from a floating-point timestamp.

Template Parameters
TType of the returned value (default is int).
Parameters
tsTimestamp in floating-point seconds.
Returns
T Millisecond part of the second.

Definition at line 44 of file time_conversions.hpp.

◆ ms_of_ts()

template<class T = int>
const T time_shield::ms_of_ts ( const ts_ms_t & ts)
constexprnoexcept

Get the millisecond part of the timestamp.

Template Parameters
TType of the returned value (default is int).
Parameters
tsTimestamp in milliseconds.
Returns
T Millisecond part of the timestamp.

Definition at line 54 of file time_conversions.hpp.

◆ ms_to_fsec()

template<class T = ts_ms_t>
const fts_t time_shield::ms_to_fsec ( const T & ts_ms)
constexprnoexcept

Converts a timestamp from milliseconds to floating-point seconds.

Template Parameters
TThe type of the input timestamp (default is ts_ms_t).
Parameters
ts_msTimestamp in milliseconds.
Returns
fts_t Timestamp in floating-point seconds.

Definition at line 113 of file time_conversions.hpp.

◆ ms_to_sec()

template<class T1 = ts_t, class T2 = ts_ms_t>
const T1 time_shield::ms_to_sec ( const T2 & ts_ms)
constexprnoexcept

Converts a timestamp from milliseconds to seconds.

Template Parameters
T1The type of the output timestamp (default is ts_t).
T2The type of the input timestamp (default is ts_ms_t).
Parameters
ts_msTimestamp in milliseconds.
Returns
T1 Timestamp in seconds.

Definition at line 104 of file time_conversions.hpp.

◆ next_day_start()

template<class T = int>
const ts_t time_shield::next_day_start ( const ts_t & ts,
const T & days = 1 )
constexpr

Alias for start_of_next_day function.

Get timestamp of the first day after a specified number of days.

This function returns the timestamp of the start of the day after a specified number of days.

Parameters
tsCurrent timestamp.
daysNumber of days after the current day (default is 1).
Returns
Timestamp of the first day after the specified number of days.

Definition at line 1713 of file time_conversions.hpp.

◆ now()

const ts_ms_t time_shield::now ( )
inlinenoexcept

Get the current UTC timestamp in milliseconds.

Returns
ts_ms_t Current UTC timestamp in milliseconds.

Definition at line 98 of file time_utils.hpp.

◆ ns_of_sec() [1/2]

template<class T = int>
const T time_shield::ns_of_sec ( )
inlinenoexcept

Get the nanosecond part of the current second.

Template Parameters
TType of the returned value (default is int).
Returns
T Nanosecond part of the current second.

Definition at line 31 of file time_utils.hpp.

◆ ns_of_sec() [2/2]

template<class T = int>
const T time_shield::ns_of_sec ( const fts_t & ts)
constexprnoexcept

Get the nanosecond part of the second from a floating-point timestamp.

Template Parameters
TType of the returned value (default is int).
Parameters
tsTimestamp in floating-point seconds.
Returns
T Nanosecond part of the second.

Definition at line 24 of file time_conversions.hpp.

◆ num_days_in_month() [1/2]

template<class T1 = int, class T2 = year_t, class T3 = int>
const T1 time_shield::num_days_in_month ( const T2 & year,
const T3 & month )
constexprnoexcept

Get the number of days in a month.

This function calculates and returns the number of days in the specified month and year.

Parameters
yearYear as an integer.
monthMonth as an integer.
Returns
The number of days in the given month and year.

Definition at line 1527 of file time_conversions.hpp.

◆ num_days_in_month() [2/2]

template<class T1 = int>
const T1 time_shield::num_days_in_month ( const ts_t & ts = ts())
constexprnoexcept

Alias for num_days_in_month_ts function.

Get the number of days in the month of the given timestamp.

This function calculates and returns the number of days in the month of the specified timestamp.

Parameters
tsThe timestamp to extract month and year from.
Returns
The number of days in the month of the given timestamp.

Definition at line 1565 of file time_conversions.hpp.

◆ num_days_in_month_ts()

template<class T1 = int>
TIME_SHIELD_CONSTEXPR const T1 time_shield::num_days_in_month_ts ( const ts_t & ts = ts())
noexcept

Get the number of days in the month of the given timestamp.

This function calculates and returns the number of days in the month of the specified timestamp.

Parameters
tsThe timestamp to extract month and year from.
Returns
The number of days in the month of the given timestamp.

Definition at line 1553 of file time_conversions.hpp.

◆ num_days_in_year()

template<class T1 = int, class T2 = year_t>
const T1 time_shield::num_days_in_year ( const T2 & year)
constexprnoexcept

Get the number of days in a given year.

This function calculates and returns the number of days in the specified year.

Parameters
yearYear.
Returns
Number of days in the given year.

Definition at line 1585 of file time_conversions.hpp.

◆ num_days_in_year_ts()

template<class T = int>
const T time_shield::num_days_in_year_ts ( const ts_t & ts = ts())
constexpr

Get the number of days in the current year.

This function calculates and returns the number of days in the current year based on the provided timestamp.

Parameters
tsTimestamp.
Returns
Number of days in the current year.

Definition at line 1606 of file time_conversions.hpp.

◆ parse_iso8601()

const bool time_shield::parse_iso8601 ( const std::string & input,
DateTimeStruct & dt,
TimeZoneStruct & tz )

Parse a date and time string in ISO8601 format.

This function parses a date and time string in the ISO8601 format and fills the provided DateTimeStruct and TimeZoneStruct with the parsed values.

Parameters
inputThe input string in ISO8601 format.
dtThe DateTimeStruct to be filled with the parsed date and time values.
tzThe TimeZoneStruct to be filled with the parsed time zone values.
Returns
True if the parsing is successful and the date and time values are valid, false otherwise.

Definition at line 154 of file time_parser.hpp.

◆ parse_time_zone()

const bool time_shield::parse_time_zone ( const std::string & tz_str,
TimeZoneStruct & tz )

Parse a time zone string into a TimeZoneStruct.

This function parses a time zone string in the format "+hh:mm" or "Z" into a TimeZoneStruct. If the string is empty or "Z", it sets the time zone to UTC.

Parameters
tz_strThe time zone string.
tzThe TimeZoneStruct to be filled.
Returns
True if the parsing is successful and the time zone is valid, false otherwise.

Definition at line 120 of file time_parser.hpp.

◆ parse_tz()

const bool time_shield::parse_tz ( const std::string & tz_str,
TimeZoneStruct & tz )
inline

Alias for parse_time_zone function.

Parse a time zone string into a TimeZoneStruct.

This function parses a time zone string in the format "+hh:mm" or "Z" into a TimeZoneStruct. If the string is empty or "Z", it sets the time zone to UTC.

Parameters
tz_strThe time zone string.
tzThe TimeZoneStruct to be filled.
Returns
True if the parsing is successful and the time zone is valid, false otherwise.

Definition at line 141 of file time_parser.hpp.

◆ previous_day_start()

template<class T = int>
const ts_t time_shield::previous_day_start ( const ts_t & ts = ts(),
const T & days = 1 )
constexpr

Alias for start_of_prev_day function.

Get timestamp of the start of the previous day.

This function returns the timestamp at the start of the previous day.

Parameters
tsTimestamp of the current day.
daysNumber of days to go back (default is 1).
Returns
Timestamp of the start of the previous day.

Definition at line 1654 of file time_conversions.hpp.

◆ process_format_impl()

void time_shield::process_format_impl ( const char & last_char,
const size_t & repeat_count,
const ts_t & ts,
const tz_t & utc_offset,
const DateTimeStruct & dt,
std::string & result )
inline

Definition at line 17 of file time_formatting.hpp.

◆ saturday_begin()

const ts_t time_shield::saturday_begin ( const ts_t & ts = ts())
constexpr

Alias for start_of_saturday function.

Get the timestamp of the start of Saturday.

This function finds the timestamp of the beginning of the day on Saturday, which corresponds to the start of Saturday.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the start of Saturday.

Definition at line 2120 of file time_conversions.hpp.

◆ sec_of_day() [1/2]

template<class T1 = int, class T2 = int>
const T1 time_shield::sec_of_day ( const T2 & hour,
const T2 & min,
const T2 & sec )
constexprnoexcept

Get the second of the day.

This function returns a value between 0 and MAX_SEC_PER_DAY representing the second of the day, given the hour, minute, and second.

Template Parameters
T1The return type of the function (default is int).
T2The type of the hour, minute, and second parameters (default is int).
Parameters
hourHour of the day.
minMinute of the hour.
secSecond of the minute.
Returns
Second of the day.

Definition at line 1090 of file time_conversions.hpp.

◆ sec_of_day() [2/2]

template<class T = int>
const T time_shield::sec_of_day ( const ts_t & ts = ts())
constexpr

Get the second of the day.

This function returns a value from 0 to MAX_SEC_PER_DAY representing the second of the day.

Template Parameters
TThe return type of the function (default is int).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Second of the day.

Definition at line 1063 of file time_conversions.hpp.

◆ sec_of_day_ms()

template<class T = int>
const T time_shield::sec_of_day_ms ( const ts_ms_t & ts_ms)
constexprnoexcept

Get the second of the day from milliseconds timestamp.

This function returns a value from 0 to MAX_SEC_PER_DAY representing the second of the day, given a timestamp in milliseconds.

Template Parameters
TThe return type of the function (default is int).
Parameters
ts_msTimestamp in milliseconds.
Returns
Second of the day.

Definition at line 1075 of file time_conversions.hpp.

◆ sec_of_hour()

template<class T = int>
const T time_shield::sec_of_hour ( const ts_t & ts = ts())
constexpr

Get the second of the hour.

This function returns a value between 0 and 3599 representing the second of the hour.

Template Parameters
TThe return type of the function (default is int).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Second of the hour.

Definition at line 1117 of file time_conversions.hpp.

◆ sec_of_min()

template<class T = int>
const T time_shield::sec_of_min ( const ts_t & ts = ts())
constexpr

Get the second of the minute.

This function returns a value between 0 and 59 representing the second of the minute.

Template Parameters
TThe return type of the function (default is int).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Second of the minute.

Definition at line 1105 of file time_conversions.hpp.

◆ sec_to_ms()

template<class T1 = ts_ms_t, class T2 >
const T1 time_shield::sec_to_ms ( const T2 & ts)
constexprnoexcept

Converts a timestamp from seconds to milliseconds.

Template Parameters
T1The type of the output timestamp (default is ts_ms_t).
T2The type of the input timestamp.
Parameters
tsTimestamp in seconds.
Returns
T1 Timestamp in milliseconds.

Definition at line 76 of file time_conversions.hpp.

◆ sec_to_ms_impl() [1/2]

template<class T >
const ts_ms_t time_shield::sec_to_ms_impl ( const T & t,
std::false_type  )
constexprnoexcept

Definition at line 65 of file time_conversions.hpp.

◆ sec_to_ms_impl() [2/2]

template<class T >
const ts_ms_t time_shield::sec_to_ms_impl ( const T & t,
std::true_type  )
constexprnoexcept

Definition at line 60 of file time_conversions.hpp.

◆ start_of_day()

const ts_t time_shield::start_of_day ( const ts_t & ts = ts())
constexprnoexcept

Get the start of the day timestamp.

This function returns the timestamp at the start of the day. The function sets the hours, minutes, and seconds to zero.

Parameters
tsTimestamp.
Returns
Start of the day timestamp.

Definition at line 1627 of file time_conversions.hpp.

◆ start_of_day_ms()

const ts_ms_t time_shield::start_of_day_ms ( const ts_ms_t & ts_ms = ts_ms())
constexpr

Get the start of the day timestamp in milliseconds.

This function returns the timestamp at the start of the day in milliseconds. The function sets the hours, minutes, seconds, and milliseconds to zero.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of the day timestamp in milliseconds.

Definition at line 1686 of file time_conversions.hpp.

◆ start_of_day_sec()

const ts_t time_shield::start_of_day_sec ( const ts_ms_t & ts_ms = ts_ms())
constexpr

Get the start of the day timestamp in seconds.

This function returns the timestamp at the start of the day in seconds. The function sets the hours, minutes, and seconds to zero.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of the day timestamp in seconds.

Definition at line 1667 of file time_conversions.hpp.

◆ start_of_hour()

const ts_t time_shield::start_of_hour ( const ts_t & ts = ts())
constexprnoexcept

Get the timestamp at the start of the hour.

This function sets the minute and second to zero.

Parameters
tsTimestamp (default: current timestamp).
Returns
Timestamp at the start of the hour.

Definition at line 1951 of file time_conversions.hpp.

◆ start_of_hour_ms()

const ts_ms_t time_shield::start_of_hour_ms ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Get the timestamp at the start of the hour. This function sets the minute and second to zero.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the start of the hour in milliseconds.

Definition at line 1985 of file time_conversions.hpp.

◆ start_of_hour_sec()

const ts_t time_shield::start_of_hour_sec ( const ts_ms_t & ts_ms = ts_ms())
constexprnoexcept

Get the timestamp at the start of the hour.

This function sets the minute and second to zero.

Parameters
ts_msTimestamp in milliseconds (default: current timestamp in milliseconds).
Returns
Timestamp at the start of the hour in seconds.

Definition at line 1969 of file time_conversions.hpp.

◆ start_of_min()

const ts_t time_shield::start_of_min ( const ts_t & ts = ts())
constexprnoexcept

Get the timestamp of the beginning of the minute.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the beginning of the minute.

Definition at line 2129 of file time_conversions.hpp.

◆ start_of_month()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::start_of_month ( const ts_t & ts = ts())
inline

Get the timestamp at the start of the current month.

This function returns the timestamp at the start of the current month, setting the day to the first day of the month and the time to 00:00:00.

Parameters
tsTimestamp (default is current timestamp)
Returns
Timestamp at the start of the current month

Definition at line 1873 of file time_conversions.hpp.

◆ start_of_next_day()

template<class T = int>
const ts_t time_shield::start_of_next_day ( const ts_t & ts,
const T & days = 1 )
constexpr

Get timestamp of the first day after a specified number of days.

This function returns the timestamp of the start of the day after a specified number of days.

Parameters
tsCurrent timestamp.
daysNumber of days after the current day (default is 1).
Returns
Timestamp of the first day after the specified number of days.

Definition at line 1706 of file time_conversions.hpp.

◆ start_of_period()

template<class T = int>
const ts_t time_shield::start_of_period ( const T & p,
const ts_t & ts = ts() )
constexpr

Get the timestamp of the start of the period.

Parameters
pPeriod duration in seconds.
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the start of the period.

Definition at line 2183 of file time_conversions.hpp.

◆ start_of_prev_day()

template<class T = int>
const ts_t time_shield::start_of_prev_day ( const ts_t & ts = ts(),
const T & days = 1 )
constexpr

Get timestamp of the start of the previous day.

This function returns the timestamp at the start of the previous day.

Parameters
tsTimestamp of the current day.
daysNumber of days to go back (default is 1).
Returns
Timestamp of the start of the previous day.

Definition at line 1647 of file time_conversions.hpp.

◆ start_of_saturday()

const ts_t time_shield::start_of_saturday ( const ts_t & ts = ts())
constexpr

Get the timestamp of the start of Saturday.

This function finds the timestamp of the beginning of the day on Saturday, which corresponds to the start of Saturday.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the start of Saturday.

Definition at line 2114 of file time_conversions.hpp.

◆ start_of_week()

const ts_t time_shield::start_of_week ( const ts_t & ts = ts())
constexpr

Get the timestamp of the beginning of the week.

This function finds the timestamp of the beginning of the week, which corresponds to the start of Sunday.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the beginning of the week.

Definition at line 2076 of file time_conversions.hpp.

◆ start_of_year()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::start_of_year ( const ts_t & ts)
inlinenoexcept

Get the start of the year timestamp.

This function resets the days, months, hours, minutes, and seconds of the given timestamp to the beginning of the year.

Parameters
tsTimestamp.
Returns
Start of the year timestamp.

Definition at line 1186 of file time_conversions.hpp.

◆ start_of_year_date()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::start_of_year_date ( const T & year)
inline

Get the timestamp of the start of the year.

This function returns the timestamp at the start of the specified year.

Parameters
yearYear.
Returns
Timestamp of the start of the year.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1287 of file time_conversions.hpp.

◆ start_of_year_date_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::start_of_year_date_ms ( const T & year)
inline

Get the timestamp in milliseconds of the start of the year.

This function returns the timestamp at the start of the specified year in milliseconds.

Parameters
yearYear.
Returns
Timestamp of the start of the year in milliseconds.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1329 of file time_conversions.hpp.

◆ start_of_year_ms()

TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::start_of_year_ms ( const ts_ms_t & ts_ms = ts_ms())
inlinenoexcept

Get the start of the year timestamp in milliseconds.

This function resets the days, months, hours, minutes, and seconds of the given timestamp to the beginning of the year.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of year timestamp in milliseconds.

Definition at line 1261 of file time_conversions.hpp.

◆ str_to_fts()

const bool time_shield::str_to_fts ( const std::string & str,
fts_t & ts )
inline

Convert an ISO8601 string to a floating-point timestamp (fts_t).

This function parses a string in ISO8601 format and converts it to a floating-point timestamp.

Parameters
strThe ISO8601 string.
tsThe floating-point timestamp to be filled.
Returns
True if the parsing and conversion are successful, false otherwise.

Definition at line 231 of file time_parser.hpp.

◆ str_to_ts()

const bool time_shield::str_to_ts ( const std::string & str,
ts_t & ts )
inline

Convert an ISO8601 string to a timestamp (ts_t).

This function parses a string in ISO8601 format and converts it to a timestamp.

Parameters
strThe ISO8601 string.
tsThe timestamp to be filled.
Returns
True if the parsing and conversion are successful, false otherwise.

Definition at line 199 of file time_parser.hpp.

◆ str_to_ts_ms()

const bool time_shield::str_to_ts_ms ( const std::string & str,
ts_ms_t & ts )
inline

Convert an ISO8601 string to a millisecond timestamp (ts_ms_t).

This function parses a string in ISO8601 format and converts it to a millisecond timestamp.

Parameters
strThe ISO8601 string.
tsThe millisecond timestamp to be filled.
Returns
True if the parsing and conversion are successful, false otherwise.

Definition at line 215 of file time_parser.hpp.

◆ time_zone_struct_to_offset()

const tz_t time_shield::time_zone_struct_to_offset ( const TimeZoneStruct & tz)
inline

Converts a TimeZoneStruct to a single integer representation.

Parameters
tzThe TimeZoneStruct to convert.
Returns
An integer representing the TimeZoneStruct.

Definition at line 81 of file time_zone_struct.hpp.

◆ time_zone_struct_to_string()

const std::string time_shield::time_zone_struct_to_string ( const TimeZoneStruct & tz)
inline

Converts a TimeZoneStruct to a string representation.

Parameters
tzThe TimeZoneStruct to convert.
Returns
A string representation of the TimeZoneStruct.

Definition at line 59 of file time_zone_struct.hpp.

◆ timestamp() [1/4]

const ts_t time_shield::timestamp ( )
inlinenoexcept

Get the current UTC timestamp in seconds.

Returns
ts_t Current UTC timestamp in seconds.

Definition at line 63 of file time_utils.hpp.

◆ timestamp() [2/4]

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

Alias for tm_to_timestamp function.

Converts a std::tm structure to a timestamp.

This function converts a standard C++ std::tm structure to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 560 of file time_conversions.hpp.

◆ timestamp() [3/4]

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 511 of file time_conversions.hpp.

◆ timestamp() [4/4]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::timestamp ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0 )
inline

Alias for to_timestamp function.

Converts a date and time 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
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 438 of file time_conversions.hpp.

◆ timestamp_ms() [1/4]

const ts_ms_t time_shield::timestamp_ms ( )
inlinenoexcept

Get the current UTC timestamp in milliseconds.

Returns
ts_ms_t Current UTC timestamp in milliseconds.

Definition at line 91 of file time_utils.hpp.

◆ timestamp_ms() [2/4]

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

Alias for tm_to_timestamp_ms function.

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 730 of file time_conversions.hpp.

◆ timestamp_ms() [3/4]

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 688 of file time_conversions.hpp.

◆ timestamp_ms() [4/4]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::timestamp_ms ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T2 & ms = 0 )
inline

Alias for to_timestamp_ms function.

Converts a date and time to a timestamp in milliseconds.

This function converts a given date and time to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).

Template Parameters
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 633 of file time_conversions.hpp.

◆ timestamp_us()

const ts_us_t time_shield::timestamp_us ( )
inlinenoexcept

Get the current UTC timestamp in microseconds.

Returns
ts_us_t Current UTC timestamp in microseconds.

Definition at line 112 of file time_utils.hpp.

◆ tm_to_ftimestamp()

TIME_SHIELD_CONSTEXPR const fts_t time_shield::tm_to_ftimestamp ( const std::tm * timeinfo)
inline

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 872 of file time_conversions.hpp.

◆ tm_to_timestamp()

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

Converts a std::tm structure to a timestamp.

This function converts a standard C++ std::tm structure to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 526 of file time_conversions.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 702 of file time_conversions.hpp.

◆ to_cstr() [1/3]

const char * time_shield::to_cstr ( const Month & value,
const FormatType & format = UPPERCASE_NAME )

Converts a Month enum value to a string.

Parameters
valueThe Month enum value to convert.
formatThe format to use for the string representation (default is UPPERCASE_NAME).
Returns
A const char* pointing to the string representation of the month.

Definition at line 105 of file enums.hpp.

◆ to_cstr() [2/3]

const char * time_shield::to_cstr ( const TimeZone & value,
const FormatType & format = UPPERCASE_NAME )

Converts a TimeZone enum value to a string.

Parameters
valueThe TimeZone enum value to convert.
formatThe format to use for the string representation (default is UPPERCASE_NAME).
Returns
A const char* pointing to the string representation of the time zone.

Definition at line 182 of file enums.hpp.

◆ to_cstr() [3/3]

const char * time_shield::to_cstr ( const Weekday & value,
const FormatType & format = UPPERCASE_NAME )

Converts a Weekday enum value to a string.

Parameters
valueThe Weekday enum value to convert.
formatThe format to use for the string representation (default is UPPERCASE_NAME).
Returns
A const char* pointing to the string representation of the day.

Definition at line 37 of file enums.hpp.

◆ to_date_time()

template<class T1 , class T2 = ts_t>
T1 time_shield::to_date_time ( const 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 199 of file time_conversions.hpp.

◆ to_date_time_ms()

template<class T >
T time_shield::to_date_time_ms ( const 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 310 of file time_conversions.hpp.

◆ to_dt()

template<class T1 , class T2 = ts_t>
T1 time_shield::to_dt ( const 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 299 of file time_conversions.hpp.

◆ to_dt_ms()

template<class T >
T time_shield::to_dt_ms ( const 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 319 of file time_conversions.hpp.

◆ to_ftimestamp() [1/3]

TIME_SHIELD_CONSTEXPR const fts_t time_shield::to_ftimestamp ( const std::tm * timeinfo)
inline

Alias for tm_to_ftimestamp function.

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 879 of file time_conversions.hpp.

◆ to_ftimestamp() [2/3]

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

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 832 of file time_conversions.hpp.

◆ to_ftimestamp() [3/3]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t time_shield::to_ftimestamp ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T3 & ms = 0 )
inline

Converts a date and time to a floating-point timestamp.

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

Template Parameters
T1The type of the year parameter (default is year_t).
T2The type of the month, day, hour, minute, and second parameters (default is int).
T3The type of the millisecond parameter (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 756 of file time_conversions.hpp.

◆ to_fts() [1/3]

TIME_SHIELD_CONSTEXPR const fts_t time_shield::to_fts ( const std::tm * timeinfo)
inline

Alias for tm_to_ftimestamp function.

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 886 of file time_conversions.hpp.

◆ to_fts() [2/3]

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

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 840 of file time_conversions.hpp.

◆ to_fts() [3/3]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const fts_t time_shield::to_fts ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T3 & ms = 0 )
inline

Alias for to_ftimestamp function.

Converts a date and time to a floating-point timestamp.

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

Template Parameters
T1The type of the year parameter (default is year_t).
T2The type of the month, day, hour, minute, and second parameters (default is int).
T3The type of the millisecond parameter (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Floating-point timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 771 of file time_conversions.hpp.

◆ to_iso8601_date_str()

template<class T = ts_t>
const std::string time_shield::to_iso8601_date_str ( const T & ts)
inline

Converts a timestamp to an ISO8601 date string.

This function converts the date part of a timestamp to a string in ISO8601 format.

Template Parameters
TThe type of the timestamp (default is ts_t).
Parameters
tsThe timestamp to convert.
Returns
A string representing the date part of the timestamp in ISO8601 format.

Definition at line 455 of file time_formatting.hpp.

◆ to_iso8601_str() [1/2]

template<class T = ts_t>
const std::string time_shield::to_iso8601_str ( const T & ts)
inline

Converts a timestamp to an ISO8601 string.

This function converts a timestamp to a string in ISO8601 format.

Template Parameters
TThe type of the timestamp (default is ts_t).
Parameters
tsThe timestamp to convert.
Returns
A string representing the timestamp in ISO8601 format.

Definition at line 436 of file time_formatting.hpp.

◆ to_iso8601_str() [2/2]

template<class T = ts_t>
const std::string time_shield::to_iso8601_str ( const T & ts,
const tz_t & utc_offset )
inline

Converts a timestamp to an ISO8601 string with timezone offset.

This function converts a timestamp to a string in ISO8601 format with timezone offset.

Template Parameters
TThe type of the timestamp (default is ts_t).
Parameters
tsThe timestamp to convert.
utc_offsetThe timezone offset in seconds.
Returns
A string representing the timestamp in ISO8601 format with timezone offset.

Definition at line 554 of file time_formatting.hpp.

◆ to_iso8601_str_ms() [1/2]

const std::string time_shield::to_iso8601_str_ms ( const ts_ms_t & ts_ms)
inline

Converts a timestamp in milliseconds to an ISO8601 string.

This function converts a timestamp in milliseconds to a string in ISO8601 format.

Parameters
ts_msThe timestamp in milliseconds to convert.
Returns
A string representing the timestamp in ISO8601 format with milliseconds.

Definition at line 538 of file time_formatting.hpp.

◆ to_iso8601_str_ms() [2/2]

const std::string time_shield::to_iso8601_str_ms ( const ts_ms_t & ts_ms,
const tz_t & utc_offset )
inline

Converts a timestamp in milliseconds to an ISO8601 string with timezone offset.

This function converts a timestamp in milliseconds to a string in ISO8601 format with timezone offset.

Parameters
ts_msThe timestamp in milliseconds to convert.
utc_offsetThe timezone offset in seconds.
Returns
A string representing the timestamp in ISO8601 format with timezone offset and milliseconds.

Definition at line 581 of file time_formatting.hpp.

◆ to_iso8601_time_str()

template<class T = ts_t>
const std::string time_shield::to_iso8601_time_str ( const T & ts)
inline

Converts a timestamp to an ISO8601 time string.

This function converts the time part of a timestamp to a string in ISO8601 format.

Template Parameters
TThe type of the timestamp (default is ts_t).
Parameters
tsThe timestamp to convert.
Returns
A string representing the time part of the timestamp in ISO8601 format.

Definition at line 470 of file time_formatting.hpp.

◆ to_iso8601_time_utc_str()

template<class T = ts_t>
const std::string time_shield::to_iso8601_time_utc_str ( const T & ts)
inline

Converts a timestamp to an ISO8601 UTC time string.

This function converts the time part of a timestamp to a string in ISO8601 format with 'Z' indicating UTC.

Template Parameters
TThe type of the timestamp (default is ts_t).
Parameters
tsThe timestamp to convert.
Returns
A string representing the time part of the timestamp in ISO8601 format with 'Z' indicating UTC.

Definition at line 489 of file time_formatting.hpp.

◆ to_iso8601_utc_str()

template<class T = ts_t>
const std::string time_shield::to_iso8601_utc_str ( const T & ts)
inline

Converts a timestamp to an ISO8601 string in UTC format.

This function converts a timestamp to a string in ISO8601 format with UTC timezone.

Template Parameters
TThe type of the timestamp (default is ts_t).
Parameters
tsThe timestamp to convert.
Returns
A string representing the timestamp in ISO8601 UTC format.

Definition at line 508 of file time_formatting.hpp.

◆ to_iso8601_utc_str_ms()

const std::string time_shield::to_iso8601_utc_str_ms ( const ts_ms_t & ts_ms)
inline

Converts a timestamp in milliseconds to an ISO8601 string in UTC format.

This function converts a timestamp in milliseconds to a string in ISO8601 format with UTC timezone.

Parameters
ts_msThe timestamp in milliseconds to convert.
Returns
A string representing the timestamp in ISO8601 UTC format with milliseconds.

Definition at line 525 of file time_formatting.hpp.

◆ to_mql5_date_str()

const std::string time_shield::to_mql5_date_str ( const ts_t & ts)
inline

Converts a timestamp to a string in MQL5 date format.

This function converts a timestamp to a string in MQL5 date format (yyyy.mm.dd).

Parameters
tsThe timestamp to convert.
Returns
A string representing the date part of the timestamp in MQL5 format.

Definition at line 618 of file time_formatting.hpp.

◆ to_mql5_date_time_str()

const std::string time_shield::to_mql5_date_time_str ( const ts_t & ts)
inline

Converts a timestamp to a string in MQL5 date and time format.

This function converts a timestamp to a string in MQL5 date and time format (yyyy.mm.dd hh:mi:ss).

Parameters
tsThe timestamp to convert.
Returns
A string representing the timestamp in MQL5 date and time format.

Definition at line 599 of file time_formatting.hpp.

◆ to_mql5_full_str()

const std::string time_shield::to_mql5_full_str ( const ts_t & ts)
inline

Alias for to_mql5_date_time_str function.

Converts a timestamp to a string in MQL5 date and time format.

This function converts a timestamp to a string in MQL5 date and time format (yyyy.mm.dd hh:mi:ss).

Parameters
tsThe timestamp to convert.
Returns
A string representing the timestamp in MQL5 date and time format.

Definition at line 608 of file time_formatting.hpp.

◆ to_mql5_time_str()

const std::string time_shield::to_mql5_time_str ( const ts_t & ts)
inline

Converts a timestamp to a string in MQL5 time format.

This function converts a timestamp to a string in MQL5 time format (hh:mi:ss).

Parameters
tsThe timestamp to convert.
Returns
A string representing the time part of the timestamp in MQL5 format.

Definition at line 631 of file time_formatting.hpp.

◆ to_offset()

const tz_t time_shield::to_offset ( const TimeZoneStruct & tz)
inline

Alias for time_zone_struct_to_offset function.

Converts a TimeZoneStruct to a single integer representation.

Parameters
tzThe TimeZoneStruct to convert.
Returns
An integer representing the TimeZoneStruct.

Definition at line 93 of file time_zone_struct.hpp.

◆ to_str() [1/5]

const std::string & time_shield::to_str ( const Month & value,
const FormatType & format = UPPERCASE_NAME )

Converts a Month enum value to a string.

Parameters
valueThe Month enum value to convert.
formatThe format to use for the string representation (default is UPPERCASE_NAME).
Returns
A const std::string& pointing to the string representation of the month.

Definition at line 137 of file enums.hpp.

◆ to_str() [2/5]

template<class T = ts_t>
const std::string time_shield::to_str ( const std::string & format_str,
const T & timestamp,
const tz_t & utc_offset = 0 )
inline

Alias for to_string function.

Convert timestamp to string with custom format.

This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.

The function accepts the following format specifiers as parameters:

  • YYYYYY: Year with reduction in the number of millennia.
  • YYYY: Year represented by 4 digits.
  • YY: Last two digits of the year.
  • MM: Month (01-12).
  • MMM: Abbreviated month name.
  • DD: Day of the month (01-31).
  • hh: Hour of the day in 24-hour format (00-23).
  • mm: Minute of the hour (00-59).
  • ss: Second (00-59).
  • sss: Millisecond (000-999).
  • WWW: Abbreviated day of the week name in uppercase (SUN, MON, TUE, etc.).
  • www: Abbreviated day of the week name (Sun, Mon, Tue, etc.).

For more information, see the strftime specifiers documentation:

See also
https://manpages.debian.org/bullseye/manpages-dev/strftime.3.en.html
Parameters
format_strFormat string with custom parameters, e.g., "%H:%M:%S".
timestampTimestamp.
utc_offsetUTC offset in seconds (default is 0).
Returns
Returns a string in the format specified by the user.

Definition at line 421 of file time_formatting.hpp.

◆ to_str() [3/5]

const std::string & time_shield::to_str ( const TimeZone & value,
const FormatType & format = UPPERCASE_NAME )

Converts a TimeZone enum value to a string.

Parameters
valueThe TimeZone enum value to convert.
formatThe format to use for the string representation (default is UPPERCASE_NAME).
Returns
A const std::string& pointing to the string representation of the time zone.

Definition at line 210 of file enums.hpp.

◆ to_str() [4/5]

const std::string time_shield::to_str ( const TimeZoneStruct & tz)
inline

Alias for time_zone_struct_to_string function.

Converts a TimeZoneStruct to a string representation.

Parameters
tzThe TimeZoneStruct to convert.
Returns
A string representation of the TimeZoneStruct.

Definition at line 72 of file time_zone_struct.hpp.

◆ to_str() [5/5]

const std::string & time_shield::to_str ( const Weekday & value,
const FormatType & format = UPPERCASE_NAME )

Converts a Weekday enum value to a string.

Parameters
valueThe Weekday enum value to convert.
formatThe format to use for the string representation (default is UPPERCASE_NAME).
Returns
A const std::string& pointing to the string representation of the day.

Definition at line 63 of file enums.hpp.

◆ to_string() [1/2]

template<class T = ts_t>
const std::string time_shield::to_string ( const std::string & format_str,
const T & timestamp,
const tz_t & utc_offset = 0 )

Convert timestamp to string with custom format.

This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.

The function accepts the following format specifiers as parameters:

  • YYYYYY: Year with reduction in the number of millennia.
  • YYYY: Year represented by 4 digits.
  • YY: Last two digits of the year.
  • MM: Month (01-12).
  • MMM: Abbreviated month name.
  • DD: Day of the month (01-31).
  • hh: Hour of the day in 24-hour format (00-23).
  • mm: Minute of the hour (00-59).
  • ss: Second (00-59).
  • sss: Millisecond (000-999).
  • WWW: Abbreviated day of the week name in uppercase (SUN, MON, TUE, etc.).
  • www: Abbreviated day of the week name (Sun, Mon, Tue, etc.).

For more information, see the strftime specifiers documentation:

See also
https://manpages.debian.org/bullseye/manpages-dev/strftime.3.en.html
Parameters
format_strFormat string with custom parameters, e.g., "%H:%M:%S".
timestampTimestamp.
utc_offsetUTC offset in seconds (default is 0).
Returns
Returns a string in the format specified by the user.

Definition at line 370 of file time_formatting.hpp.

◆ to_string() [2/2]

const std::string time_shield::to_string ( const TimeZoneStruct & tz)
inline

Alias for time_zone_struct_to_string function.

Converts a TimeZoneStruct to a string representation.

Parameters
tzThe TimeZoneStruct to convert.
Returns
A string representation of the TimeZoneStruct.

Definition at line 66 of file time_zone_struct.hpp.

◆ to_time_zone()

template<class T = TimeZoneStruct>
const TimeZoneStruct time_shield::to_time_zone ( const tz_t & offset)
inline

Converts an integer to a time zone structure.

Template Parameters
TThe type of the time zone structure (default is TimeZoneStruct).
Parameters
offsetThe integer to convert.
Returns
A time zone structure of type T represented by the given integer.

The function assumes that the type T has members hour, min, and is_positive.

Definition at line 2206 of file time_conversions.hpp.

◆ to_time_zone_struct()

const TimeZoneStruct time_shield::to_time_zone_struct ( const tz_t & offset)
inline

Converts an integer to a TimeZoneStruct.

Parameters
offsetThe integer to convert.
Returns
A TimeZoneStruct represented by the given integer.

Definition at line 39 of file time_zone_struct.hpp.

◆ to_timestamp() [1/3]

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

Alias for tm_to_timestamp function.

Converts a std::tm structure to a timestamp.

This function converts a standard C++ std::tm structure to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 539 of file time_conversions.hpp.

◆ to_timestamp() [2/3]

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 487 of file time_conversions.hpp.

◆ to_timestamp() [3/3]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::to_timestamp ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0 )
inline

Converts a date and time 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
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 341 of file time_conversions.hpp.

◆ to_timestamp_ms() [1/3]

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

Alias for tm_to_timestamp_ms function.

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 709 of file time_conversions.hpp.

◆ to_timestamp_ms() [2/3]

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 664 of file time_conversions.hpp.

◆ to_timestamp_ms() [3/3]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::to_timestamp_ms ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T2 & ms = 0 )
inline

Converts a date and time to a timestamp in milliseconds.

This function converts a given date and time to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).

Template Parameters
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 591 of file time_conversions.hpp.

◆ to_ts() [1/3]

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

Alias for tm_to_timestamp function.

Converts a std::tm structure to a timestamp.

This function converts a standard C++ std::tm structure to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 546 of file time_conversions.hpp.

◆ to_ts() [2/3]

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 495 of file time_conversions.hpp.

◆ to_ts() [3/3]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::to_ts ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0 )
inline

Alias for to_timestamp function.

Converts a date and time 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
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 399 of file time_conversions.hpp.

◆ to_ts_ms() [1/3]

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

Alias for tm_to_timestamp_ms function.

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 716 of file time_conversions.hpp.

◆ to_ts_ms() [2/3]

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 672 of file time_conversions.hpp.

◆ to_ts_ms() [3/3]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::to_ts_ms ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T2 & ms = 0 )
inline

Alias for to_timestamp_ms function.

Converts a date and time to a timestamp in milliseconds.

This function converts a given date and time to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).

Template Parameters
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 605 of file time_conversions.hpp.

◆ to_tz()

const TimeZoneStruct time_shield::to_tz ( const tz_t & offset)
inline

Alias for to_time_zone_struct function.

Converts an integer to a TimeZoneStruct.

Parameters
offsetThe integer to convert.
Returns
A TimeZoneStruct represented by the given integer.

Definition at line 50 of file time_zone_struct.hpp.

◆ to_unix_min()

template<class T = int64_t>
const T time_shield::to_unix_min ( const ts_t & ts = ts())
constexpr

Alias for get_unix_min function.

Get UNIX minute.

This function returns the number of minutes elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is int64_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of minutes since the UNIX epoch.

Definition at line 1042 of file time_conversions.hpp.

◆ to_unix_year()

template<class T = year_t>
const T time_shield::to_unix_year ( const ts_t & ts)
constexprnoexcept

Alias for get_unix_year function.

Converts a UNIX timestamp to a year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
tsUNIX timestamp.
Returns
T Year corresponding to the given timestamp.

Definition at line 164 of file time_conversions.hpp.

◆ to_year()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T time_shield::to_year ( const ts_t & ts = ts())
inline

Alias for get_year function.

Get the year from the timestamp.

This function returns the year of the specified timestamp in seconds since the Unix epoch.

Template Parameters
TThe return type of the function (default is year_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Year of the specified timestamp.

Definition at line 1145 of file time_conversions.hpp.

◆ to_year_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T time_shield::to_year_ms ( const ts_ms_t & ts_ms = ts_ms())
inline

Alias for get_year_ms function.

Get the year from the timestamp in milliseconds.

This function returns the year of the specified timestamp in milliseconds since the Unix epoch.

Template Parameters
TThe return type of the function (default is year_t).
Parameters
ts_msTimestamp in milliseconds (default is current timestamp).
Returns
Year of the specified timestamp.

Definition at line 1173 of file time_conversions.hpp.

◆ try_get_month_number()

template<class T = Month>
const bool time_shield::try_get_month_number ( const std::string & month,
T & value )

Get the month number by name, with output parameter.

Template Parameters
TThe type for the month number, default is Month enum.
Parameters
monthThe name of the month as a string.
valueThe reference to store the month number if found.
Returns
True if the month name is valid, false otherwise.

Definition at line 71 of file time_parser.hpp.

◆ ts() [1/6]

const ts_t time_shield::ts ( )
inlinenoexcept

Get the current UTC timestamp in seconds.

Returns
ts_t Current UTC timestamp in seconds.

Definition at line 56 of file time_utils.hpp.

◆ ts() [2/6]

const ts_t time_shield::ts ( const char * str)
inline

Convert an ISO8601 C-style string to a timestamp (ts_t).

This function parses a string in ISO8601 format and converts it to a timestamp. If parsing fails, it returns 0.

Parameters
strThe ISO8601 C-style string.
Returns
The timestamp value. Returns 0 if parsing fails.

Definition at line 281 of file time_parser.hpp.

◆ ts() [3/6]

const ts_t time_shield::ts ( const std::string & str)
inline

Convert an ISO8601 string to a timestamp (ts_t).

This function parses a string in ISO8601 format and converts it to a timestamp. If parsing fails, it returns 0.

Parameters
strThe ISO8601 string.
Returns
The timestamp value. Returns 0 if parsing fails.

Definition at line 247 of file time_parser.hpp.

◆ ts() [4/6]

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

Alias for tm_to_timestamp function.

Converts a std::tm structure to a timestamp.

This function converts a standard C++ std::tm structure to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 553 of file time_conversions.hpp.

◆ ts() [5/6]

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 503 of file time_conversions.hpp.

◆ ts() [6/6]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::ts ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0 )
inline

Alias for to_timestamp function.

Converts a date and time 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
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 425 of file time_conversions.hpp.

◆ ts_from_tm()

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

Alias for tm_to_timestamp function.

Converts a std::tm structure to a timestamp.

This function converts a standard C++ std::tm structure to a timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Parameters
timeinfoPointer to a std::tm structure containing the date and time information.
Returns
Timestamp representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 567 of file time_conversions.hpp.

◆ ts_ms() [1/6]

const ts_ms_t time_shield::ts_ms ( )
inlinenoexcept

Get the current UTC timestamp in milliseconds.

Returns
ts_ms_t Current UTC timestamp in milliseconds.

Definition at line 84 of file time_utils.hpp.

◆ ts_ms() [2/6]

const ts_ms_t time_shield::ts_ms ( const char * str)
inline

Convert an ISO8601 C-style string to a millisecond timestamp (ts_ms_t).

This function parses a string in ISO8601 format and converts it to a millisecond timestamp. If parsing fails, it returns 0.

Parameters
strThe ISO8601 C-style string.
Returns
The parsed millisecond timestamp, or 0 if parsing fails.

Definition at line 292 of file time_parser.hpp.

◆ ts_ms() [3/6]

const ts_ms_t time_shield::ts_ms ( const std::string & str)
inline

Convert an ISO8601 string to a millisecond timestamp (ts_ms_t).

This function parses a string in ISO8601 format and converts it to a millisecond timestamp. If parsing fails, it returns 0.

Parameters
strThe ISO8601 string.
Returns
The parsed millisecond timestamp, or 0 if parsing fails.

Definition at line 258 of file time_parser.hpp.

◆ ts_ms() [4/6]

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

Alias for tm_to_timestamp_ms function.

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 723 of file time_conversions.hpp.

◆ ts_ms() [5/6]

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 680 of file time_conversions.hpp.

◆ ts_ms() [6/6]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::ts_ms ( const T1 & year,
const T2 & month,
const T2 & day,
const T2 & hour = 0,
const T2 & min = 0,
const T2 & sec = 0,
const T2 & ms = 0 )
inline

Alias for to_timestamp_ms function.

Converts a date and time to a timestamp in milliseconds.

This function converts a given date and time to a timestamp in milliseconds, which is the number of milliseconds since the Unix epoch (January 1, 1970).

Template Parameters
T1The type of the year parameter (default is int64_t).
T2The type of the other date and time parameters (default is int).
Parameters
yearThe year value.
monthThe month value.
dayThe day value.
hourThe hour value (default is 0).
minThe minute value (default is 0).
secThe second value (default is 0).
msThe millisecond value (default is 0).
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 619 of file time_conversions.hpp.

◆ ts_us()

const ts_us_t time_shield::ts_us ( )
inlinenoexcept

Get the current UTC timestamp in microseconds.

Returns
ts_us_t Current UTC timestamp in microseconds.

Definition at line 105 of file time_utils.hpp.

◆ tz_to_offset()

const tz_t time_shield::tz_to_offset ( const TimeZoneStruct & tz)
inline

Alias for time_zone_struct_to_offset function.

Converts a TimeZoneStruct to a single integer representation.

Parameters
tzThe TimeZoneStruct to convert.
Returns
An integer representing the TimeZoneStruct.

Definition at line 87 of file time_zone_struct.hpp.

◆ uday()

template<class T = uday_t>
const T time_shield::uday ( const ts_t & ts = ts())
constexprnoexcept

Alias for get_unix_day function.

Get UNIX day.

This function returns the number of days elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is unix_day_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of days since the UNIX epoch.

Definition at line 929 of file time_conversions.hpp.

◆ uday_ms()

template<class T = uday_t>
const T time_shield::uday_ms ( const ts_ms_t & t_ms = ts_ms())
constexprnoexcept

Alias for get_unix_day_ms function.

Get UNIX day from milliseconds timestamp.

This function returns the number of days elapsed since the UNIX epoch, given a timestamp in milliseconds.

Template Parameters
TThe return type of the function (default is unix_day_t).
Parameters
t_msTimestamp in milliseconds (default is current timestamp in milliseconds).
Returns
Number of days since the UNIX epoch.

Definition at line 986 of file time_conversions.hpp.

◆ uday_to_ts()

template<class T = ts_t>
const T time_shield::uday_to_ts ( const uday_t & unix_day)
constexprnoexcept

Alias for unix_day_to_timestamp function.

Convert a UNIX day to a timestamp.

This function converts a number of days since the UNIX epoch to a timestamp in seconds.

Template Parameters
TThe return type of the function (default is ts_t).
Parameters
unix_dayNumber of days since the beginning of UNIX time.
Returns
Timestamp at the beginning of the given day.

Definition at line 1014 of file time_conversions.hpp.

◆ umin()

template<class T = int64_t>
const T time_shield::umin ( const ts_t & ts = ts())
constexpr

Alias for get_unix_min function.

Get UNIX minute.

This function returns the number of minutes elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is int64_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of minutes since the UNIX epoch.

Definition at line 1049 of file time_conversions.hpp.

◆ unix_day()

template<class T = uday_t>
const T time_shield::unix_day ( const ts_t & ts = ts())
constexprnoexcept

Alias for get_unix_day function.

Get UNIX day.

This function returns the number of days elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is unix_day_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of days since the UNIX epoch.

Definition at line 922 of file time_conversions.hpp.

◆ unix_day_ms()

template<class T = uday_t>
const T time_shield::unix_day_ms ( const ts_ms_t & t_ms = ts_ms())
constexprnoexcept

Alias for get_unix_day_ms function.

Get UNIX day from milliseconds timestamp.

This function returns the number of days elapsed since the UNIX epoch, given a timestamp in milliseconds.

Template Parameters
TThe return type of the function (default is unix_day_t).
Parameters
t_msTimestamp in milliseconds (default is current timestamp in milliseconds).
Returns
Number of days since the UNIX epoch.

Definition at line 979 of file time_conversions.hpp.

◆ unix_day_to_timestamp()

template<class T = ts_t>
const T time_shield::unix_day_to_timestamp ( const uday_t & unix_day)
constexprnoexcept

Convert a UNIX day to a timestamp.

This function converts a number of days since the UNIX epoch to a timestamp in seconds.

Template Parameters
TThe return type of the function (default is ts_t).
Parameters
unix_dayNumber of days since the beginning of UNIX time.
Returns
Timestamp at the beginning of the given day.

Definition at line 1000 of file time_conversions.hpp.

◆ unix_day_to_ts()

template<class T = ts_t>
const T time_shield::unix_day_to_ts ( const uday_t & unix_day)
constexprnoexcept

Alias for unix_day_to_timestamp function.

Convert a UNIX day to a timestamp.

This function converts a number of days since the UNIX epoch to a timestamp in seconds.

Template Parameters
TThe return type of the function (default is ts_t).
Parameters
unix_dayNumber of days since the beginning of UNIX time.
Returns
Timestamp at the beginning of the given day.

Definition at line 1007 of file time_conversions.hpp.

◆ unix_min()

template<class T = int64_t>
const T time_shield::unix_min ( const ts_t & ts = ts())
constexpr

Alias for get_unix_min function.

Get UNIX minute.

This function returns the number of minutes elapsed since the UNIX epoch.

Template Parameters
TThe return type of the function (default is int64_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Number of minutes since the UNIX epoch.

Definition at line 1035 of file time_conversions.hpp.

◆ unix_year()

template<class T = year_t>
const T time_shield::unix_year ( const ts_t & ts)
constexprnoexcept

Alias for get_unix_year function.

Converts a UNIX timestamp to a year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
tsUNIX timestamp.
Returns
T Year corresponding to the given timestamp.

Definition at line 157 of file time_conversions.hpp.

◆ us_of_sec() [1/2]

template<class T = int>
const T time_shield::us_of_sec ( )
noexcept

Get the microsecond part of the current second.

Template Parameters
TType of the returned value (default is int).
Returns
T Microsecond part of the current second.

Definition at line 40 of file time_utils.hpp.

◆ us_of_sec() [2/2]

template<class T = int>
const T time_shield::us_of_sec ( const fts_t & ts)
constexprnoexcept

Get the microsecond part of the second from a floating-point timestamp.

Template Parameters
TType of the returned value (default is int).
Parameters
tsTimestamp in floating-point seconds.
Returns
T Microsecond part of the second.

Definition at line 34 of file time_conversions.hpp.

◆ week_begin()

const ts_t time_shield::week_begin ( const ts_t & ts = ts())
constexpr

Alias for start_of_week function.

Get the timestamp of the beginning of the week.

This function finds the timestamp of the beginning of the week, which corresponds to the start of Sunday.

Parameters
tsTimestamp (default: current timestamp).
Returns
Returns the timestamp of the beginning of the week.

Definition at line 2082 of file time_conversions.hpp.

◆ year()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T time_shield::year ( const ts_t & ts = ts())
inline

Alias for get_year function.

Get the year from the timestamp.

This function returns the year of the specified timestamp in seconds since the Unix epoch.

Template Parameters
TThe return type of the function (default is year_t).
Parameters
tsTimestamp in seconds (default is current timestamp).
Returns
Year of the specified timestamp.

Definition at line 1138 of file time_conversions.hpp.

◆ year_begin()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_begin ( const ts_t & ts = ts())
inline

Alias for start_of_year function.

Get the start of the year timestamp.

This function resets the days, months, hours, minutes, and seconds of the given timestamp to the beginning of the year.

Parameters
tsTimestamp.
Returns
Start of the year timestamp.

Definition at line 1248 of file time_conversions.hpp.

◆ year_begin_date()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_begin_date ( const T & year)
inline

Alias for start_of_year_date function.

Get the timestamp of the start of the year.

This function returns the timestamp at the start of the specified year.

Parameters
yearYear.
Returns
Timestamp of the start of the year.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1315 of file time_conversions.hpp.

◆ year_begin_date_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::year_begin_date_ms ( const T & year)
inline

Alias for start_of_year_date_ms function.

Get the timestamp in milliseconds of the start of the year.

This function returns the timestamp at the start of the specified year in milliseconds.

Parameters
yearYear.
Returns
Timestamp of the start of the year in milliseconds.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1343 of file time_conversions.hpp.

◆ year_begin_ms()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_begin_ms ( const ts_t & ts_ms = ts_ms())
inline

Alias for start_of_year_ms function.

Get the start of the year timestamp in milliseconds.

This function resets the days, months, hours, minutes, and seconds of the given timestamp to the beginning of the year.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of year timestamp in milliseconds.

Definition at line 1273 of file time_conversions.hpp.

◆ year_end()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_end ( const ts_t & ts = ts())
inline

Alias for end_of_year function.

Get the end-of-year timestamp.

This function finds the last timestamp of the current year.

Parameters
tsTimestamp.
Returns
End-of-year timestamp.

Definition at line 1416 of file time_conversions.hpp.

◆ year_end_ms()

TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::year_end_ms ( const ts_ms_t & ts_ms = ts_ms())
inline

Alias for end_of_year_ms function.

Get the timestamp in milliseconds of the end of the year.

This function finds the last timestamp of the current year in milliseconds.

Parameters
ts_msTimestamp in milliseconds.
Returns
End-of-year timestamp in milliseconds.

Definition at line 1435 of file time_conversions.hpp.

◆ year_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const T time_shield::year_ms ( const ts_ms_t & ts_ms = ts_ms())
inline

Alias for get_year_ms function.

Get the year from the timestamp in milliseconds.

This function returns the year of the specified timestamp in milliseconds since the Unix epoch.

Template Parameters
TThe return type of the function (default is year_t).
Parameters
ts_msTimestamp in milliseconds (default is current timestamp).
Returns
Year of the specified timestamp.

Definition at line 1166 of file time_conversions.hpp.

◆ year_start()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_start ( const ts_t & ts = ts())
inline

Alias for start_of_year function.

Get the start of the year timestamp.

This function resets the days, months, hours, minutes, and seconds of the given timestamp to the beginning of the year.

Parameters
tsTimestamp.
Returns
Start of the year timestamp.

Definition at line 1242 of file time_conversions.hpp.

◆ year_start_date()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_start_date ( const T & year)
inline

Alias for start_of_year_date function.

Get the timestamp of the start of the year.

This function returns the timestamp at the start of the specified year.

Parameters
yearYear.
Returns
Timestamp of the start of the year.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1308 of file time_conversions.hpp.

◆ year_start_date_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR const ts_ms_t time_shield::year_start_date_ms ( const T & year)
inline

Alias for start_of_year_date_ms function.

Get the timestamp in milliseconds of the start of the year.

This function returns the timestamp at the start of the specified year in milliseconds.

Parameters
yearYear.
Returns
Timestamp of the start of the year in milliseconds.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1336 of file time_conversions.hpp.

◆ year_start_ms()

TIME_SHIELD_CONSTEXPR const ts_t time_shield::year_start_ms ( const ts_t & ts_ms = ts_ms())
inline

Alias for start_of_year_ms function.

Get the start of the year timestamp in milliseconds.

This function resets the days, months, hours, minutes, and seconds of the given timestamp to the beginning of the year.

Parameters
ts_msTimestamp in milliseconds.
Returns
Start of year timestamp in milliseconds.

Definition at line 1267 of file time_conversions.hpp.

Variable Documentation

◆ AVG_DAYS_PER_YEAR

double time_shield::AVG_DAYS_PER_YEAR = 365.25
constexpr

Average days per year.

Definition at line 70 of file constants.hpp.

◆ AVG_SEC_PER_YEAR

int64_t time_shield::AVG_SEC_PER_YEAR = 31557600
constexpr

Average seconds per year (365.25 days)

Definition at line 33 of file constants.hpp.

◆ DAYS_PER_4_YEARS

int64_t time_shield::DAYS_PER_4_YEARS = 1461
constexpr

Days per 4 years.

Definition at line 53 of file constants.hpp.

◆ DAYS_PER_LEAP_YEAR

int64_t time_shield::DAYS_PER_LEAP_YEAR = 366
constexpr

Days per leap year.

Definition at line 51 of file constants.hpp.

◆ DAYS_PER_WEEK

int64_t time_shield::DAYS_PER_WEEK = 7
constexpr

Days per week.

Definition at line 50 of file constants.hpp.

◆ DAYS_PER_YEAR

int64_t time_shield::DAYS_PER_YEAR = 365
constexpr

Days per year.

Definition at line 52 of file constants.hpp.

◆ ERROR_TIMESTAMP

int64_t time_shield::ERROR_TIMESTAMP = 9223372036854770000LL
constexpr

Error timestamp value.

Definition at line 68 of file constants.hpp.

◆ ERROR_YEAR

int64_t time_shield::ERROR_YEAR = 9223372036854770000LL
constexpr

Error year value.

Definition at line 66 of file constants.hpp.

◆ HOURS_PER_DAY

int64_t time_shield::HOURS_PER_DAY = 24
constexpr

Hours per day.

Definition at line 49 of file constants.hpp.

◆ LEAP_YEAR_PER_100_YEAR

const int64_t time_shield::LEAP_YEAR_PER_100_YEAR = 24

Leap years per 100 years.

Definition at line 58 of file constants.hpp.

◆ LEAP_YEAR_PER_400_YEAR

const int64_t time_shield::LEAP_YEAR_PER_400_YEAR = 97

Leap years per 400 years.

Definition at line 59 of file constants.hpp.

◆ MAX_DAYS_PER_MONTH

const int64_t time_shield::MAX_DAYS_PER_MONTH = 31

Maximum days per month.

Definition at line 57 of file constants.hpp.

◆ MAX_MOON_MIN

int64_t time_shield::MAX_MOON_MIN = 42523
constexpr

Maximum lunar minutes.

Definition at line 46 of file constants.hpp.

◆ MAX_OADATE

double time_shield::MAX_OADATE = std::numeric_limits<double>::max()
constexpr

Maximum OLE automation date.

Definition at line 69 of file constants.hpp.

◆ MAX_SEC_PER_DAY

int64_t time_shield::MAX_SEC_PER_DAY = 86399
constexpr

Maximum seconds per day.

Definition at line 39 of file constants.hpp.

◆ MAX_TIMESTAMP

int64_t time_shield::MAX_TIMESTAMP = 9223371890843040000LL
constexpr

Maximum timestamp value.

Definition at line 67 of file constants.hpp.

◆ MAX_YEAR

int64_t time_shield::MAX_YEAR = 292277022000LL
constexpr

Maximum representable year.

Definition at line 64 of file constants.hpp.

◆ MIN_PER_DAY

int64_t time_shield::MIN_PER_DAY = 1440
constexpr

Minutes per day.

Definition at line 43 of file constants.hpp.

◆ MIN_PER_HOUR

int64_t time_shield::MIN_PER_HOUR = 60
constexpr

Minutes per hour.

Definition at line 42 of file constants.hpp.

◆ MIN_PER_MONTH

int64_t time_shield::MIN_PER_MONTH = 40320
constexpr

Minutes per month (28 days)

Definition at line 45 of file constants.hpp.

◆ MIN_PER_WEEK

int64_t time_shield::MIN_PER_WEEK = 10080
constexpr

Minutes per week.

Definition at line 44 of file constants.hpp.

◆ MIN_YEAR

int64_t time_shield::MIN_YEAR = -2967369602200LL
constexpr

Minimum representable year.

Definition at line 65 of file constants.hpp.

◆ MONTHS_PER_YEAR

const int64_t time_shield::MONTHS_PER_YEAR = 12

Months per year.

Definition at line 56 of file constants.hpp.

◆ MS_PER_DAY

int64_t time_shield::MS_PER_DAY = 86400000
constexpr

Milliseconds per day.

Definition at line 25 of file constants.hpp.

◆ MS_PER_HALF_HOUR

int64_t time_shield::MS_PER_HALF_HOUR = 1800000
constexpr

Milliseconds per half hour.

Definition at line 23 of file constants.hpp.

◆ MS_PER_HOUR

int64_t time_shield::MS_PER_HOUR = 3600000
constexpr

Milliseconds per hour.

Definition at line 24 of file constants.hpp.

◆ MS_PER_MIN

int64_t time_shield::MS_PER_MIN = 60000
constexpr

Milliseconds per minute.

Definition at line 22 of file constants.hpp.

◆ MS_PER_SEC

int64_t time_shield::MS_PER_SEC = 1000
constexpr

Milliseconds per second.

Definition at line 21 of file constants.hpp.

◆ NS_PER_MS

int64_t time_shield::NS_PER_MS = 1000000
constexpr

Nanoseconds per millisecond.

Definition at line 16 of file constants.hpp.

◆ NS_PER_SEC

int64_t time_shield::NS_PER_SEC = 1000000000
constexpr

Nanoseconds per second.

Definition at line 17 of file constants.hpp.

◆ NS_PER_US

int64_t time_shield::NS_PER_US = 1000
constexpr

Nanoseconds per microsecond.

Definition at line 15 of file constants.hpp.

◆ OLE_EPOCH

int64_t time_shield::OLE_EPOCH = 25569
constexpr

OLE automation date since UNIX epoch.

Definition at line 63 of file constants.hpp.

◆ SEC_PER_100_YEARS

int64_t time_shield::SEC_PER_100_YEARS = 3155673600
constexpr

Seconds per 100 years.

Definition at line 37 of file constants.hpp.

◆ SEC_PER_400_YEARS

int64_t time_shield::SEC_PER_400_YEARS = 12622780800
constexpr

Seconds per 400 years.

Definition at line 38 of file constants.hpp.

◆ SEC_PER_4_YEARS

int64_t time_shield::SEC_PER_4_YEARS = 126230400
constexpr

Seconds per 4 years.

Definition at line 35 of file constants.hpp.

◆ SEC_PER_DAY

int64_t time_shield::SEC_PER_DAY = 86400
constexpr

Seconds per day.

Definition at line 31 of file constants.hpp.

◆ SEC_PER_FIRST_100_YEARS

int64_t time_shield::SEC_PER_FIRST_100_YEARS = 3155760000
constexpr

Seconds per first 100 years.

Definition at line 36 of file constants.hpp.

◆ SEC_PER_HALF_HOUR

int64_t time_shield::SEC_PER_HALF_HOUR = 1800
constexpr

Seconds per half hour.

Definition at line 29 of file constants.hpp.

◆ SEC_PER_HOUR

int64_t time_shield::SEC_PER_HOUR = 3600
constexpr

Seconds per hour.

Definition at line 30 of file constants.hpp.

◆ SEC_PER_LEAP_YEAR

int64_t time_shield::SEC_PER_LEAP_YEAR = 31622400
constexpr

Seconds per leap year (366 days)

Definition at line 34 of file constants.hpp.

◆ SEC_PER_MIN

int64_t time_shield::SEC_PER_MIN = 60
constexpr

Seconds per minute.

Definition at line 28 of file constants.hpp.

◆ SEC_PER_YEAR

int64_t time_shield::SEC_PER_YEAR = 31536000
constexpr

Seconds per year (365 days)

Definition at line 32 of file constants.hpp.

◆ UNIX_EPOCH

int64_t time_shield::UNIX_EPOCH = 1970
constexpr

Start year of UNIX time.

Definition at line 62 of file constants.hpp.

◆ US_PER_SEC

int64_t time_shield::US_PER_SEC = 1000000
constexpr

Microseconds per second.

Definition at line 20 of file constants.hpp.