Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
date_time_conversions.hpp File Reference

Conversions involving DateTimeStruct and day boundary helpers. More...

Go to the source code of this file.

Namespaces

namespace  time_shield
 Main namespace for the Time Shield library.
 

Functions

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

Detailed Description

Conversions involving DateTimeStruct and day boundary helpers.

Definition in file date_time_conversions.hpp.