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

Functions

template<class T1 = DateTimeStruct, class T2 = ts_t>
T1 to_date_time (T2 ts)
 Converts a timestamp to a date-time structure.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t 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>
TIME_SHIELD_CONSTEXPR ts_t 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 T = year_t>
TIME_SHIELD_CONSTEXPR T years_since_epoch (ts_t ts) noexcept
 Converts a UNIX timestamp to a year.
 
template<class Year, class Month, class Day>
TIME_SHIELD_CONSTEXPR dse_t date_to_unix_day (Year year, Month month, Day day) noexcept
 Convert a calendar date to UNIX day count.
 

Function Documentation

◆ date_to_unix_day()

template<class Year, class Month, class Day>
TIME_SHIELD_CONSTEXPR dse_t time_shield::legacy::date_to_unix_day ( Year year,
Month month,
Day day )
inlinenoexcept

Convert a calendar date to UNIX day count.

Calculates the number of days since the UNIX epoch (January 1, 1970) for the provided calendar date components.

Template Parameters
YearType of the year component.
MonthType of the month component.
DayType of the day component.
Parameters
yearYear component of the date.
monthMonth component of the date.
dayDay component of the date.
Returns
Number of days since the UNIX epoch.

Definition at line 89 of file unix_time_conversions.hpp.

◆ to_timestamp()

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t time_shield::legacy::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.

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

◆ to_timestamp_unchecked()

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR ts_t time_shield::legacy::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.

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

◆ years_since_epoch()

template<class T = year_t>
TIME_SHIELD_CONSTEXPR T time_shield::legacy::years_since_epoch ( ts_t ts)
noexcept

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 28 of file unix_time_conversions.hpp.