3#ifndef TIME_SHIELD_HEADER_CONVERSIONS_DATE_CONVERSIONS_HPP_INCLUDED
4#define TIME_SHIELD_HEADER_CONVERSIONS_DATE_CONVERSIONS_HPP_INCLUDED
24 template<
class T = year_t>
36 template<
class T = year_t>
44 template<
class T1 =
int,
class T2 = year_t>
56 template<
class T =
int>
71 template<
class T1 = Weekday,
class T2 = year_t,
class T3 =
int,
class T4 =
int>
80 R = 7000 + ( day + y + (y / 4) - (y / 100) + (y / 400) + (31 * m) /
MONTHS_PER_YEAR);
92 template<
class T1 = Weekday,
class T2>
100 template<
class T1 = Weekday,
class T2>
constexpr int64_t DAYS_PER_WEEK
Days per week.
const int64_t MONTHS_PER_YEAR
Months per year.
constexpr int64_t DAYS_PER_YEAR
Days per year.
constexpr int64_t DAYS_PER_LEAP_YEAR
Days per leap year.
constexpr int64_t UNIX_EPOCH
Start year of UNIX time.
TIME_SHIELD_CONSTEXPR T1 ms_to_sec(T2 ts_ms) noexcept
Converts a timestamp from milliseconds to seconds.
TIME_SHIELD_CONSTEXPR T1 num_days_in_year(T2 year) noexcept
Get the number of days in a year.
TIME_SHIELD_CONSTEXPR T1 day_of_week_date(T2 year, T3 month, T4 day)
Get the day of the week.
TIME_SHIELD_CONSTEXPR T1 weekday_of_date(const T2 &date)
Get the day of the week from a date structure.
TIME_SHIELD_CONSTEXPR T num_days_in_year_ts(ts_t ts=time_shield::ts())
Get the number of days in the current year.
TIME_SHIELD_CONSTEXPR T year_of_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Get the year from the timestamp in milliseconds.
TIME_SHIELD_CONSTEXPR T year(ts_t ts=time_shield::ts())
Alias for year_of function.
TIME_SHIELD_CONSTEXPR T year_of(ts_t ts=time_shield::ts())
Get the year from the timestamp.
TIME_SHIELD_CONSTEXPR T1 weekday_from_date(const T2 &date)
Alias for weekday_of_date.
int64_t ts_t
Unix timestamp in seconds since 1970‑01‑01T00:00:00Z.
int64_t ts_ms_t
Unix timestamp in milliseconds since epoch.
int64_t year_t
Year as an integer (e.g., 2024).
ts_t ts() noexcept
Get the current UTC timestamp in seconds.
ts_ms_t ts_ms() noexcept
Get the current UTC timestamp in milliseconds.
TIME_SHIELD_CONSTEXPR bool is_leap_year_ts(ts_t ts)
Checks if the given year is a leap year.
TIME_SHIELD_CONSTEXPR bool is_leap_year_date(T year) noexcept
Checks if the given year is a leap year.
Main namespace for the Time Shield library.
TIME_SHIELD_CONSTEXPR T years_since_epoch(ts_t ts) noexcept
Converts a UNIX timestamp to a year.
Conversions related to UNIX-based time units and epochs.