18 std::cout <<
"ns_of_sec: " <<
ns_of_sec(sec) <<
'\n';
19 std::cout <<
"us_of_sec: " <<
us_of_sec(sec) <<
'\n';
20 std::cout <<
"ms_of_sec: " <<
ms_of_sec(sec) <<
'\n';
23 std::cout <<
"sec_to_ms: " << ms <<
'\n';
24 std::cout <<
"ms_to_sec: " <<
ms_to_sec(ms) <<
'\n';
25 std::cout <<
"ms_to_fsec: " <<
ms_to_fsec(ms) <<
'\n';
27 std::cout <<
"min_to_sec(2.5): " <<
min_to_sec(2.5) <<
'\n';
28 std::cout <<
"sec_to_min(150): " <<
sec_to_min(150) <<
'\n';
29 std::cout <<
"hour_to_ms(1.5): " <<
hour_to_ms(1.5) <<
'\n';
30 std::cout <<
"hour24_to_12(15): " <<
hour24_to_12(15) <<
'\n';
32 ts_t ts_val =
to_ts(2024, Month::JUN, 21, 14, 30, 0);
36 std::cout <<
"to_dt_ms: " << dt.
year <<
'-' << dt.
mon <<
'-' << dt.
day <<
' '
37 << dt.
hour <<
':' << dt.
min <<
':' << dt.
sec <<
'.' << dt.
ms <<
'\n';
39 std::cout <<
"start_of_day: " <<
start_of_day(ts_val) <<
'\n';
40 std::cout <<
"end_of_day_ms: " <<
end_of_day_ms(ts_ms_val) <<
'\n';
41 std::cout <<
"next_day_ms: " <<
next_day_ms(ts_ms_val) <<
'\n';
43 std::cout <<
"day_of_year: " <<
day_of_year(ts_val) <<
'\n';
44 std::cout <<
"month_of_year: " <<
static_cast<int>(
month_of_year(ts_val)) <<
'\n';
45 std::cout <<
"day_of_month: " <<
day_of_month(ts_val) <<
'\n';
47 std::cout <<
"day_of_week_date(2024, JUN, 21): "
50 std::cout <<
"Press Enter to exit..." << std::endl;
56 std::cout <<
"time_conversions.hpp requires Windows." << std::endl;
Header for date and time structure and related functions.
constexpr const ts_ms_t 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 T1 min_to_sec(T2 ts) noexcept
Converts a timestamp from minutes to seconds.
constexpr const ts_ms_t 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.
TIME_SHIELD_CONSTEXPR const ts_t start_of_year_date(T year)
Get the timestamp of the start of the year.
constexpr T1 hour_to_ms(T2 ts) noexcept
Converts a timestamp from hours to milliseconds.
TIME_SHIELD_CONSTEXPR ts_t to_ts(year_t year, int month, int day)
Alias for to_timestamp.
TIME_SHIELD_CONSTEXPR const T month_of_year(ts_t ts) noexcept
Get the month of the year.
constexpr const T1 day_of_week_date(T2 year, T3 month, T4 day)
Get the day of the week.
constexpr const T ns_of_sec(fts_t ts) noexcept
Get the nanosecond part of the second from a floating-point timestamp.
T to_dt_ms(ts_ms_t ts)
Alias for to_date_time_ms function.
TIME_SHIELD_CONSTEXPR const T hour24_to_12(T hour) noexcept
Converts a 24-hour format hour to a 12-hour format.
constexpr T1 sec_to_min(T2 ts) noexcept
Converts a timestamp from seconds to minutes.
constexpr const T ms_of_sec(fts_t ts) noexcept
Get the millisecond part of the second from a floating-point timestamp.
TIME_SHIELD_CONSTEXPR const T day_of_month(ts_t ts=time_shield::ts())
Get the day of the month.
constexpr T1 sec_to_ms(T2 ts) noexcept
Converts a timestamp from seconds to milliseconds.
constexpr const ts_t start_of_day(ts_t ts=time_shield::ts()) noexcept
Get the start of the day timestamp.
constexpr ts_ms_t to_ts_ms(year_t year, int month, int day)
Alias for to_timestamp_ms.
const T day_of_year(ts_t ts=time_shield::ts())
Get the day of the year.
constexpr const fts_t ms_to_fsec(T ts_ms) noexcept
Converts a timestamp from milliseconds to floating-point seconds.
constexpr const T us_of_sec(fts_t ts) noexcept
Get the microsecond part of the second from a floating-point timestamp.
constexpr const T1 ms_to_sec(T2 ts_ms) noexcept
Converts a timestamp from milliseconds to seconds.
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.
Main namespace for the Time Shield library.
Structure to represent date and time.
int ms
Millisecond component of time (0-999)
int hour
Hour component of time (0-23)
int64_t year
Year component of the date.
int day
Day component of the date (1-31).
int min
Minute component of time (0-59)
int mon
Month component of the date (1-12).
int sec
Second component of time (0-59)
Header file for time conversion functions.