3#ifndef _TIME_SHIELD_DATE_CONVERSIONS_HPP_INCLUDED
4#define _TIME_SHIELD_DATE_CONVERSIONS_HPP_INCLUDED
27 template<
class T = year_t>
39 template<
class T = year_t>
47 template<
class T1 =
int,
class T2 = year_t>
59 template<
class T =
int>
74 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>
Configuration macros for the library.
Header file with time-related constants.
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.
constexpr T years_since_epoch(ts_t ts) noexcept
Converts a UNIX timestamp to a year.
TIME_SHIELD_CONSTEXPR ts_t ts(year_t year, int month, int day)
Alias for to_timestamp.
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 ts_ms_t ts_ms(year_t year, int month, int day)
Alias for to_timestamp_ms.
constexpr T1 ms_to_sec(T2 ts_ms) noexcept
Converts a timestamp from milliseconds to seconds.
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).
constexpr bool is_leap_year_date(T year) noexcept
Checks if the given year is a leap year.
TIME_SHIELD_CONSTEXPR bool is_leap_year_ts(ts_t ts)
Checks if the given year is a leap year.
Main namespace for the Time Shield library.
Type definitions for time-related units and formats.
Conversions related to UNIX-based time units and epochs.
Header file with time-related validation functions.