Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_conversion_aliases.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2#pragma once
3#ifndef _TIME_SHIELD_TIME_CONVERSIONS_ALIASES_HPP_INCLUDED
4#define _TIME_SHIELD_TIME_CONVERSIONS_ALIASES_HPP_INCLUDED
5
12
13#include <string>
14
15namespace time_shield {
16
19
22 template<class T = year_t>
23 constexpr T unix_year(ts_t ts) noexcept {
25 }
26
29 template<class T = year_t>
30 constexpr T to_unix_year(ts_t ts) noexcept {
32 }
33
36 template<class T = year_t>
37 constexpr T get_unix_year(ts_t ts) noexcept {
39 }
40
41//------------------------------------------------------------------------------
42
43
46 template<class T = uday_t>
47 constexpr T get_unixday(ts_t ts = time_shield::ts()) noexcept {
48 return days_since_epoch<T>(ts);
49 }
50
51
54 template<class T = uday_t>
55 constexpr T unix_day(ts_t ts = time_shield::ts()) noexcept {
56 return days_since_epoch<T>(ts);
57 }
58
59
62 template<class T = uday_t>
63 constexpr T unixday(ts_t ts = time_shield::ts()) noexcept {
64 return days_since_epoch<T>(ts);
65 }
66
67
70 template<class T = uday_t>
71 constexpr T uday(ts_t ts = time_shield::ts()) noexcept {
72 return days_since_epoch<T>(ts);
73 }
74
77 template<class T = uday_t>
78 constexpr T get_unix_day(ts_t ts = time_shield::ts()) noexcept {
79 return days_since_epoch<T>(ts);
80 }
81
82//------------------------------------------------------------------------------
83
84
87 template<class T = uday_t>
88 constexpr T get_unixday_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
89 return days_since_epoch_ms<T>(t_ms);
90 }
91
92
95 template<class T = uday_t>
96 constexpr T unix_day_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
97 return days_since_epoch_ms<T>(t_ms);
98 }
99
100
103 template<class T = uday_t>
104 constexpr T unixday_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
105 return days_since_epoch_ms<T>(t_ms);
106 }
107
108
111 template<class T = uday_t>
112 constexpr T uday_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
113 return days_since_epoch_ms<T>(t_ms);
114 }
115
118 template<class T = uday_t>
119 constexpr T get_unix_day_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
120 return days_since_epoch_ms<T>(t_ms);
121 }
122
123//------------------------------------------------------------------------------
124
127 template<class T = ts_t>
128 constexpr T unix_day_to_timestamp(uday_t unix_day) noexcept {
130 }
131
134 template<class T = ts_t>
135 constexpr T unixday_to_ts(uday_t unix_day) noexcept {
137 }
138
141 template<class T = ts_t>
142 constexpr T uday_to_ts(uday_t unix_day) noexcept {
144 }
145
148 template<class T = ts_t>
151 }
152
153//------------------------------------------------------------------------------
154
157 template<class T = ts_t>
160 }
161
164 template<class T = ts_t>
165 constexpr T unixday_to_ts_ms(uday_t unix_day) noexcept {
167 }
168
171 template<class T = ts_t>
172 constexpr T uday_to_ts_ms(uday_t unix_day) noexcept {
174 }
175
178 template<class T = ts_t>
181 }
182
183//------------------------------------------------------------------------------
184
187 template<class T = ts_t>
191
194 template<class T = ts_t>
198
201 template<class T = ts_t>
202 constexpr T next_day_unixday(uday_t unix_day) noexcept {
204 }
205
206//------------------------------------------------------------------------------
207
210 template<class T = ts_ms_t>
214
217 template<class T = ts_ms_t>
221
224 template<class T = ts_ms_t>
228
229//------------------------------------------------------------------------------
230
233 template<class T = int64_t>
235 return min_since_epoch<T>(ts);
236 }
237
240 template<class T = int64_t>
241 constexpr T unix_min(ts_t ts = time_shield::ts()) {
242 return min_since_epoch<T>(ts);
243 }
244
247 template<class T = int64_t>
249 return min_since_epoch<T>(ts);
250 }
251
254 template<class T = int64_t>
255 constexpr T umin(ts_t ts = time_shield::ts()) {
256 return min_since_epoch<T>(ts);
257 }
258
261 template<class T = int64_t>
263 return min_since_epoch<T>(ts);
264 }
265
266//------------------------------------------------------------------------------
267
271 template<class T>
272 TIME_SHIELD_CONSTEXPR inline auto dt_to_ts(const T& date_time)
273 -> decltype(dt_to_timestamp(date_time)) {
274 return dt_to_timestamp(date_time);
275 }
276
280 TIME_SHIELD_CONSTEXPR inline auto tm_to_ts(const std::tm* timeinfo)
281 -> decltype(tm_to_timestamp(timeinfo)) {
282 return tm_to_timestamp(timeinfo);
283 }
284
285//------------------------------------------------------------------------------
286
289 template<class T = int>
290 TIME_SHIELD_CONSTEXPR inline T h24_to_h12(T hour) noexcept {
291 return hour24_to_12(hour);
292 }
293
294//------------------------------------------------------------------------------
295
299 template<class T1, class T2 = ts_t>
300 T1 to_dt(T2 ts) {
301 return to_date_time(ts);
302 }
303
307 template<class T1, class T2 = ts_t>
309 return to_date_time(ts);
310 }
311
315 inline auto to_dt(ts_t ts)
316 -> decltype(to_date_time(ts)) {
317 return to_date_time(ts);
318 }
319
320//------------------------------------------------------------------------------
321
325 template<class T>
326 inline T to_dt_ms(ts_ms_t ts) {
327 return to_date_time_ms<T>(ts);
328 }
329
333 template<class T>
335 return to_date_time_ms<T>(ts);
336 }
337
345
346//------------------------------------------------------------------------------
347
348
363 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day) {
364 return to_timestamp(year, month, day);
365 }
366
367
383 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day, int hour) {
384 return to_timestamp(year, month, day, hour);
385 }
386
387
404 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day, int hour, int min) {
405 return to_timestamp(year, month, day, hour, min);
406 }
407
408
426 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day, int hour, int min, int sec) {
427 return to_timestamp(year, month, day, hour, min, sec);
428 }
429
430
445 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day) {
446 return to_timestamp(year, month, day);
447 }
448
449
465 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day, int hour) {
466 return to_timestamp(year, month, day, hour);
467 }
468
469
486 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day, int hour, int min) {
487 return to_timestamp(year, month, day, hour, min);
488 }
489
490
508 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day, int hour, int min, int sec) {
509 return to_timestamp(year, month, day, hour, min, sec);
510 }
511
512
527 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day) {
528 return to_timestamp(year, month, day);
529 }
530
531
547 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day, int hour) {
548 return to_timestamp(year, month, day, hour);
549 }
550
551
568 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day, int hour, int min) {
569 return to_timestamp(year, month, day, hour, min);
570 }
571
572
590 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day, int hour, int min, int sec) {
591 return to_timestamp(year, month, day, hour, min, sec);
592 }
593
594
609 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day) {
610 return to_timestamp(year, month, day);
611 }
612
613
629 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day, int hour) {
630 return to_timestamp(year, month, day, hour);
631 }
632
633
650 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day, int hour, int min) {
651 return to_timestamp(year, month, day, hour, min);
652 }
653
654
672 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day, int hour, int min, int sec) {
673 return to_timestamp(year, month, day, hour, min, sec);
674 }
675
676
691 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day) {
692 return to_timestamp(year, month, day);
693 }
694
695
711 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day, int hour) {
712 return to_timestamp(year, month, day, hour);
713 }
714
715
732 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day, int hour, int min) {
733 return to_timestamp(year, month, day, hour, min);
734 }
735
736
754 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day, int hour, int min, int sec) {
755 return to_timestamp(year, month, day, hour, min, sec);
756 }
757
758//------------------------------------------------------------------------------
759
763 template<class T>
764 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp(
765 const T& date_time) {
766 return dt_to_timestamp(date_time);
767 }
768
772 template<class T>
773 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(
774 const T& date_time) {
775 return dt_to_timestamp(date_time);
776 }
777
781 template<class T>
782 TIME_SHIELD_CONSTEXPR inline ts_t ts(
783 const T& date_time) {
784 return dt_to_timestamp(date_time);
785 }
786
790 template<class T>
791 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(
792 const T& date_time) {
793 return dt_to_timestamp(date_time);
794 }
795
796//------------------------------------------------------------------------------
797
800 TIME_SHIELD_CONSTEXPR inline ts_t ts(const std::tm* timeinfo) {
801 return tm_to_timestamp(timeinfo);
802 }
803
806 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(const std::tm* timeinfo) {
807 return tm_to_timestamp(timeinfo);
808 }
809
812 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(const std::tm* timeinfo) {
813 return tm_to_timestamp(timeinfo);
814 }
815
818 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(const std::tm* timeinfo) {
819 return tm_to_timestamp(timeinfo);
820 }
821
824 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(const std::tm* timeinfo) {
825 return tm_to_timestamp(timeinfo);
826 }
827
830 TIME_SHIELD_CONSTEXPR inline ts_t ts_from_tm(const std::tm* timeinfo) {
831 return tm_to_timestamp(timeinfo);
832 }
833
836 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp(const std::tm* timeinfo) {
837 return tm_to_timestamp(timeinfo);
838 }
839
840//------------------------------------------------------------------------------
841
855 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day) {
856 return to_timestamp_ms(year, month, day);
857 }
858
873 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour) {
874 return to_timestamp_ms(year, month, day, hour);
875 }
876
892 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour, int min) {
893 return to_timestamp_ms(year, month, day, hour, min);
894 }
895
912 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour, int min, int sec) {
913 return to_timestamp_ms(year, month, day, hour, min, sec);
914 }
915
933 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
934 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
935 }
936
950 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day) {
951 return to_timestamp_ms(year, month, day);
952 }
953
968 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour) {
969 return to_timestamp_ms(year, month, day, hour);
970 }
971
987 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour, int min) {
988 return to_timestamp_ms(year, month, day, hour, min);
989 }
990
1007 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour, int min, int sec) {
1008 return to_timestamp_ms(year, month, day, hour, min, sec);
1009 }
1010
1028 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
1029 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1030 }
1031
1045 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day) {
1046 return to_timestamp_ms(year, month, day);
1047 }
1048
1063 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour) {
1064 return to_timestamp_ms(year, month, day, hour);
1065 }
1066
1082 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour, int min) {
1083 return to_timestamp_ms(year, month, day, hour, min);
1084 }
1085
1102 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour, int min, int sec) {
1103 return to_timestamp_ms(year, month, day, hour, min, sec);
1104 }
1105
1123 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
1124 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1125 }
1126
1140 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day) {
1141 return to_timestamp_ms(year, month, day);
1142 }
1143
1158 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour) {
1159 return to_timestamp_ms(year, month, day, hour);
1160 }
1161
1177 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour, int min) {
1178 return to_timestamp_ms(year, month, day, hour, min);
1179 }
1180
1197 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour, int min, int sec) {
1198 return to_timestamp_ms(year, month, day, hour, min, sec);
1199 }
1200
1218 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
1219 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1220 }
1221
1235 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day) {
1236 return to_timestamp_ms(year, month, day);
1237 }
1238
1253 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour) {
1254 return to_timestamp_ms(year, month, day, hour);
1255 }
1256
1272 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour, int min) {
1273 return to_timestamp_ms(year, month, day, hour, min);
1274 }
1275
1292 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour, int min, int sec) {
1293 return to_timestamp_ms(year, month, day, hour, min, sec);
1294 }
1295
1313 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
1314 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1315 }
1316
1317//------------------------------------------------------------------------------
1318
1322 template<class T>
1323 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp_ms(
1324 const T& date_time) {
1325 return dt_to_timestamp_ms(date_time);
1326 }
1327
1331 template<class T>
1332 TIME_SHIELD_CONSTEXPR inline auto dt_to_ts_ms(const T& date_time)
1333 -> decltype(dt_to_timestamp_ms(date_time)) {
1334 return dt_to_timestamp_ms(date_time);
1335 }
1336
1340 template<class T>
1341 TIME_SHIELD_CONSTEXPR inline ts_t to_ts_ms(
1342 const T& date_time) {
1343 return dt_to_timestamp_ms(date_time);
1344 }
1345
1349 template<class T>
1350 TIME_SHIELD_CONSTEXPR inline ts_t ts_ms(
1351 const T& date_time) {
1352 return dt_to_timestamp_ms(date_time);
1353 }
1354
1358 template<class T>
1359 TIME_SHIELD_CONSTEXPR inline ts_t timestamp_ms(
1360 const T& date_time) {
1361 return dt_to_timestamp_ms(date_time);
1362 }
1363
1364//------------------------------------------------------------------------------
1365
1368 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp_ms(
1369 const std::tm *timeinfo) {
1370 return tm_to_timestamp_ms(timeinfo);
1371 }
1372
1375 TIME_SHIELD_CONSTEXPR inline auto tm_to_ts_ms(const std::tm *timeinfo)
1376 -> decltype(tm_to_timestamp_ms(timeinfo)) {
1377 return tm_to_timestamp_ms(timeinfo);
1378 }
1379
1382 TIME_SHIELD_CONSTEXPR inline ts_t to_ts_ms(
1383 const std::tm *timeinfo) {
1384 return tm_to_timestamp_ms(timeinfo);
1385 }
1386
1389 TIME_SHIELD_CONSTEXPR inline ts_t ts_ms(
1390 const std::tm *timeinfo) {
1391 return tm_to_timestamp_ms(timeinfo);
1392 }
1393
1396 TIME_SHIELD_CONSTEXPR inline ts_t timestamp_ms(
1397 const std::tm *timeinfo) {
1398 return tm_to_timestamp_ms(timeinfo);
1399 }
1400
1401//------------------------------------------------------------------------------
1402
1422 template<class T1 = year_t, class T2 = int, class T3 = int>
1423 constexpr fts_t to_fts(T1 year, T2 month, T2 day, T2 hour = 0, T2 min = 0, T2 sec = 0, T3 ms = 0) {
1424 return to_ftimestamp(year, month, day, hour, min, sec, ms);
1425 }
1426
1446 template<class T1 = year_t, class T2 = int, class T3 = int>
1447 constexpr fts_t fts(T1 year, T2 month, T2 day, T2 hour = 0, T2 min = 0, T2 sec = 0, T3 ms = 0) {
1448 return to_ftimestamp(year, month, day, hour, min, sec, ms);
1449 }
1450
1470 template<class T1 = year_t, class T2 = int, class T3 = int>
1471 constexpr fts_t ftimestamp(T1 year, T2 month, T2 day, T2 hour = 0, T2 min = 0, T2 sec = 0, T3 ms = 0) {
1472 return to_ftimestamp(year, month, day, hour, min, sec, ms);
1473 }
1474
1475//------------------------------------------------------------------------------
1476
1480 template<class T>
1481 constexpr fts_t to_ftimestamp(const T& date_time) {
1482 return dt_to_ftimestamp(date_time);
1483 }
1484
1488 template<class T>
1489 constexpr auto dt_to_fts(const T& date_time)
1490 -> decltype(dt_to_ftimestamp(date_time)) {
1491 return dt_to_ftimestamp(date_time);
1492 }
1493
1497 template<class T>
1498 constexpr fts_t to_fts(const T& date_time) {
1499 return dt_to_ftimestamp(date_time);
1500 }
1501
1505 template<class T>
1506 constexpr fts_t fts(const T& date_time) {
1507 return dt_to_ftimestamp(date_time);
1508 }
1509
1513 template<class T>
1514 constexpr fts_t ftimestamp(const T& date_time) {
1515 return dt_to_ftimestamp(date_time);
1516 }
1517
1518//------------------------------------------------------------------------------
1519
1523 TIME_SHIELD_CONSTEXPR inline fts_t to_ftimestamp(const std::tm* timeinfo) {
1524 return tm_to_ftimestamp(timeinfo);
1525 }
1526
1530 TIME_SHIELD_CONSTEXPR inline auto tm_to_fts(const std::tm* timeinfo)
1531 -> decltype(tm_to_ftimestamp(timeinfo)) {
1532 return tm_to_ftimestamp(timeinfo);
1533 }
1534
1538 TIME_SHIELD_CONSTEXPR inline fts_t to_fts(const std::tm* timeinfo) {
1539 return tm_to_ftimestamp(timeinfo);
1540 }
1541
1545 TIME_SHIELD_CONSTEXPR inline fts_t fts(const std::tm* timeinfo) {
1546 return tm_to_ftimestamp(timeinfo);
1547 }
1548
1552 TIME_SHIELD_CONSTEXPR inline fts_t ftimestamp(const std::tm* timeinfo) {
1553 return tm_to_ftimestamp(timeinfo);
1554 }
1555
1556//------------------------------------------------------------------------------
1557
1560 template<class T = int>
1561 constexpr T get_days(ts_t start, ts_t stop) noexcept {
1562 return days_between<T>(start, stop);
1563 }
1564
1567 template<class T = int>
1568 constexpr T days(ts_t start, ts_t stop) noexcept {
1569 return days_between<T>(start, stop);
1570 }
1571
1574 template<class T = int>
1575 constexpr T get_days_difference(ts_t start, ts_t stop) noexcept {
1576 return days_between<T>(start, stop);
1577 }
1578
1581 template<class T = int>
1582 constexpr T diff_in_days(ts_t start, ts_t stop) noexcept {
1583 return days_between<T>(start, stop);
1584 }
1585
1586//------------------------------------------------------------------------------
1587
1590 template<class T = year_t>
1591 TIME_SHIELD_CONSTEXPR inline T year(ts_t ts = time_shield::ts()) {
1592 return year_of<T>(ts);
1593 }
1594
1597 template<class T = year_t>
1598 TIME_SHIELD_CONSTEXPR inline T to_year(ts_t ts = time_shield::ts()) {
1599 return year_of<T>(ts);
1600 }
1601
1604 template<class T = year_t>
1605 TIME_SHIELD_CONSTEXPR inline T get_year(ts_t ts = time_shield::ts()) {
1606 return year_of<T>(ts);
1607 }
1608
1609//------------------------------------------------------------------------------
1610
1613 template<class T = year_t>
1614 TIME_SHIELD_CONSTEXPR inline T year_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1615 return year_of_ms<T>(ts_ms);
1616 }
1617
1620 template<class T = year_t>
1621 TIME_SHIELD_CONSTEXPR inline T to_year_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1622 return year_of_ms<T>(ts_ms);
1623 }
1624
1627 template<class T = year_t>
1628 TIME_SHIELD_CONSTEXPR inline T get_year_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1629 return year_of_ms<T>(ts_ms);
1630 }
1631
1632//------------------------------------------------------------------------------
1633
1636 TIME_SHIELD_CONSTEXPR inline ts_t year_start(ts_t ts = time_shield::ts()) {
1637 return start_of_year(ts);
1638 }
1639
1642 TIME_SHIELD_CONSTEXPR inline ts_t year_begin(ts_t ts = time_shield::ts()) {
1643 return start_of_year(ts);
1644 }
1645
1646//------------------------------------------------------------------------------
1647
1653
1659
1660//------------------------------------------------------------------------------
1661
1664 template<class T = year_t>
1665 TIME_SHIELD_CONSTEXPR inline ts_t year_start_date(T year) {
1666 return start_of_year_date(year);
1667 }
1668
1671 template<class T = year_t>
1672 TIME_SHIELD_CONSTEXPR inline ts_t year_begin_date(T year) {
1673 return start_of_year_date(year);
1674 }
1675
1676//------------------------------------------------------------------------------
1677
1680 template<class T = year_t>
1681 TIME_SHIELD_CONSTEXPR inline ts_ms_t year_start_date_ms(T year) {
1683 }
1684
1687 template<class T = year_t>
1688 TIME_SHIELD_CONSTEXPR inline ts_ms_t year_begin_date_ms(T year) {
1690 }
1691
1692//------------------------------------------------------------------------------
1693
1696 TIME_SHIELD_CONSTEXPR inline ts_t year_end(ts_t ts = time_shield::ts()) {
1697 return end_of_year(ts);
1698 }
1699
1700//------------------------------------------------------------------------------
1701
1704 TIME_SHIELD_CONSTEXPR inline ts_ms_t year_end_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1705 return end_of_year_ms(ts_ms);
1706 }
1707
1708//------------------------------------------------------------------------------
1709
1714 template<class T1 = int, class T2 = year_t, class T3 = int>
1715 constexpr T1 days_in_month(T2 year, T3 month) noexcept {
1716 return num_days_in_month(year, month);
1717 }
1718
1719//------------------------------------------------------------------------------
1720
1723 template<class T1 = int>
1724 constexpr T1 num_days_in_month(ts_t ts = time_shield::ts()) noexcept {
1725 return num_days_in_month_ts(ts);
1726 }
1727
1730 template<class T1 = int>
1731 constexpr T1 days_in_month(ts_t ts = time_shield::ts()) noexcept {
1732 return num_days_in_month_ts(ts);
1733 }
1734
1735//------------------------------------------------------------------------------
1736
1739 template<class T1 = int, class T2 = year_t>
1740 constexpr T1 days_in_year(T2 year) noexcept {
1741 return num_days_in_year(year);
1742 }
1743
1744//------------------------------------------------------------------------------
1745
1748 template<class T = int>
1750 return num_days_in_year_ts(ts);
1751 }
1752
1753//------------------------------------------------------------------------------
1754
1757 constexpr ts_t day_start(ts_t ts = time_shield::ts()) noexcept {
1758 return start_of_day(ts);
1759 }
1760
1761//------------------------------------------------------------------------------
1762
1765 template<class T = int>
1766 constexpr ts_t previous_day_start(ts_t ts = time_shield::ts(), T days = 1) noexcept {
1767 return start_of_prev_day(ts, days);
1768 }
1769
1770//------------------------------------------------------------------------------
1771
1775 return start_of_day(ms_to_sec(ts_ms));
1776 }
1777
1781 return start_of_day(ms_to_sec(ts_ms));
1782 }
1783
1784//------------------------------------------------------------------------------
1785
1789 return start_of_day_ms(ts_ms);
1790 }
1791
1792//------------------------------------------------------------------------------
1793
1796 template<class T = int>
1797 constexpr ts_t next_day_start(ts_t ts, T days = 1) noexcept {
1798 return start_of_next_day(ts, days);
1799 }
1800
1801//------------------------------------------------------------------------------
1802
1805 template<class T = int>
1806 constexpr ts_ms_t next_day_start_ms(ts_ms_t ts_ms, T days = 1) noexcept {
1808 }
1809
1810//------------------------------------------------------------------------------
1811
1814 constexpr ts_t day_end(ts_t ts = time_shield::ts()) noexcept {
1815 return end_of_day(ts);
1816 }
1817
1818//------------------------------------------------------------------------------
1819
1823 return end_of_day_sec(ts_ms);
1824 }
1825
1826//------------------------------------------------------------------------------
1827
1831 return end_of_day_ms(ts_ms);
1832 }
1833
1834//------------------------------------------------------------------------------
1835
1838 template<class T1 = Weekday>
1839 constexpr T1 day_of_week(year_t year, int month, int day) {
1840 return day_of_week_date<T1>(year, month, day);
1841 }
1842
1845 template<class T1 = Weekday>
1846 constexpr T1 day_of_week(year_t year, Month month, int day) {
1847 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1848 }
1849
1852 template<class T1 = Weekday>
1853 constexpr T1 get_weekday(year_t year, int month, int day) {
1854 return day_of_week_date<T1>(year, month, day);
1855 }
1856
1859 template<class T1 = Weekday>
1860 constexpr T1 get_weekday(year_t year, Month month, int day) {
1861 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1862 }
1863
1866 template<class T1 = Weekday>
1867 constexpr T1 weekday(year_t year, int month, int day) {
1868 return day_of_week_date<T1>(year, month, day);
1869 }
1870
1873 template<class T1 = Weekday>
1874 constexpr T1 weekday(year_t year, Month month, int day) {
1875 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1876 }
1877
1880 template<class T1 = Weekday>
1881 constexpr T1 dow(year_t year, int month, int day) {
1882 return day_of_week_date<T1>(year, month, day);
1883 }
1884
1887 template<class T1 = Weekday>
1888 constexpr T1 dow(year_t year, Month month, int day) {
1889 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1890 }
1891
1892//------------------------------------------------------------------------------
1893
1897 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1898 TIME_SHIELD_CONSTEXPR inline T1 get_weekday_from_date(const T2& date) {
1899 return weekday_of_date<T1>(date);
1900 }
1901
1905 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1906 constexpr T1 get_dow(const T2& date) {
1907 return weekday_of_date<T1>(date);
1908 }
1909
1913 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1914 constexpr T1 dow_from_date(const T2& date) {
1915 return weekday_of_date<T1>(date);
1916 }
1917
1921 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1922 constexpr T1 weekday_of(const T2& date) {
1923 return weekday_of_date<T1>(date);
1924 }
1925
1929 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1930 constexpr T1 day_of_week_dt(const T2& date) {
1931 return weekday_of_date<T1>(date);
1932 }
1933
1937 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1938 constexpr T1 day_of_week(const T2& date) {
1939 return weekday_of_date<T1>(date);
1940 }
1941
1945 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1946 constexpr T1 dow(const T2& date) {
1947 return weekday_of_date<T1>(date);
1948 }
1949
1953 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1954 constexpr T1 wd(const T2& date) {
1955 return weekday_of_date<T1>(date);
1956 }
1957
1958//------------------------------------------------------------------------------
1959
1960
1963 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1964 constexpr T day_of_week(U ts) noexcept {
1965 return weekday_of_ts<T>(ts);
1966 }
1967
1970 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1971 constexpr T dow_ts(U ts) noexcept {
1972 return weekday_of_ts<T>(ts);
1973 }
1974
1977 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1978 constexpr T get_dow_from_ts(U ts) noexcept {
1979 return weekday_of_ts<T>(ts);
1980 }
1981
1984 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1985 constexpr T get_weekday_from_ts(U ts) noexcept {
1986 return weekday_of_ts<T>(ts);
1987 }
1988
1989//------------------------------------------------------------------------------
1990
1993 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1994 constexpr T wd_ts(U ts) noexcept {
1995 return weekday_of_ts<T>(ts);
1996 }
1997
1998//------------------------------------------------------------------------------
1999
2002 template<class T = Weekday>
2004 return weekday_of_ts_ms<T>(ts_ms);
2005 }
2006
2009 template<class T = Weekday>
2010 constexpr T wd_ms(ts_ms_t ts_ms) {
2011 return weekday_of_ts_ms<T>(ts_ms);
2012 }
2013
2014//------------------------------------------------------------------------------
2015
2018 TIME_SHIELD_CONSTEXPR inline ts_t month_begin(ts_t ts = time_shield::ts()) {
2019 return start_of_month(ts);
2020 }
2021
2022//------------------------------------------------------------------------------
2023
2026 TIME_SHIELD_CONSTEXPR inline ts_t last_day_of_month(ts_t ts = time_shield::ts()) {
2027 return end_of_month(ts);
2028 }
2029
2030//------------------------------------------------------------------------------
2031
2034 TIME_SHIELD_CONSTEXPR inline ts_t final_sunday_of_month(ts_t ts = time_shield::ts()) {
2035 return last_sunday_of_month(ts);
2036 }
2037
2038//------------------------------------------------------------------------------
2039
2042 template<class T1 = int, class T2 = year_t, class T3 = int>
2043 TIME_SHIELD_CONSTEXPR inline T1 final_sunday_month_day(T2 year, T3 month) {
2044 return last_sunday_month_day(year, month);
2045 }
2046
2047//------------------------------------------------------------------------------
2048
2051 constexpr ts_t hour_begin(ts_t ts = time_shield::ts()) noexcept {
2052 return start_of_hour(ts);
2053 }
2054
2055//------------------------------------------------------------------------------
2056
2060 return start_of_hour_sec(ts_ms);
2061 }
2062
2063//------------------------------------------------------------------------------
2064
2068 return start_of_hour_ms(ts_ms);
2069 }
2070
2071//------------------------------------------------------------------------------
2072
2075 constexpr ts_t finish_of_hour(ts_t ts = time_shield::ts()) noexcept {
2076 return end_of_hour(ts);
2077 }
2078
2079//------------------------------------------------------------------------------
2080
2084 return end_of_hour_sec(ts_ms);
2085 }
2086
2087//------------------------------------------------------------------------------
2088
2092 return end_of_hour_ms(ts_ms);
2093 }
2094
2095//------------------------------------------------------------------------------
2096
2099 template<class T = int>
2100 constexpr T hour_in_day(ts_t ts = time_shield::ts()) noexcept {
2101 return hour_of_day(ts);
2102 }
2103
2104//------------------------------------------------------------------------------
2105
2109 return start_of_week(ts);
2110 }
2111
2112//------------------------------------------------------------------------------
2113
2117 return end_of_week(ts);
2118 }
2119
2120//------------------------------------------------------------------------------
2121
2125 return start_of_saturday(ts);
2126 }
2127
2128//------------------------------------------------------------------------------
2129
2132 constexpr ts_t min_begin(ts_t ts = time_shield::ts()) noexcept {
2133 return start_of_min(ts);
2134 }
2135
2136//------------------------------------------------------------------------------
2137
2140 constexpr ts_t finish_of_min(ts_t ts = time_shield::ts()) noexcept {
2141 return end_of_min(ts);
2142 }
2143
2144//------------------------------------------------------------------------------
2145
2148 TIME_SHIELD_CONSTEXPR inline bool workday(ts_t ts) noexcept {
2149 return is_workday(ts);
2150 }
2151
2154 TIME_SHIELD_CONSTEXPR inline bool workday_ms(ts_ms_t ts_ms) noexcept {
2155 return is_workday_ms(ts_ms);
2156 }
2157
2160 TIME_SHIELD_CONSTEXPR inline bool workday(year_t year, int month, int day) noexcept {
2161 return is_workday(year, month, day);
2162 }
2163
2166 template<class T>
2167 TIME_SHIELD_CONSTEXPR inline tz_t tz_offset(const T& tz) noexcept {
2168 return to_tz_offset(tz);
2169 }
2170
2173 TIME_SHIELD_CONSTEXPR inline tz_t offset_hm(int hour, int min = 0) noexcept {
2174 return tz_offset_hm(hour, min);
2175 }
2176
2179 TIME_SHIELD_CONSTEXPR inline bool valid_tz_offset(tz_t off) noexcept {
2180 return is_valid_tz_offset(off);
2181 }
2182
2184
2185}; // namespace time_shield
2186
2187#endif // _TIME_SHIELD_TIME_CONVERSIONS_ALIASES_HPP_INCLUDED
constexpr T start_of_day_from_unix_day_ms(uday_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
constexpr ts_t min_begin(ts_t ts=time_shield::ts()) noexcept
Alias for start_of_min function.
constexpr T unix_day(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
constexpr T1 days_in_month(T2 year, T3 month) noexcept
Alias for num_days_in_month function.
constexpr T get_unixday(ts_t ts=time_shield::ts()) noexcept
Alias for get_unix_day function.
constexpr T next_day_from_unix_day_ms(uday_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day_ms function.
TIME_SHIELD_CONSTEXPR T get_year(ts_t ts=time_shield::ts())
Alias for year_of function.
TIME_SHIELD_CONSTEXPR ts_ms_t year_begin_date_ms(T year)
Alias for start_of_year_date_ms function.
constexpr T get_unix_day(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
constexpr T next_day_unixday_ms(uday_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day_ms function.
ts_ms_t year_start_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for start_of_year_ms function.
constexpr T days_between(ts_t start, ts_t stop) noexcept
Get the number of days between two timestamps.
TIME_SHIELD_CONSTEXPR ts_ms_t get_ts_ms(year_t year, int month, int day)
Alias for to_timestamp_ms.
constexpr T get_days_difference(ts_t start, ts_t stop) noexcept
Alias for days_between function.
constexpr ts_ms_t day_start_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_day_ms function.
constexpr T years_since_epoch(ts_t ts) noexcept
Converts a UNIX timestamp to a year.
TIME_SHIELD_CONSTEXPR T1 get_weekday_from_date(const T2 &date)
Alias for weekday_of_date.
constexpr T unixday_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
constexpr T1 get_dow(const T2 &date)
Alias for weekday_of_date.
constexpr ts_t finish_of_min(ts_t ts=time_shield::ts()) noexcept
Alias for end_of_min function.
constexpr T1 dow_from_date(const T2 &date)
Alias for weekday_of_date.
constexpr T1 dow(year_t year, int month, int day)
Alias for day_of_week_date.
TIME_SHIELD_CONSTEXPR bool workday(ts_t ts) noexcept
Alias for is_workday(ts_t).
constexpr T start_of_next_day_from_unix_day(uday_t unix_day) noexcept
Converts a UNIX day to a timestamp representing the start of the next day in seconds.
constexpr T wd_ts(U ts) noexcept
Alias for weekday_of_ts.
constexpr T unixday_to_ts_ms(uday_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
constexpr ts_ms_t day_end_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_day_ms function.
constexpr T uday_to_ts_ms(uday_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
constexpr ts_ms_t finish_of_hour_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_hour_ms function.
constexpr T next_day_from_unix_day(uday_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day function.
TIME_SHIELD_CONSTEXPR bool is_valid_tz_offset(tz_t off) noexcept
Check if a numeric offset is within supported bounds.
constexpr ts_t previous_day_start(ts_t ts=time_shield::ts(), T days=1) noexcept
Alias for start_of_prev_day function.
TIME_SHIELD_CONSTEXPR ts_t year_begin_date(T year)
Alias for start_of_year_date function.
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 ts_ms_t year_start_date_ms(T year)
Alias for start_of_year_date_ms function.
TIME_SHIELD_CONSTEXPR T to_year(ts_t ts=time_shield::ts())
Alias for year_of function.
constexpr T get_unix_day_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
constexpr ts_t finish_of_week(ts_t ts=time_shield::ts())
Alias for end_of_week function.
constexpr T unix_day_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
constexpr T wd_ms(ts_ms_t ts_ms)
Alias for weekday_of_ts_ms function.
TIME_SHIELD_CONSTEXPR T hour24_to_12(T hour) noexcept
Converts a 24-hour format hour to a 12-hour format.
TIME_SHIELD_CONSTEXPR tz_t offset_hm(int hour, int min=0) noexcept
Alias for tz_offset_hm.
constexpr T to_unix_year(ts_t ts) noexcept
Alias for years_since_epoch function.
TIME_SHIELD_CONSTEXPR ts_t year_begin(ts_t ts=time_shield::ts())
Alias for start_of_year function.
constexpr T uday_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
constexpr T unix_year(ts_t ts) noexcept
Alias for years_since_epoch function.
constexpr T get_unix_min(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
TIME_SHIELD_CONSTEXPR auto tm_to_ts_ms(const std::tm *timeinfo) -> decltype(tm_to_timestamp_ms(timeinfo))
Alias for tm_to_timestamp_ms function.
constexpr T1 weekday_of(const T2 &date)
Alias for weekday_of_date.
constexpr T unix_day_to_timestamp(uday_t unix_day) noexcept
Alias for unix_day_to_ts function.
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 ts_ms_t hour_begin_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_hour_ms function.
TIME_SHIELD_CONSTEXPR ts_t to_ts(year_t year, int month, int day)
Alias for to_timestamp.
TIME_SHIELD_CONSTEXPR auto dt_to_ts_ms(const T &date_time) -> decltype(dt_to_timestamp_ms(date_time))
Alias for dt_to_timestamp_ms function.
constexpr ts_t saturday_begin(ts_t ts=time_shield::ts())
Alias for start_of_saturday function.
T to_dt_struct_ms(ts_ms_t ts)
Alias for to_date_time_ms function.
TIME_SHIELD_CONSTEXPR T get_year_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for year_of_ms function.
constexpr T1 get_weekday(year_t year, int month, int day)
Alias for day_of_week_date.
constexpr T diff_in_days(ts_t start, ts_t stop) noexcept
Alias for days_between function.
constexpr T dow_ts(U ts) noexcept
Alias for weekday_of_ts.
constexpr ts_t day_start(ts_t ts=time_shield::ts()) noexcept
Alias for start_of_day function.
constexpr ts_t finish_of_hour_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_hour_sec function.
constexpr T next_day_unix_day(uday_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day function.
constexpr fts_t to_fts(T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0, T3 ms=0)
Alias for to_ftimestamp.
TIME_SHIELD_CONSTEXPR ts_t final_sunday_of_month(ts_t ts=time_shield::ts())
Alias for last_sunday_of_month function.
constexpr T1 day_of_week(year_t year, int month, int day)
Alias for day_of_week_date.
constexpr T minutes_since_epoch(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
TIME_SHIELD_CONSTEXPR bool valid_tz_offset(tz_t off) noexcept
Alias for is_valid_tz_offset.
constexpr T1 wd(const T2 &date)
Alias for weekday_of_date.
T1 to_dt_struct(T2 ts)
Alias for to_date_time function.
TIME_SHIELD_CONSTEXPR ts_t year_start_date(T year)
Alias for start_of_year_date function.
TIME_SHIELD_CONSTEXPR ts_t get_ts(year_t year, int month, int day)
Alias for to_timestamp.
TIME_SHIELD_CONSTEXPR ts_t last_day_of_month(ts_t ts=time_shield::ts())
Alias for end_of_month function.
constexpr ts_t start_day_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_day_sec function.
TIME_SHIELD_CONSTEXPR ts_t year_start(ts_t ts=time_shield::ts())
Alias for start_of_year function.
constexpr T1 ms_to_sec(T2 ts_ms) noexcept
Converts a timestamp from milliseconds to seconds.
TIME_SHIELD_CONSTEXPR auto tm_to_fts(const std::tm *timeinfo) -> decltype(tm_to_ftimestamp(timeinfo))
Alias for tm_to_ftimestamp.
constexpr T start_of_day_from_unix_day(uday_t unix_day) noexcept
Alias for unix_day_to_ts function.
TIME_SHIELD_CONSTEXPR ts_t get_timestamp(year_t year, int month, int day)
Alias for to_timestamp.
T to_dt_ms(ts_ms_t ts)
Alias for to_date_time_ms function.
TIME_SHIELD_CONSTEXPR ts_ms_t year_end_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for end_of_year_ms function.
constexpr ts_t day_end(ts_t ts=time_shield::ts()) noexcept
Alias for end_of_day function.
TIME_SHIELD_CONSTEXPR tz_t tz_offset_hm(int hour, int min=0) noexcept
Build offset in seconds from hours/minutes.
constexpr ts_ms_t next_day_start_ms(ts_ms_t ts_ms, T days=1) noexcept
Alias for start_of_next_day_ms function.
constexpr T uday_to_ts(uday_t unix_day) noexcept
Alias for unix_day_to_ts function.
constexpr T next_day_unix_day_ms(uday_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day_ms function.
constexpr ts_t week_begin(ts_t ts=time_shield::ts())
Alias for start_of_week function.
TIME_SHIELD_CONSTEXPR tz_t tz_offset(const T &tz) noexcept
Alias for to_tz_offset.
constexpr T hour_in_day(ts_t ts=time_shield::ts()) noexcept
Alias for hour_of_day function.
constexpr T umin(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
constexpr T day_of_week_ms(ts_ms_t ts_ms)
Alias for weekday_of_ts_ms function.
constexpr T get_unix_year(ts_t ts) noexcept
Alias for years_since_epoch function.
TIME_SHIELD_CONSTEXPR T1 final_sunday_month_day(T2 year, T3 month)
Alias for last_sunday_month_day function.
TIME_SHIELD_CONSTEXPR ts_t ts_from_tm(const std::tm *timeinfo)
Alias for tm_to_timestamp.
constexpr T to_unix_min(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
constexpr T unix_min(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
constexpr T unix_day_to_timestamp_ms(uday_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
constexpr ts_t day_start_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_day_sec function.
constexpr T min_since_epoch(ts_t ts=time_shield::ts())
Get UNIX minute.
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 ts_ms_t to_ts_ms(year_t year, int month, int day)
Alias for to_timestamp_ms.
constexpr T unixday(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
constexpr T days(ts_t start, ts_t stop) noexcept
Alias for days_between function.
TIME_SHIELD_CONSTEXPR bool workday_ms(ts_ms_t ts_ms) noexcept
Alias for is_workday(ts_ms_t).
constexpr ts_t next_day_start(ts_t ts, T days=1) noexcept
Alias for start_of_next_day function.
constexpr T1 weekday(year_t year, int month, int day)
Alias for day_of_week_date.
constexpr T days_since_epoch_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Get UNIX day from milliseconds timestamp.
constexpr auto dt_to_fts(const T &date_time) -> decltype(dt_to_ftimestamp(date_time))
Alias for dt_to_ftimestamp.
ts_ms_t year_begin_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for start_of_year_ms function.
constexpr T get_days(ts_t start, ts_t stop) noexcept
Alias for days_between function.
constexpr T start_of_next_day_from_unix_day_ms(uday_t unix_day) noexcept
Converts a UNIX day to a timestamp representing the start of the next day in milliseconds.
TIME_SHIELD_CONSTEXPR ts_t year_end(ts_t ts=time_shield::ts())
Alias for end_of_year function.
constexpr T get_dow_from_ts(U ts) noexcept
Alias for weekday_of_ts.
constexpr ts_t hour_begin_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_hour_sec function.
TIME_SHIELD_CONSTEXPR auto dt_to_ts(const T &date_time) -> decltype(dt_to_timestamp(date_time))
Alias for dt_to_timestamp.
TIME_SHIELD_CONSTEXPR T year(ts_t ts=time_shield::ts())
Alias for year_of function.
constexpr T1 days_in_year(T2 year) noexcept
Alias for num_days_in_year function.
constexpr ts_t day_end_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_day_sec function.
T1 to_dt(T2 ts)
Alias for to_date_time function.
TIME_SHIELD_CONSTEXPR ts_t month_begin(ts_t ts=time_shield::ts())
Alias for start_of_month function.
TIME_SHIELD_CONSTEXPR T year_of(ts_t ts=time_shield::ts())
Get the year from the timestamp.
TIME_SHIELD_CONSTEXPR T h24_to_h12(T hour) noexcept
Alias for hour24_to_12 function.
constexpr T unix_day_to_ts(uday_t unix_day) noexcept
Converts a UNIX day to a timestamp in seconds.
TIME_SHIELD_CONSTEXPR tz_t to_tz_offset(const T &tz) noexcept
Convert time zone struct to offset in seconds.
constexpr T unix_day_to_ts_ms(uday_t unix_day) noexcept
Converts a UNIX day to a timestamp in milliseconds.
constexpr ts_t finish_of_hour(ts_t ts=time_shield::ts()) noexcept
Alias for end_of_hour function.
constexpr ts_t hour_begin(ts_t ts=time_shield::ts()) noexcept
Alias for start_of_hour function.
TIME_SHIELD_CONSTEXPR auto tm_to_ts(const std::tm *timeinfo) -> decltype(tm_to_timestamp(timeinfo))
Alias for tm_to_timestamp.
TIME_SHIELD_CONSTEXPR ts_ms_t get_timestamp_ms(year_t year, int month, int day)
Alias for to_timestamp_ms.
TIME_SHIELD_CONSTEXPR T to_year_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for year_of_ms function.
TIME_SHIELD_CONSTEXPR T year_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for year_of_ms function.
constexpr T1 day_of_week_dt(const T2 &date)
Alias for weekday_of_date.
constexpr T unixday_to_ts(uday_t unix_day) noexcept
Alias for unix_day_to_ts function.
constexpr T next_day_unixday(uday_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day function.
constexpr T get_unixday_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
constexpr T uday(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
constexpr T days_since_epoch(ts_t ts=time_shield::ts()) noexcept
Get UNIX day.
constexpr T days_in_year_ts(ts_t ts=time_shield::ts())
Alias for num_days_in_year_ts function.
bool is_workday(const std::string &str)
Parse ISO8601 string and check if it falls on a workday (seconds precision).
bool is_workday_ms(const std::string &str)
Parse ISO8601 string and check if it falls on a workday (milliseconds precision).
TIME_SHIELD_CONSTEXPR ts_t tm_to_timestamp(const std::tm *timeinfo)
Converts a std::tm structure to a timestamp.
constexpr ts_t end_of_hour(ts_t ts=time_shield::ts()) noexcept
Get the timestamp at the end of the hour.
TIME_SHIELD_CONSTEXPR fts_t dt_to_ftimestamp(const T &date_time)
Converts a date-time structure to a floating-point timestamp.
TIME_SHIELD_CONSTEXPR fts_t tm_to_ftimestamp(const std::tm *timeinfo)
Converts a std::tm structure to a floating-point timestamp.
constexpr ts_t start_of_saturday(ts_t ts=time_shield::ts())
Get the timestamp of the start of Saturday.
constexpr ts_t end_of_week(ts_t ts=time_shield::ts())
Get the timestamp of the end of the week.
TIME_SHIELD_CONSTEXPR ts_ms_t end_of_year_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Get the timestamp in milliseconds of the end of the year.
T to_date_time_ms(ts_ms_t ts)
Converts a timestamp in milliseconds to a date-time structure with milliseconds.
constexpr ts_t start_of_min(ts_t ts=time_shield::ts()) noexcept
Get the timestamp of the beginning of the minute.
TIME_SHIELD_CONSTEXPR T1 last_sunday_month_day(T2 year, T3 month)
Get the day of the last Sunday of the given month and year.
constexpr T weekday_of_ts_ms(ts_ms_t ts_ms)
Get the weekday from a timestamp in milliseconds.
constexpr ts_ms_t 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_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 ts_t end_of_year(ts_t ts=time_shield::ts())
Get the end-of-year timestamp.
constexpr ts_ms_t start_of_day_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Get the start of the day timestamp in milliseconds.
constexpr ts_t start_of_hour(ts_t ts=time_shield::ts()) noexcept
Get the timestamp at the start of the hour.
constexpr T hour_of_day(ts_t ts=time_shield::ts()) noexcept
Get hour of day. This function returns a value between 0 to 23.
TIME_SHIELD_CONSTEXPR ts_t start_of_year(ts_t ts) noexcept
Get the start of the year timestamp.
constexpr ts_t end_of_day(ts_t ts=time_shield::ts()) noexcept
Get the timestamp at the end of the day.
TIME_SHIELD_CONSTEXPR ts_t tm_to_timestamp_ms(const std::tm *timeinfo)
Converts a std::tm structure to a timestamp in milliseconds.
TIME_SHIELD_CONSTEXPR ts_t start_of_month(ts_t ts=time_shield::ts())
Get the timestamp at the start of the current month.
TIME_SHIELD_CONSTEXPR ts_t dt_to_timestamp(const T &date_time)
Converts a date-time structure to a timestamp.
constexpr ts_ms_t 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.
TIME_SHIELD_CONSTEXPR T1 num_days_in_month_ts(ts_t ts=time_shield::ts()) noexcept
Get the number of days in the month of the given timestamp.
TIME_SHIELD_CONSTEXPR fts_t 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.
TIME_SHIELD_CONSTEXPR ts_t end_of_month(ts_t ts=time_shield::ts())
Get the last timestamp of the current month.
constexpr ts_t start_of_day(ts_t ts=time_shield::ts()) noexcept
Get the start of the day timestamp.
TIME_SHIELD_CONSTEXPR ts_ms_t start_of_year_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Get the timestamp at the start of the year in milliseconds.
constexpr ts_t 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.
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.
constexpr ts_t end_of_min(ts_t ts=time_shield::ts()) noexcept
Get the timestamp of the end of the minute.
constexpr ts_ms_t 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.
TIME_SHIELD_CONSTEXPR ts_t last_sunday_of_month(ts_t ts=time_shield::ts())
Get the timestamp of the last Sunday of the current month.
TIME_SHIELD_CONSTEXPR ts_t start_of_year_date(T year)
Get the timestamp of the start of the year.
constexpr ts_t 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.
T1 to_date_time(T2 ts)
Converts a timestamp to a date-time structure.
TIME_SHIELD_CONSTEXPR ts_t dt_to_timestamp_ms(const T &date_time)
Converts a date-time structure to a timestamp in milliseconds.
constexpr ts_t start_of_week(ts_t ts=time_shield::ts())
Get the timestamp of the beginning of the week.
constexpr T weekday_of_ts(ts_t ts) noexcept
Get the second of the week day from a timestamp.
constexpr ts_t start_of_prev_day(ts_t ts=time_shield::ts(), T days=1) noexcept
Get timestamp of the start of the previous day.
constexpr T1 num_days_in_month(T2 year, T3 month) noexcept
Get the number of days in a month.
constexpr T get_weekday_from_ts(ts_t ts) noexcept
Alias for weekday_of_ts.
TIME_SHIELD_CONSTEXPR ts_ms_t start_of_year_date_ms(T year)
Get the timestamp in milliseconds of the start of the year.
constexpr ts_t 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_t 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.
TIME_SHIELD_CONSTEXPR ts_ms_t 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.
int64_t ts_t
Unix timestamp in seconds since 1970‑01‑01T00:00:00Z.
Definition types.hpp:48
int32_t tz_t
Time zone offset in minutes from UTC (e.g., +180 = UTC+3).
Definition types.hpp:60
int64_t ts_ms_t
Unix timestamp in milliseconds since epoch.
Definition types.hpp:49
int64_t uday_t
Unix day count since 1970‑01‑01 (days since epoch).
Definition types.hpp:42
double fts_t
Floating-point timestamp (fractional seconds since epoch).
Definition types.hpp:51
int64_t year_t
Year as an integer (e.g., 2024).
Definition types.hpp:41
ts_t ts() noexcept
Get the current UTC timestamp in seconds.
ts_t timestamp() noexcept
Get the current UTC timestamp in seconds.
fts_t ftimestamp() noexcept
Get the current UTC timestamp in floating-point seconds.
ts_ms_t ts_ms() noexcept
Get the current UTC timestamp in milliseconds.
ts_ms_t timestamp_ms() noexcept
Get the current UTC timestamp in milliseconds.
fts_t fts() noexcept
Get the current UTC timestamp in floating-point seconds.
Main namespace for the Time Shield library.