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

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

Topics

 Time structure conversions
 
 Time structure formatting
 

Classes

struct  time_shield::DateStruct
 Structure to represent a date. More...
 
struct  time_shield::DateTimeStruct
 Structure to represent date and time. More...
 
struct  time_shield::IsoWeekDateStruct
 Structure to represent an ISO week date. More...
 
struct  time_shield::TimeStruct
 Structure to represent time. More...
 
struct  time_shield::TimeZoneStruct
 Structure to represent time zone information. More...
 

Functions

const DateStruct time_shield::create_date_struct (int64_t year, int32_t mon=1, int32_t day=1)
 Creates a DateStruct instance.
 
template<class T1 = DateTimeStruct, class T2 = ts_t>
T1 time_shield::legacy::to_date_time (T2 ts)
 Converts a timestamp to a date-time structure.
 
const DateTimeStruct time_shield::create_date_time_struct (int64_t year, int mon=1, int day=1, int hour=0, int min=0, int sec=0, int ms=0)
 Creates a DateTimeStruct instance.
 
const IsoWeekDateStruct time_shield::create_iso_week_date_struct (int64_t year, int32_t week=1, int32_t weekday=1)
 Creates an IsoWeekDateStruct instance.
 
const TimeStruct time_shield::create_time_struct (int16_t hour, int16_t min, int16_t sec=0, int16_t ms=0)
 Creates a TimeStruct instance.
 
TimeZoneStruct time_shield::create_time_zone_struct (int hour, int min, bool is_positive=true)
 Creates a TimeZoneStruct instance.
 
template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time_zone_offset (const T &time_zone) noexcept
 Check if the time zone is valid.
 
template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time_zone (const T &time_zone)
 Alias for is_valid_time_zone_offset function.
 
template<class T = TimeZoneStruct>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_tz (const T &time_zone)
 Alias for is_valid_time_zone_offset function.
 
template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time (const T &time) noexcept
 Checks the correctness of the specified time.
 
template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date (const T &date) noexcept
 Checks the correctness of the specified date.
 
template<class T>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date_time (const T &date_time) noexcept
 Checks the correctness of a date and time.
 
DateStruct time_shield::create_date_struct (const long year, const int mon=1, const int day=1)
 Creates a DateStruct instance.
 
DateTimeStruct time_shield::create_date_time_struct (const long year, const int mon=1, const int day=1, const int hour=0, const int min=0, const int sec=0, const int ms=0)
 Creates a DateTimeStruct instance.
 
TimeStruct time_shield::create_time_struct (const int hour, const int min, const int sec=0, const int ms=0)
 Creates a TimeStruct instance.
 
template<class T1 = Weekday, class T2>
TIME_SHIELD_CONSTEXPR T1 time_shield::weekday_of_date (const T2 &date)
 Get the day of the week from a date structure.
 
template<class T1 = Weekday, class T2>
TIME_SHIELD_CONSTEXPR T1 time_shield::weekday_from_date (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = DateTimeStruct, class T2 = ts_t>
T1 time_shield::to_date_time (T2 ts)
 Converts a timestamp to a date-time structure.
 
template<class T>
time_shield::to_date_time_ms (ts_ms_t ts)
 Converts a timestamp in milliseconds to a date-time structure with milliseconds.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::dt_to_timestamp (const T &date_time)
 Converts a date-time structure to a timestamp.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::tm_to_timestamp (const std::tm *timeinfo)
 Converts a std::tm structure to a timestamp.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::to_timestamp_ms (T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0, T2 ms=0)
 Converts a date-time structure to a timestamp in milliseconds.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::dt_to_timestamp_ms (const T &date_time)
 Converts a date-time structure to a timestamp in milliseconds.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::tm_to_timestamp_ms (const std::tm *timeinfo)
 Converts a std::tm structure to a timestamp in milliseconds.
 
template<class T>
TIME_SHIELD_CONSTEXPR fts_t time_shield::dt_to_ftimestamp (const T &date_time)
 Converts a date-time structure to a floating-point timestamp.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_timestamp_unchecked (T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0) noexcept
 Converts a date and time to a timestamp without validation.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_timestamp (T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0)
 Converts a date and time to a timestamp.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR fts_t time_shield::to_ftimestamp (T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0, T3 ms=0)
 Converts a date and time to a floating-point timestamp.
 
TIME_SHIELD_CONSTEXPR fts_t time_shield::tm_to_ftimestamp (const std::tm *timeinfo)
 Converts a std::tm structure to a floating-point timestamp.
 
constexpr ts_t time_shield::start_of_day (ts_t ts=time_shield::ts()) noexcept
 Get the start of the day timestamp.
 
template<class T = int>
constexpr ts_t time_shield::start_of_prev_day (ts_t ts=time_shield::ts(), T days=1) noexcept
 Get timestamp of the start of the previous day.
 
constexpr ts_t time_shield::start_of_day_sec (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the start of the day timestamp in seconds.
 
constexpr ts_ms_t time_shield::start_of_day_ms (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the start of the day timestamp in milliseconds.
 
template<class T = int>
constexpr ts_t time_shield::start_of_next_day (ts_t ts, T days=1) noexcept
 Get the timestamp of the start of the day after a specified number of days.
 
template<class T = int>
constexpr ts_ms_t time_shield::start_of_next_day_ms (ts_ms_t ts_ms, T days=1) noexcept
 Get the timestamp of the start of the day after a specified number of days.
 
template<class T = int>
constexpr ts_t time_shield::next_day (ts_t ts, T days=1) noexcept
 Calculate the timestamp for a specified number of days in the future.
 
template<class T = int>
constexpr ts_ms_t time_shield::next_day_ms (ts_ms_t ts_ms, T days=1) noexcept
 Calculate the timestamp for a specified number of days in the future (milliseconds).
 
constexpr ts_t time_shield::end_of_day (ts_t ts=time_shield::ts()) noexcept
 Get the timestamp at the end of the day.
 
constexpr ts_t time_shield::end_of_day_sec (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the timestamp at the end of the day in seconds.
 
constexpr ts_ms_t time_shield::end_of_day_ms (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the timestamp at the end of the day in milliseconds.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR ts_t time_shield::start_of_year_date (T year)
 Get the timestamp of the start of the year.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::start_of_year_date_ms (T year)
 Get the timestamp in milliseconds of the start of the year.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::start_of_year (ts_t ts) noexcept
 Get the start of the year timestamp.
 
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::start_of_year_ms (ts_ms_t ts_ms=time_shield::ts_ms())
 Get the timestamp at the start of the year in milliseconds.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::end_of_year (ts_t ts=time_shield::ts())
 Get the end-of-year timestamp.
 
template<class T = year_t>
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::end_of_year_ms (ts_ms_t ts_ms=time_shield::ts_ms())
 Get the timestamp in milliseconds of the end of the year.
 
template<class T = int>
time_shield::day_of_year (ts_t ts=time_shield::ts())
 Get the day of the year.
 
template<class T = Month>
TIME_SHIELD_CONSTEXPR T time_shield::month_of_year (ts_t ts) noexcept
 Get the month of the year.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR T time_shield::day_of_month (ts_t ts=time_shield::ts())
 Get the day of the month.
 
template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR T1 time_shield::num_days_in_month (T2 year, T3 month) noexcept
 Get the number of days in a month.
 
template<class T1 = int>
TIME_SHIELD_CONSTEXPR T1 time_shield::num_days_in_month_ts (ts_t ts=time_shield::ts()) noexcept
 Get the number of days in the month of the given timestamp.
 
template<class T = Weekday>
constexpr T time_shield::weekday_of_ts (ts_t ts) noexcept
 Get the second of the week day from a timestamp.
 
template<class T = Weekday>
constexpr T time_shield::weekday_of_ts_ms (ts_ms_t ts_ms)
 Get the weekday from a timestamp in milliseconds.
 
template<class T = Weekday>
constexpr T time_shield::get_weekday_from_ts (ts_t ts) noexcept
 Alias for weekday_of_ts.
 
template<class T = Weekday>
constexpr T time_shield::get_weekday_from_ts_ms (ts_ms_t ts_ms)
 Alias for weekday_of_ts_ms.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::start_of_month (ts_t ts=time_shield::ts())
 Get the timestamp at the start of the current month.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::end_of_month (ts_t ts=time_shield::ts())
 Get the last timestamp of the current month.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::last_sunday_of_month (ts_t ts=time_shield::ts())
 Get the timestamp of the last Sunday of the current month.
 
template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR T1 time_shield::last_sunday_month_day (T2 year, T3 month)
 Get the day of the last Sunday of the given month and year.
 
constexpr ts_t time_shield::start_of_week (ts_t ts=time_shield::ts())
 Get the timestamp of the beginning of the week.
 
constexpr ts_t time_shield::end_of_week (ts_t ts=time_shield::ts())
 Get the timestamp of the end of the week.
 
constexpr ts_t time_shield::start_of_saturday (ts_t ts=time_shield::ts())
 Get the timestamp of the start of Saturday.
 
constexpr ts_t time_shield::start_of_hour (ts_t ts=time_shield::ts()) noexcept
 Get the timestamp at the start of the hour.
 
constexpr ts_t time_shield::start_of_hour_sec (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the timestamp at the start of the hour.
 
constexpr ts_ms_t time_shield::start_of_hour_ms (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the timestamp at the start of the hour. This function sets the minute and second to zero.
 
constexpr ts_t time_shield::end_of_hour (ts_t ts=time_shield::ts()) noexcept
 Get the timestamp at the end of the hour.
 
constexpr ts_t time_shield::end_of_hour_sec (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the timestamp at the end of the hour in seconds.
 
constexpr ts_ms_t time_shield::end_of_hour_ms (ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
 Get the timestamp at the end of the hour in milliseconds.
 
constexpr ts_t time_shield::start_of_min (ts_t ts=time_shield::ts()) noexcept
 Get the timestamp of the beginning of the minute.
 
constexpr ts_t time_shield::end_of_min (ts_t ts=time_shield::ts()) noexcept
 Get the timestamp of the end of the minute.
 
template<class T = int>
constexpr T time_shield::min_of_day (ts_t ts=time_shield::ts()) noexcept
 Get minute of day. This function returns a value between 0 to 1439 (minute of day).
 
template<class T = int>
constexpr T time_shield::hour_of_day (ts_t ts=time_shield::ts()) noexcept
 Get hour of day. This function returns a value between 0 to 23.
 
template<class T = int>
constexpr T time_shield::min_of_hour (ts_t ts=time_shield::ts()) noexcept
 Get minute of hour. This function returns a value between 0 to 59.
 
template<class T = int>
constexpr ts_t time_shield::start_of_period (T p, ts_t ts=time_shield::ts())
 Get the timestamp of the start of the period.
 
template<class T = int>
constexpr ts_t time_shield::end_of_period (T p, ts_t ts=time_shield::ts())
 Get the timestamp of the end of the period.
 
template<class T>
TIME_SHIELD_CONSTEXPR auto time_shield::dt_to_ts (const T &date_time) -> decltype(dt_to_timestamp(date_time))
 Alias for dt_to_timestamp.
 
TIME_SHIELD_CONSTEXPR auto time_shield::tm_to_ts (const std::tm *timeinfo) -> decltype(tm_to_timestamp(timeinfo))
 Alias for tm_to_timestamp.
 
template<class T1, class T2 = ts_t>
T1 time_shield::to_dt (T2 ts)
 Alias for to_date_time function.
 
template<class T1, class T2 = ts_t>
T1 time_shield::to_dt_struct (T2 ts)
 Alias for to_date_time function.
 
auto time_shield::to_dt (ts_t ts) -> decltype(to_date_time(ts))
 Alias for to_date_time function.
 
template<class T>
time_shield::to_dt_ms (ts_ms_t ts)
 Alias for to_date_time_ms function.
 
template<class T>
time_shield::to_dt_struct_ms (ts_ms_t ts)
 Alias for to_date_time_ms function.
 
auto time_shield::to_dt_ms (ts_ms_t ts_ms) -> decltype(to_date_time_ms< DateTimeStruct >(ts_ms))
 Alias for to_date_time_ms function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_timestamp (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_ts (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::ts (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::timestamp (const T &date_time)
 Alias for dt_to_timestamp function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_timestamp_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T>
TIME_SHIELD_CONSTEXPR auto time_shield::dt_to_ts_ms (const T &date_time) -> decltype(dt_to_timestamp_ms(date_time))
 Alias for dt_to_timestamp_ms function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_ts_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::ts_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T>
TIME_SHIELD_CONSTEXPR ts_t time_shield::timestamp_ms (const T &date_time)
 Alias for dt_to_timestamp_ms function.
 
template<class T>
constexpr fts_t time_shield::to_ftimestamp (const T &date_time)
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr auto time_shield::dt_to_fts (const T &date_time) -> decltype(dt_to_ftimestamp(date_time))
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr fts_t time_shield::to_fts (const T &date_time)
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr fts_t time_shield::fts (const T &date_time)
 Alias for dt_to_ftimestamp.
 
template<class T>
constexpr fts_t time_shield::ftimestamp (const T &date_time)
 Alias for dt_to_ftimestamp.
 
TIME_SHIELD_CONSTEXPR fts_t time_shield::to_ftimestamp (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
TIME_SHIELD_CONSTEXPR auto time_shield::tm_to_fts (const std::tm *timeinfo) -> decltype(tm_to_ftimestamp(timeinfo))
 Alias for tm_to_ftimestamp.
 
TIME_SHIELD_CONSTEXPR fts_t time_shield::to_fts (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
TIME_SHIELD_CONSTEXPR fts_t time_shield::fts (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
TIME_SHIELD_CONSTEXPR fts_t time_shield::ftimestamp (const std::tm *timeinfo)
 Alias for tm_to_ftimestamp.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
TIME_SHIELD_CONSTEXPR T1 time_shield::get_weekday_from_date (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::get_dow (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::dow_from_date (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::weekday_of (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::day_of_week_dt (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::day_of_week (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::dow (const T2 &date)
 Alias for weekday_of_date.
 
template<class T1 = Weekday, class T2, typename std::enable_if< std::is_class< T2 >::value, int >::type = 0>
constexpr T1 time_shield::wd (const T2 &date)
 Alias for weekday_of_date.
 

Detailed Description

Structures for representing and working with time and date components.

This group includes various structures used for representing time, date, and date-time combinations, along with related utility functions for creating and manipulating these structures.

Included Structures:

Example Usage:

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

Function Documentation

◆ create_date_struct() [1/2]

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

Creates a DateStruct instance.

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

Definition at line 37 of file date_struct.mqh.

◆ create_date_struct() [2/2]

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

Creates a DateStruct instance.

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

Definition at line 27 of file date_struct.hpp.

◆ create_date_time_struct() [1/2]

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

Creates a DateTimeStruct instance.

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

Definition at line 46 of file date_time_struct.mqh.

◆ create_date_time_struct() [2/2]

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

Creates a DateTimeStruct instance.

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

Definition at line 37 of file date_time_struct.hpp.

◆ create_iso_week_date_struct()

const IsoWeekDateStruct time_shield::create_iso_week_date_struct ( int64_t year,
int32_t week = 1,
int32_t weekday = 1 )
inline

Creates an IsoWeekDateStruct instance.

Parameters
yearISO week-numbering year component.
weekISO week number component.
weekdayISO weekday component (1=Monday .. 7=Sunday).
Returns
An IsoWeekDateStruct instance with the provided components.

Definition at line 29 of file iso_week_struct.hpp.

◆ create_time_struct() [1/2]

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

Creates a TimeStruct instance.

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

Definition at line 40 of file time_struct.mqh.

◆ create_time_struct() [2/2]

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

Creates a TimeStruct instance.

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

Definition at line 29 of file time_struct.hpp.

◆ create_time_zone_struct()

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

Creates a TimeZoneStruct instance.

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

Definition at line 34 of file time_zone_struct.hpp.

◆ day_of_month()

template<class T = int>
TIME_SHIELD_CONSTEXPR T time_shield::day_of_month ( ts_t ts = time_shield::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 931 of file date_time_conversions.hpp.

◆ day_of_week()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1938 of file time_conversion_aliases.hpp.

◆ day_of_week_dt()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1930 of file time_conversion_aliases.hpp.

◆ day_of_year()

template<class T = int>
T time_shield::day_of_year ( ts_t ts = time_shield::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 892 of file date_time_conversions.hpp.

◆ dow()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1946 of file time_conversion_aliases.hpp.

◆ dow_from_date()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1914 of file time_conversion_aliases.hpp.

◆ dt_to_ftimestamp()

template<class T>
TIME_SHIELD_CONSTEXPR 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 622 of file date_time_conversions.hpp.

◆ dt_to_fts()

template<class T>
auto time_shield::dt_to_fts ( const T & date_time) -> decltype(dt_to_ftimestamp(date_time))
constexpr

Alias for dt_to_ftimestamp.

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

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

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

Definition at line 1489 of file time_conversion_aliases.hpp.

◆ dt_to_timestamp()

template<class T>
TIME_SHIELD_CONSTEXPR 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 465 of file date_time_conversions.hpp.

◆ dt_to_timestamp_ms()

template<class T>
TIME_SHIELD_CONSTEXPR ts_ms_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 and 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 containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 547 of file date_time_conversions.hpp.

◆ dt_to_ts()

template<class T>
TIME_SHIELD_CONSTEXPR auto time_shield::dt_to_ts ( const T & date_time) -> decltype(dt_to_timestamp(date_time))
inline

Alias for dt_to_timestamp.

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 272 of file time_conversion_aliases.hpp.

◆ dt_to_ts_ms()

template<class T>
TIME_SHIELD_CONSTEXPR auto time_shield::dt_to_ts_ms ( const T & date_time) -> decltype(dt_to_timestamp_ms(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 and 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 containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1332 of file time_conversion_aliases.hpp.

◆ end_of_day()

ts_t time_shield::end_of_day ( ts_t ts = time_shield::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 747 of file date_time_conversions.hpp.

◆ end_of_day_ms()

ts_ms_t time_shield::end_of_day_ms ( ts_ms_t ts_ms = time_shield::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 767 of file date_time_conversions.hpp.

◆ end_of_day_sec()

ts_t time_shield::end_of_day_sec ( ts_ms_t ts_ms = time_shield::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 757 of file date_time_conversions.hpp.

◆ end_of_hour()

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

Get the timestamp at the end of the hour.

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

Definition at line 1130 of file date_time_conversions.hpp.

◆ end_of_hour_ms()

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

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

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

Definition at line 1144 of file date_time_conversions.hpp.

◆ end_of_hour_sec()

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

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

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

Definition at line 1137 of file date_time_conversions.hpp.

◆ end_of_min()

ts_t time_shield::end_of_min ( ts_t ts = time_shield::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 1158 of file date_time_conversions.hpp.

◆ end_of_month()

TIME_SHIELD_CONSTEXPR ts_t time_shield::end_of_month ( ts_t ts = time_shield::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 1037 of file date_time_conversions.hpp.

◆ end_of_period()

template<class T = int>
ts_t time_shield::end_of_period ( T p,
ts_t ts = time_shield::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 1206 of file date_time_conversions.hpp.

◆ end_of_week()

ts_t time_shield::end_of_week ( ts_t ts = time_shield::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 1083 of file date_time_conversions.hpp.

◆ end_of_year()

TIME_SHIELD_CONSTEXPR ts_t time_shield::end_of_year ( ts_t ts = time_shield::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 868 of file date_time_conversions.hpp.

◆ end_of_year_ms()

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

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

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

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

Definition at line 881 of file date_time_conversions.hpp.

◆ ftimestamp() [1/2]

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

Alias for tm_to_ftimestamp.

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

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

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

Definition at line 1552 of file time_conversion_aliases.hpp.

◆ ftimestamp() [2/2]

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

Alias for dt_to_ftimestamp.

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

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

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

Definition at line 1514 of file time_conversion_aliases.hpp.

◆ fts() [1/2]

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

Alias for tm_to_ftimestamp.

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

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

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

Definition at line 1545 of file time_conversion_aliases.hpp.

◆ fts() [2/2]

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

Alias for dt_to_ftimestamp.

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

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

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

Definition at line 1506 of file time_conversion_aliases.hpp.

◆ get_dow()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1906 of file time_conversion_aliases.hpp.

◆ get_weekday_from_date()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1898 of file time_conversion_aliases.hpp.

◆ get_weekday_from_ts()

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

Alias for weekday_of_ts.

Get the second of the week day from a timestamp.

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

Definition at line 1008 of file date_time_conversions.hpp.

◆ get_weekday_from_ts_ms()

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

Alias for weekday_of_ts_ms.

Get the weekday from a timestamp in milliseconds.

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

Definition at line 1015 of file date_time_conversions.hpp.

◆ hour_of_day()

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

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

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

Definition at line 1177 of file date_time_conversions.hpp.

◆ is_valid_date()

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

Checks the correctness of the specified date.

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

Definition at line 265 of file validation.hpp.

◆ is_valid_date_time()

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

Checks the correctness of a date and time.

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

Definition at line 301 of file validation.hpp.

◆ is_valid_time()

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

Checks the correctness of the specified time.

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

Definition at line 217 of file validation.hpp.

◆ is_valid_time_zone()

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

Alias for is_valid_time_zone_offset function.

Check if the time zone is valid.

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

Definition at line 174 of file validation.hpp.

◆ is_valid_time_zone_offset()

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

Check if the time zone is valid.

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

Definition at line 165 of file validation.hpp.

◆ is_valid_tz()

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

Alias for is_valid_time_zone_offset function.

Check if the time zone is valid.

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

Definition at line 183 of file validation.hpp.

◆ last_sunday_month_day()

template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR T1 time_shield::last_sunday_month_day ( T2 year,
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 1060 of file date_time_conversions.hpp.

◆ last_sunday_of_month()

TIME_SHIELD_CONSTEXPR ts_t time_shield::last_sunday_of_month ( ts_t ts = time_shield::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 1048 of file date_time_conversions.hpp.

◆ min_of_day()

template<class T = int>
T time_shield::min_of_day ( ts_t ts = time_shield::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 1167 of file date_time_conversions.hpp.

◆ min_of_hour()

template<class T = int>
T time_shield::min_of_hour ( ts_t ts = time_shield::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 1187 of file date_time_conversions.hpp.

◆ month_of_year()

template<class T = Month>
TIME_SHIELD_CONSTEXPR T time_shield::month_of_year ( 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 903 of file date_time_conversions.hpp.

◆ next_day()

template<class T = int>
ts_t time_shield::next_day ( ts_t ts,
T days = 1 )
constexprnoexcept

Calculate the timestamp for a specified number of days in the future.

Adds the given number of days to the provided timestamp, without adjusting to the start of the day.

Parameters
tsThe current timestamp in seconds.
daysThe number of days to add to the current timestamp (default is 1).
Returns
The timestamp in seconds after adding the specified number of days.

Definition at line 725 of file date_time_conversions.hpp.

◆ next_day_ms()

template<class T = int>
ts_ms_t time_shield::next_day_ms ( ts_ms_t ts_ms,
T days = 1 )
constexprnoexcept

Calculate the timestamp for a specified number of days in the future (milliseconds).

Adds the given number of days to the provided timestamp, without adjusting to the start of the day.

Parameters
ts_msThe current timestamp in milliseconds.
daysThe number of days to add to the current timestamp (default is 1).
Returns
The timestamp in milliseconds after adding the specified number of days.

Definition at line 737 of file date_time_conversions.hpp.

◆ num_days_in_month()

template<class T1 = int, class T2 = year_t, class T3 = int>
TIME_SHIELD_CONSTEXPR T1 time_shield::num_days_in_month ( T2 year,
T3 month )
noexcept

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 965 of file date_time_conversions.hpp.

◆ num_days_in_month_ts()

template<class T1 = int>
TIME_SHIELD_CONSTEXPR T1 time_shield::num_days_in_month_ts ( ts_t ts = time_shield::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 979 of file date_time_conversions.hpp.

◆ start_of_day()

ts_t time_shield::start_of_day ( ts_t ts = time_shield::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 653 of file date_time_conversions.hpp.

◆ start_of_day_ms()

ts_ms_t time_shield::start_of_day_ms ( ts_ms_t ts_ms = time_shield::ts_ms())
constexprnoexcept

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 687 of file date_time_conversions.hpp.

◆ start_of_day_sec()

ts_t time_shield::start_of_day_sec ( ts_ms_t ts_ms = time_shield::ts_ms())
constexprnoexcept

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 676 of file date_time_conversions.hpp.

◆ start_of_hour()

ts_t time_shield::start_of_hour ( ts_t ts = time_shield::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 1105 of file date_time_conversions.hpp.

◆ start_of_hour_ms()

ts_ms_t time_shield::start_of_hour_ms ( ts_ms_t ts_ms = time_shield::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 1123 of file date_time_conversions.hpp.

◆ start_of_hour_sec()

ts_t time_shield::start_of_hour_sec ( ts_ms_t ts_ms = time_shield::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 1115 of file date_time_conversions.hpp.

◆ start_of_min()

ts_t time_shield::start_of_min ( ts_t ts = time_shield::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 1151 of file date_time_conversions.hpp.

◆ start_of_month()

TIME_SHIELD_CONSTEXPR ts_t time_shield::start_of_month ( ts_t ts = time_shield::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 1026 of file date_time_conversions.hpp.

◆ start_of_next_day()

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

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

Calculates the timestamp for the beginning of the day after a specified number of days relative to the given timestamp.

Parameters
tsThe current timestamp in seconds.
daysThe number of days after the current day (default is 1).
Returns
The timestamp in seconds representing the beginning of the specified future day.

Definition at line 700 of file date_time_conversions.hpp.

◆ start_of_next_day_ms()

template<class T = int>
ts_ms_t time_shield::start_of_next_day_ms ( ts_ms_t ts_ms,
T days = 1 )
constexprnoexcept

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

Calculates the timestamp for the beginning of the day after a specified number of days relative to the given timestamp in milliseconds.

Parameters
ts_msThe current timestamp in milliseconds.
daysThe number of days after the current day (default is 1).
Returns
The timestamp in milliseconds representing the beginning of the specified future day.

Definition at line 713 of file date_time_conversions.hpp.

◆ start_of_period()

template<class T = int>
ts_t time_shield::start_of_period ( T p,
ts_t ts = time_shield::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 1197 of file date_time_conversions.hpp.

◆ start_of_prev_day()

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

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 665 of file date_time_conversions.hpp.

◆ start_of_saturday()

ts_t time_shield::start_of_saturday ( ts_t ts = time_shield::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 1094 of file date_time_conversions.hpp.

◆ start_of_week()

ts_t time_shield::start_of_week ( ts_t ts = time_shield::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 1072 of file date_time_conversions.hpp.

◆ start_of_year()

TIME_SHIELD_CONSTEXPR ts_t time_shield::start_of_year ( 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 800 of file date_time_conversions.hpp.

◆ start_of_year_date()

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

Get the timestamp of the start of the year.

Parameters
yearYear.
Returns
Timestamp at 00:00:00 of the first day of the year.

Definition at line 775 of file date_time_conversions.hpp.

◆ start_of_year_date_ms()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::start_of_year_date_ms ( 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 789 of file date_time_conversions.hpp.

◆ start_of_year_ms()

TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::start_of_year_ms ( ts_ms_t ts_ms = time_shield::ts_ms())
inline

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

Parameters
ts_msTimestamp in milliseconds.
Returns
Timestamp at 00:00:00.000 of the first day of the year.

Definition at line 858 of file date_time_conversions.hpp.

◆ timestamp()

template<class T>
TIME_SHIELD_CONSTEXPR 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 791 of file time_conversion_aliases.hpp.

◆ timestamp_ms()

template<class T>
TIME_SHIELD_CONSTEXPR 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 and 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 containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1359 of file time_conversion_aliases.hpp.

◆ tm_to_ftimestamp()

TIME_SHIELD_CONSTEXPR 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 641 of file date_time_conversions.hpp.

◆ tm_to_fts()

TIME_SHIELD_CONSTEXPR auto time_shield::tm_to_fts ( const std::tm * timeinfo) -> decltype(tm_to_ftimestamp(timeinfo))
inline

Alias for tm_to_ftimestamp.

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

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

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

Definition at line 1530 of file time_conversion_aliases.hpp.

◆ tm_to_timestamp()

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

Converts a std::tm structure to a timestamp.

This function converts a given 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.

Definition at line 485 of file date_time_conversions.hpp.

◆ tm_to_timestamp_ms()

TIME_SHIELD_CONSTEXPR 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 570 of file date_time_conversions.hpp.

◆ tm_to_ts()

TIME_SHIELD_CONSTEXPR auto time_shield::tm_to_ts ( const std::tm * timeinfo) -> decltype(tm_to_timestamp(timeinfo))
inline

Alias for tm_to_timestamp.

Converts a std::tm structure to a timestamp.

This function converts a given 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.

Definition at line 280 of file time_conversion_aliases.hpp.

◆ to_date_time() [1/2]

template<class T1 = DateTimeStruct, class T2 = ts_t>
T1 time_shield::legacy::to_date_time ( T2 ts)

Converts a timestamp to a date-time structure.

This function converts a timestamp (usually an integer representing seconds since epoch) to a custom date-time structure. The default type for the timestamp is int64_t.

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

Definition at line 47 of file date_time_conversions.hpp.

◆ to_date_time() [2/2]

template<class T1 = DateTimeStruct, class T2 = ts_t>
T1 time_shield::to_date_time ( T2 ts)

Converts a timestamp to a date-time structure.

This function converts a timestamp (usually an integer representing seconds since epoch) to a custom date-time structure. The default type for the timestamp is int64_t.

Note
Inspired by the algorithm described in: https://www.benjoffe.com/fast-date-64 This implementation is written from scratch (no code copied).
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 160 of file date_time_conversions.hpp.

◆ to_date_time_ms()

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

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

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

Definition at line 193 of file date_time_conversions.hpp.

◆ to_dt() [1/2]

template<class T1, class T2 = ts_t>
T1 time_shield::to_dt ( T2 ts)

Alias for to_date_time function.

Converts a timestamp to a date-time structure.

This function converts a timestamp (usually an integer representing seconds since epoch) to a custom date-time structure. The default type for the timestamp is int64_t.

Note
Inspired by the algorithm described in: https://www.benjoffe.com/fast-date-64 This implementation is written from scratch (no code copied).
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 300 of file time_conversion_aliases.hpp.

◆ to_dt() [2/2]

auto time_shield::to_dt ( ts_t ts) -> decltype(to_date_time(ts))
inline

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.

Note
Inspired by the algorithm described in: https://www.benjoffe.com/fast-date-64 This implementation is written from scratch (no code copied).
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 315 of file time_conversion_aliases.hpp.

◆ to_dt_ms() [1/2]

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

Alias for to_date_time_ms function.

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

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

Definition at line 326 of file time_conversion_aliases.hpp.

◆ to_dt_ms() [2/2]

auto time_shield::to_dt_ms ( ts_ms_t ts_ms) -> decltype(to_date_time_ms<DateTimeStruct>(ts_ms))
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 341 of file time_conversion_aliases.hpp.

◆ to_dt_struct()

template<class T1, class T2 = ts_t>
T1 time_shield::to_dt_struct ( T2 ts)

Alias for to_date_time function.

Converts a timestamp to a date-time structure.

This function converts a timestamp (usually an integer representing seconds since epoch) to a custom date-time structure. The default type for the timestamp is int64_t.

Note
Inspired by the algorithm described in: https://www.benjoffe.com/fast-date-64 This implementation is written from scratch (no code copied).
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 308 of file time_conversion_aliases.hpp.

◆ to_dt_struct_ms()

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

Alias for to_date_time_ms function.

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

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

Definition at line 334 of file time_conversion_aliases.hpp.

◆ to_ftimestamp() [1/3]

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

Alias for tm_to_ftimestamp.

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

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

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

Definition at line 1523 of file time_conversion_aliases.hpp.

◆ to_ftimestamp() [2/3]

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

Alias for dt_to_ftimestamp.

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

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

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

Definition at line 1481 of file time_conversion_aliases.hpp.

◆ to_ftimestamp() [3/3]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR fts_t time_shield::to_ftimestamp ( T1 year,
T2 month,
T2 day,
T2 hour = 0,
T2 min = 0,
T2 sec = 0,
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 594 of file date_time_conversions.hpp.

◆ to_fts() [1/2]

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

Alias for tm_to_ftimestamp.

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

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

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

Definition at line 1538 of file time_conversion_aliases.hpp.

◆ to_fts() [2/2]

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

Alias for dt_to_ftimestamp.

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

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

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

Definition at line 1498 of file time_conversion_aliases.hpp.

◆ to_timestamp() [1/2]

template<class T>
TIME_SHIELD_CONSTEXPR 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 764 of file time_conversion_aliases.hpp.

◆ to_timestamp() [2/2]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_timestamp ( T1 year,
T2 month,
T2 day,
T2 hour = 0,
T2 min = 0,
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).

If the day is ≥ 1970 and year ≤ 31, parameters are assumed to be in DD-MM-YYYY order and are automatically reordered.

Note
Inspired by the algorithm described in: https://www.benjoffe.com/fast-date-64 This implementation is written from scratch (no code copied).
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.
Aliases:
The following function names are provided as aliases:
  • ts(...)
  • get_ts(...)
  • get_timestamp(...)
  • timestamp(...)
  • to_ts(...)

These aliases are macro-generated and behave identically to to_timestamp.

See also
ts()
get_ts()
get_timestamp()
timestamp()
to_ts()

Definition at line 436 of file date_time_conversions.hpp.

◆ to_timestamp_ms() [1/2]

template<class T>
TIME_SHIELD_CONSTEXPR 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 and 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 containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1323 of file time_conversion_aliases.hpp.

◆ to_timestamp_ms() [2/2]

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

Converts a date-time structure 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 year_t).
T2The type of the month, day, hour, minute, and second 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 515 of file date_time_conversions.hpp.

◆ to_timestamp_unchecked()

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_timestamp_unchecked ( T1 year,
T2 month,
T2 day,
T2 hour = 0,
T2 min = 0,
T2 sec = 0 )
inlinenoexcept

Converts a date and time to a timestamp without validation.

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

If the day is ≥ 1970 and year ≤ 31, parameters are assumed to be in DD-MM-YYYY order and are automatically reordered.

Note
Inspired by the algorithm described in: https://www.benjoffe.com/fast-date-64 This implementation is written from scratch (no code copied).
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.

Definition at line 382 of file date_time_conversions.hpp.

◆ to_ts()

template<class T>
TIME_SHIELD_CONSTEXPR 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 773 of file time_conversion_aliases.hpp.

◆ to_ts_ms()

template<class T>
TIME_SHIELD_CONSTEXPR 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 and 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 containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1341 of file time_conversion_aliases.hpp.

◆ ts()

template<class T>
TIME_SHIELD_CONSTEXPR 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 782 of file time_conversion_aliases.hpp.

◆ ts_ms()

template<class T>
TIME_SHIELD_CONSTEXPR 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 and 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 containing year, month, day, hour, minute, second, and millisecond fields.
Returns
Timestamp in milliseconds representing the given date and time.
Exceptions
std::invalid_argumentif the date-time combination is invalid.

Definition at line 1350 of file time_conversion_aliases.hpp.

◆ wd()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1954 of file time_conversion_aliases.hpp.

◆ weekday_from_date()

template<class T1 = Weekday, class T2>
TIME_SHIELD_CONSTEXPR T1 time_shield::weekday_from_date ( const T2 & date)
inline

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 104 of file date_conversions.hpp.

◆ weekday_of()

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

Alias for weekday_of_date.

Get the day of the week from a date structure.

This function takes a date structure with fields 'year', 'mon', and 'day', and returns the day of the week (SUN = 0, MON = 1, ... SAT = 6).

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

Definition at line 1922 of file time_conversion_aliases.hpp.

◆ weekday_of_date()

template<class T1 = Weekday, class T2>
TIME_SHIELD_CONSTEXPR T1 time_shield::weekday_of_date ( const T2 & date)
inline

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 96 of file date_conversions.hpp.

◆ weekday_of_ts()

template<class T = Weekday>
T time_shield::weekday_of_ts ( ts_t ts)
constexprnoexcept

Get the second of the week day from a timestamp.

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

Definition at line 992 of file date_time_conversions.hpp.

◆ weekday_of_ts_ms()

template<class T = Weekday>
T time_shield::weekday_of_ts_ms ( 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 1001 of file date_time_conversions.hpp.