Time Shield Library 2.0.0
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_HEADER_CONVERSIONS_TIME_CONVERSION_ALIASES_HPP_INCLUDED
4#define TIME_SHIELD_HEADER_CONVERSIONS_TIME_CONVERSION_ALIASES_HPP_INCLUDED
5
12
13#include <string>
14
15namespace time_shield {
16
19
22 template<class T = year_t>
23 TIME_SHIELD_CONSTEXPR T unix_year(ts_t ts) noexcept {
25 }
26
29 template<class T = year_t>
30 TIME_SHIELD_CONSTEXPR T to_unix_year(ts_t ts) noexcept {
32 }
33
34//------------------------------------------------------------------------------
35
36
40 template<class T = dse_t>
41 TIME_SHIELD_CONSTEXPR T get_unixday(ts_t ts = time_shield::ts()) noexcept {
42 return days_since_epoch<T>(ts);
43 }
44
45
49 template<class T = dse_t>
50 TIME_SHIELD_CONSTEXPR T unix_day(ts_t ts = time_shield::ts()) noexcept {
51 return days_since_epoch<T>(ts);
52 }
53
54
58 template<class T = dse_t>
59 TIME_SHIELD_CONSTEXPR T dse(ts_t ts = time_shield::ts()) noexcept {
60 return days_since_epoch<T>(ts);
61 }
62
63
67 template<class T = dse_t>
68 TIME_SHIELD_CONSTEXPR T unixday(ts_t ts = time_shield::ts()) noexcept {
69 return days_since_epoch<T>(ts);
70 }
71
72
76 template<class T = dse_t>
77 TIME_SHIELD_CONSTEXPR T uday(ts_t ts = time_shield::ts()) noexcept {
78 return days_since_epoch<T>(ts);
79 }
80
81//------------------------------------------------------------------------------
82
83
87 template<class T = dse_t>
88 TIME_SHIELD_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
96 template<class T = dse_t>
97 TIME_SHIELD_CONSTEXPR T unix_day_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
98 return days_since_epoch_ms<T>(t_ms);
99 }
100
101
105 template<class T = dse_t>
106 TIME_SHIELD_CONSTEXPR T dse_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
107 return days_since_epoch_ms<T>(t_ms);
108 }
109
110
114 template<class T = dse_t>
115 TIME_SHIELD_CONSTEXPR T unixday_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
116 return days_since_epoch_ms<T>(t_ms);
117 }
118
119
123 template<class T = dse_t>
124 TIME_SHIELD_CONSTEXPR T uday_ms(ts_ms_t t_ms = time_shield::ts_ms()) noexcept {
125 return days_since_epoch_ms<T>(t_ms);
126 }
127
128//------------------------------------------------------------------------------
129
132 template<class T = ts_t>
133 TIME_SHIELD_CONSTEXPR T unixday_to_ts(dse_t unix_day) noexcept {
135 }
136
139 template<class T = ts_t>
140 TIME_SHIELD_CONSTEXPR T dse_to_ts(dse_t unix_day) noexcept {
142 }
143
146 template<class T = ts_t>
147 TIME_SHIELD_CONSTEXPR T uday_to_ts(dse_t unix_day) noexcept {
149 }
150
153 template<class T = ts_t>
154 TIME_SHIELD_CONSTEXPR T start_of_day_from_unix_day(dse_t unix_day) noexcept {
156 }
157
158//------------------------------------------------------------------------------
159
162 template<class T = ts_t>
163 TIME_SHIELD_CONSTEXPR T unixday_to_ts_ms(dse_t unix_day) noexcept {
165 }
166
169 template<class T = ts_ms_t>
170 TIME_SHIELD_CONSTEXPR T dse_to_ts_ms(dse_t unix_day) noexcept {
172 }
173
176 template<class T = ts_t>
177 TIME_SHIELD_CONSTEXPR T uday_to_ts_ms(dse_t unix_day) noexcept {
179 }
180
183 template<class T = ts_t>
184 TIME_SHIELD_CONSTEXPR T start_of_day_from_unix_day_ms(dse_t unix_day) noexcept {
186 }
187
188//------------------------------------------------------------------------------
189
192 template<class T = ts_t>
193 TIME_SHIELD_CONSTEXPR T next_day_from_unix_day(dse_t unix_day) noexcept {
195 }
196
197//------------------------------------------------------------------------------
198
201 template<class T = ts_ms_t>
202 TIME_SHIELD_CONSTEXPR T next_day_from_unix_day_ms(dse_t unix_day) noexcept {
204 }
205
206//------------------------------------------------------------------------------
207
210 template<class T = int64_t>
211 TIME_SHIELD_CONSTEXPR T minutes_since_epoch(ts_t ts = time_shield::ts()) {
212 return min_since_epoch<T>(ts);
213 }
214
217 template<class T = int64_t>
218 TIME_SHIELD_CONSTEXPR T unix_min(ts_t ts = time_shield::ts()) {
219 return min_since_epoch<T>(ts);
220 }
221
224 template<class T = int64_t>
225 TIME_SHIELD_CONSTEXPR T to_unix_min(ts_t ts = time_shield::ts()) {
226 return min_since_epoch<T>(ts);
227 }
228
231 template<class T = int64_t>
232 TIME_SHIELD_CONSTEXPR T umin(ts_t ts = time_shield::ts()) {
233 return min_since_epoch<T>(ts);
234 }
235
236//------------------------------------------------------------------------------
237
241 template<class T>
242 TIME_SHIELD_CONSTEXPR inline auto dt_to_ts(const T& date_time)
243 -> decltype(dt_to_timestamp(date_time)) {
244 return dt_to_timestamp(date_time);
245 }
246
250 TIME_SHIELD_CONSTEXPR inline auto tm_to_ts(const std::tm* timeinfo)
251 -> decltype(tm_to_timestamp(timeinfo)) {
252 return tm_to_timestamp(timeinfo);
253 }
254
255//------------------------------------------------------------------------------
256
259 template<class T = int>
260 TIME_SHIELD_CONSTEXPR inline T h24_to_h12(T hour) noexcept {
261 return hour24_to_12(hour);
262 }
263
264//------------------------------------------------------------------------------
265
269 template<class T1, class T2 = ts_t>
270 T1 to_dt(T2 ts) {
271 return to_date_time(ts);
272 }
273
277 template<class T1, class T2 = ts_t>
279 return to_date_time(ts);
280 }
281
285 inline auto to_dt(ts_t ts)
286 -> decltype(to_date_time(ts)) {
287 return to_date_time(ts);
288 }
289
290//------------------------------------------------------------------------------
291
296 template<class T>
297 inline T to_dt_ms(ts_ms_t ts) {
298 return to_date_time_ms<T>(ts);
299 }
300
305 template<class T>
307 return to_date_time_ms<T>(ts);
308 }
309
318
319//------------------------------------------------------------------------------
320
321
336 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day) {
337 return to_timestamp(year, month, day);
338 }
339
340
356 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day, int hour) {
357 return to_timestamp(year, month, day, hour);
358 }
359
360
377 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day, int hour, int min) {
378 return to_timestamp(year, month, day, hour, min);
379 }
380
381
399 TIME_SHIELD_CONSTEXPR inline ts_t ts(year_t year, int month, int day, int hour, int min, int sec) {
400 return to_timestamp(year, month, day, hour, min, sec);
401 }
402
403
418 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day) {
419 return to_timestamp(year, month, day);
420 }
421
422
438 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day, int hour) {
439 return to_timestamp(year, month, day, hour);
440 }
441
442
459 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day, int hour, int min) {
460 return to_timestamp(year, month, day, hour, min);
461 }
462
463
481 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(year_t year, int month, int day, int hour, int min, int sec) {
482 return to_timestamp(year, month, day, hour, min, sec);
483 }
484
485
500 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day) {
501 return to_timestamp(year, month, day);
502 }
503
504
520 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day, int hour) {
521 return to_timestamp(year, month, day, hour);
522 }
523
524
541 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day, int hour, int min) {
542 return to_timestamp(year, month, day, hour, min);
543 }
544
545
563 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(year_t year, int month, int day, int hour, int min, int sec) {
564 return to_timestamp(year, month, day, hour, min, sec);
565 }
566
567
582 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day) {
583 return to_timestamp(year, month, day);
584 }
585
586
602 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day, int hour) {
603 return to_timestamp(year, month, day, hour);
604 }
605
606
623 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day, int hour, int min) {
624 return to_timestamp(year, month, day, hour, min);
625 }
626
627
645 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(year_t year, int month, int day, int hour, int min, int sec) {
646 return to_timestamp(year, month, day, hour, min, sec);
647 }
648
649
664 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day) {
665 return to_timestamp(year, month, day);
666 }
667
668
684 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day, int hour) {
685 return to_timestamp(year, month, day, hour);
686 }
687
688
705 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day, int hour, int min) {
706 return to_timestamp(year, month, day, hour, min);
707 }
708
709
727 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(year_t year, int month, int day, int hour, int min, int sec) {
728 return to_timestamp(year, month, day, hour, min, sec);
729 }
730
731//------------------------------------------------------------------------------
732
736 template<class T>
737 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp(
738 const T& date_time) {
739 return dt_to_timestamp(date_time);
740 }
741
745 template<class T>
746 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(
747 const T& date_time) {
748 return dt_to_timestamp(date_time);
749 }
750
754 template<class T>
755 TIME_SHIELD_CONSTEXPR inline ts_t ts(
756 const T& date_time) {
757 return dt_to_timestamp(date_time);
758 }
759
763 template<class T>
764 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(
765 const T& date_time) {
766 return dt_to_timestamp(date_time);
767 }
768
769//------------------------------------------------------------------------------
770
773 TIME_SHIELD_CONSTEXPR inline ts_t ts(const std::tm* timeinfo) {
774 return tm_to_timestamp(timeinfo);
775 }
776
779 TIME_SHIELD_CONSTEXPR inline ts_t get_ts(const std::tm* timeinfo) {
780 return tm_to_timestamp(timeinfo);
781 }
782
785 TIME_SHIELD_CONSTEXPR inline ts_t timestamp(const std::tm* timeinfo) {
786 return tm_to_timestamp(timeinfo);
787 }
788
791 TIME_SHIELD_CONSTEXPR inline ts_t get_timestamp(const std::tm* timeinfo) {
792 return tm_to_timestamp(timeinfo);
793 }
794
797 TIME_SHIELD_CONSTEXPR inline ts_t to_ts(const std::tm* timeinfo) {
798 return tm_to_timestamp(timeinfo);
799 }
800
803 TIME_SHIELD_CONSTEXPR inline ts_t ts_from_tm(const std::tm* timeinfo) {
804 return tm_to_timestamp(timeinfo);
805 }
806
809 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp(const std::tm* timeinfo) {
810 return tm_to_timestamp(timeinfo);
811 }
812
813//------------------------------------------------------------------------------
814
828 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day) {
829 return to_timestamp_ms(year, month, day);
830 }
831
846 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour) {
847 return to_timestamp_ms(year, month, day, hour);
848 }
849
865 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour, int min) {
866 return to_timestamp_ms(year, month, day, hour, min);
867 }
868
885 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour, int min, int sec) {
886 return to_timestamp_ms(year, month, day, hour, min, sec);
887 }
888
906 TIME_SHIELD_CONSTEXPR inline ts_ms_t ts_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
907 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
908 }
909
923 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day) {
924 return to_timestamp_ms(year, month, day);
925 }
926
941 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour) {
942 return to_timestamp_ms(year, month, day, hour);
943 }
944
960 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour, int min) {
961 return to_timestamp_ms(year, month, day, hour, min);
962 }
963
980 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_ts_ms(year_t year, int month, int day, int hour, int min, int sec) {
981 return to_timestamp_ms(year, month, day, hour, min, sec);
982 }
983
1001 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) {
1002 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1003 }
1004
1018 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day) {
1019 return to_timestamp_ms(year, month, day);
1020 }
1021
1036 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour) {
1037 return to_timestamp_ms(year, month, day, hour);
1038 }
1039
1055 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour, int min) {
1056 return to_timestamp_ms(year, month, day, hour, min);
1057 }
1058
1075 TIME_SHIELD_CONSTEXPR inline ts_ms_t get_timestamp_ms(year_t year, int month, int day, int hour, int min, int sec) {
1076 return to_timestamp_ms(year, month, day, hour, min, sec);
1077 }
1078
1096 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) {
1097 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1098 }
1099
1113 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day) {
1114 return to_timestamp_ms(year, month, day);
1115 }
1116
1131 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour) {
1132 return to_timestamp_ms(year, month, day, hour);
1133 }
1134
1150 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour, int min) {
1151 return to_timestamp_ms(year, month, day, hour, min);
1152 }
1153
1170 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour, int min, int sec) {
1171 return to_timestamp_ms(year, month, day, hour, min, sec);
1172 }
1173
1191 TIME_SHIELD_CONSTEXPR inline ts_ms_t timestamp_ms(year_t year, int month, int day, int hour, int min, int sec, int ms) {
1192 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1193 }
1194
1208 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day) {
1209 return to_timestamp_ms(year, month, day);
1210 }
1211
1226 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour) {
1227 return to_timestamp_ms(year, month, day, hour);
1228 }
1229
1245 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour, int min) {
1246 return to_timestamp_ms(year, month, day, hour, min);
1247 }
1248
1265 TIME_SHIELD_CONSTEXPR inline ts_ms_t to_ts_ms(year_t year, int month, int day, int hour, int min, int sec) {
1266 return to_timestamp_ms(year, month, day, hour, min, sec);
1267 }
1268
1286 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) {
1287 return to_timestamp_ms(year, month, day, hour, min, sec, ms);
1288 }
1289
1290//------------------------------------------------------------------------------
1291
1295 template<class T>
1296 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp_ms(
1297 const T& date_time) {
1298 return dt_to_timestamp_ms(date_time);
1299 }
1300
1304 template<class T>
1305 TIME_SHIELD_CONSTEXPR inline auto dt_to_ts_ms(const T& date_time)
1306 -> decltype(dt_to_timestamp_ms(date_time)) {
1307 return dt_to_timestamp_ms(date_time);
1308 }
1309
1313 template<class T>
1314 TIME_SHIELD_CONSTEXPR inline ts_t to_ts_ms(
1315 const T& date_time) {
1316 return dt_to_timestamp_ms(date_time);
1317 }
1318
1322 template<class T>
1323 TIME_SHIELD_CONSTEXPR inline ts_t ts_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 ts_t timestamp_ms(
1333 const T& date_time) {
1334 return dt_to_timestamp_ms(date_time);
1335 }
1336
1337//------------------------------------------------------------------------------
1338
1341 TIME_SHIELD_CONSTEXPR inline ts_t to_timestamp_ms(
1342 const std::tm *timeinfo) {
1343 return tm_to_timestamp_ms(timeinfo);
1344 }
1345
1348 TIME_SHIELD_CONSTEXPR inline auto tm_to_ts_ms(const std::tm *timeinfo)
1349 -> decltype(tm_to_timestamp_ms(timeinfo)) {
1350 return tm_to_timestamp_ms(timeinfo);
1351 }
1352
1355 TIME_SHIELD_CONSTEXPR inline ts_t to_ts_ms(
1356 const std::tm *timeinfo) {
1357 return tm_to_timestamp_ms(timeinfo);
1358 }
1359
1362 TIME_SHIELD_CONSTEXPR inline ts_t ts_ms(
1363 const std::tm *timeinfo) {
1364 return tm_to_timestamp_ms(timeinfo);
1365 }
1366
1369 TIME_SHIELD_CONSTEXPR inline ts_t timestamp_ms(
1370 const std::tm *timeinfo) {
1371 return tm_to_timestamp_ms(timeinfo);
1372 }
1373
1374//------------------------------------------------------------------------------
1375
1395 template<class T1 = year_t, class T2 = int, class T3 = int>
1396 TIME_SHIELD_CONSTEXPR fts_t to_fts(T1 year, T2 month, T2 day, T2 hour = 0, T2 min = 0, T2 sec = 0, T3 ms = 0) {
1397 return to_ftimestamp(year, month, day, hour, min, sec, ms);
1398 }
1399
1419 template<class T1 = year_t, class T2 = int, class T3 = int>
1420 TIME_SHIELD_CONSTEXPR fts_t fts(T1 year, T2 month, T2 day, T2 hour = 0, T2 min = 0, T2 sec = 0, T3 ms = 0) {
1421 return to_ftimestamp(year, month, day, hour, min, sec, ms);
1422 }
1423
1443 template<class T1 = year_t, class T2 = int, class T3 = int>
1444 TIME_SHIELD_CONSTEXPR fts_t ftimestamp(T1 year, T2 month, T2 day, T2 hour = 0, T2 min = 0, T2 sec = 0, T3 ms = 0) {
1445 return to_ftimestamp(year, month, day, hour, min, sec, ms);
1446 }
1447
1448//------------------------------------------------------------------------------
1449
1453 template<class T>
1454 TIME_SHIELD_CONSTEXPR fts_t to_ftimestamp(const T& date_time) {
1455 return dt_to_ftimestamp(date_time);
1456 }
1457
1461 template<class T>
1462 constexpr auto dt_to_fts(const T& date_time)
1463 -> decltype(dt_to_ftimestamp(date_time)) {
1464 return dt_to_ftimestamp(date_time);
1465 }
1466
1470 template<class T>
1471 TIME_SHIELD_CONSTEXPR fts_t to_fts(const T& date_time) {
1472 return dt_to_ftimestamp(date_time);
1473 }
1474
1478 template<class T>
1479 TIME_SHIELD_CONSTEXPR fts_t fts(const T& date_time) {
1480 return dt_to_ftimestamp(date_time);
1481 }
1482
1486 template<class T>
1487 TIME_SHIELD_CONSTEXPR fts_t ftimestamp(const T& date_time) {
1488 return dt_to_ftimestamp(date_time);
1489 }
1490
1491//------------------------------------------------------------------------------
1492
1496 TIME_SHIELD_CONSTEXPR inline fts_t to_ftimestamp(const std::tm* timeinfo) {
1497 return tm_to_ftimestamp(timeinfo);
1498 }
1499
1503 TIME_SHIELD_CONSTEXPR inline auto tm_to_fts(const std::tm* timeinfo)
1504 -> decltype(tm_to_ftimestamp(timeinfo)) {
1505 return tm_to_ftimestamp(timeinfo);
1506 }
1507
1511 TIME_SHIELD_CONSTEXPR inline fts_t to_fts(const std::tm* timeinfo) {
1512 return tm_to_ftimestamp(timeinfo);
1513 }
1514
1518 TIME_SHIELD_CONSTEXPR inline fts_t fts(const std::tm* timeinfo) {
1519 return tm_to_ftimestamp(timeinfo);
1520 }
1521
1525 TIME_SHIELD_CONSTEXPR inline fts_t ftimestamp(const std::tm* timeinfo) {
1526 return tm_to_ftimestamp(timeinfo);
1527 }
1528
1529//------------------------------------------------------------------------------
1530
1533 template<class T = int>
1534 TIME_SHIELD_CONSTEXPR T get_days(ts_t start, ts_t stop) noexcept {
1535 return days_between<T>(start, stop);
1536 }
1537
1540 template<class T = int>
1541 TIME_SHIELD_CONSTEXPR T days(ts_t start, ts_t stop) noexcept {
1542 return days_between<T>(start, stop);
1543 }
1544
1547 template<class T = int>
1548 TIME_SHIELD_CONSTEXPR T get_days_difference(ts_t start, ts_t stop) noexcept {
1549 return days_between<T>(start, stop);
1550 }
1551
1554 template<class T = int>
1555 TIME_SHIELD_CONSTEXPR T diff_in_days(ts_t start, ts_t stop) noexcept {
1556 return days_between<T>(start, stop);
1557 }
1558
1559//------------------------------------------------------------------------------
1560
1563 template<class T = year_t>
1564 TIME_SHIELD_CONSTEXPR inline T year(ts_t ts = time_shield::ts()) {
1565 return year_of<T>(ts);
1566 }
1567
1570 template<class T = year_t>
1571 TIME_SHIELD_CONSTEXPR inline T to_year(ts_t ts = time_shield::ts()) {
1572 return year_of<T>(ts);
1573 }
1574
1575//------------------------------------------------------------------------------
1576
1579 template<class T = year_t>
1580 TIME_SHIELD_CONSTEXPR inline T year_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1581 return year_of_ms<T>(ts_ms);
1582 }
1583
1586 template<class T = year_t>
1587 TIME_SHIELD_CONSTEXPR inline T to_year_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1588 return year_of_ms<T>(ts_ms);
1589 }
1590
1591//------------------------------------------------------------------------------
1592
1595 TIME_SHIELD_CONSTEXPR inline ts_t year_start(ts_t ts = time_shield::ts()) {
1596 return start_of_year(ts);
1597 }
1598
1601 TIME_SHIELD_CONSTEXPR inline ts_t year_begin(ts_t ts = time_shield::ts()) {
1602 return start_of_year(ts);
1603 }
1604
1605//------------------------------------------------------------------------------
1606
1612
1618
1619//------------------------------------------------------------------------------
1620
1623 template<class T = year_t>
1624 TIME_SHIELD_CONSTEXPR inline ts_t year_start_date(T year) {
1625 return start_of_year_date(year);
1626 }
1627
1630 template<class T = year_t>
1631 TIME_SHIELD_CONSTEXPR inline ts_t year_begin_date(T year) {
1632 return start_of_year_date(year);
1633 }
1634
1635//------------------------------------------------------------------------------
1636
1639 template<class T = year_t>
1640 TIME_SHIELD_CONSTEXPR inline ts_ms_t year_start_date_ms(T year) {
1642 }
1643
1646 template<class T = year_t>
1647 TIME_SHIELD_CONSTEXPR inline ts_ms_t year_begin_date_ms(T year) {
1649 }
1650
1651//------------------------------------------------------------------------------
1652
1655 TIME_SHIELD_CONSTEXPR inline ts_t year_end(ts_t ts = time_shield::ts()) {
1656 return end_of_year(ts);
1657 }
1658
1659//------------------------------------------------------------------------------
1660
1663 TIME_SHIELD_CONSTEXPR inline ts_ms_t year_end_ms(ts_ms_t ts_ms = time_shield::ts_ms()) {
1664 return end_of_year_ms(ts_ms);
1665 }
1666
1667//------------------------------------------------------------------------------
1668
1673 template<class T1 = int, class T2 = year_t, class T3 = int>
1674 TIME_SHIELD_CONSTEXPR T1 days_in_month(T2 year, T3 month) noexcept {
1675 return num_days_in_month(year, month);
1676 }
1677
1678//------------------------------------------------------------------------------
1679
1682 template<class T1 = int>
1683 TIME_SHIELD_CONSTEXPR T1 num_days_in_month(ts_t ts = time_shield::ts()) noexcept {
1684 return num_days_in_month_ts(ts);
1685 }
1686
1689 template<class T1 = int>
1690 TIME_SHIELD_CONSTEXPR T1 days_in_month(ts_t ts = time_shield::ts()) noexcept {
1691 return num_days_in_month_ts(ts);
1692 }
1693
1694//------------------------------------------------------------------------------
1695
1698 template<class T1 = int, class T2 = year_t>
1699 TIME_SHIELD_CONSTEXPR T1 days_in_year(T2 year) noexcept {
1700 return num_days_in_year(year);
1701 }
1702
1703//------------------------------------------------------------------------------
1704
1707 template<class T = int>
1708 TIME_SHIELD_CONSTEXPR T days_in_year_ts(ts_t ts = time_shield::ts()) {
1709 return num_days_in_year_ts(ts);
1710 }
1711
1712//------------------------------------------------------------------------------
1713
1716 TIME_SHIELD_CONSTEXPR inline ts_t day_start(ts_t ts = time_shield::ts()) noexcept {
1717 return start_of_day(ts);
1718 }
1719
1720//------------------------------------------------------------------------------
1721
1724 template<class T = int>
1725 TIME_SHIELD_CONSTEXPR ts_t previous_day_start(ts_t ts = time_shield::ts(), T days = 1) noexcept {
1726 return start_of_prev_day(ts, days);
1727 }
1728
1729//------------------------------------------------------------------------------
1730
1733 TIME_SHIELD_CONSTEXPR inline ts_t day_start_sec(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
1734 return start_of_day(ms_to_sec(ts_ms));
1735 }
1736
1739 TIME_SHIELD_CONSTEXPR inline ts_t start_day_sec(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
1740 return start_of_day(ms_to_sec(ts_ms));
1741 }
1742
1743//------------------------------------------------------------------------------
1744
1747 TIME_SHIELD_CONSTEXPR inline ts_ms_t day_start_ms(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
1748 return start_of_day_ms(ts_ms);
1749 }
1750
1751//------------------------------------------------------------------------------
1752
1755 template<class T = int>
1756 TIME_SHIELD_CONSTEXPR ts_t next_day_start(ts_t ts, T days = 1) noexcept {
1757 return start_of_next_day(ts, days);
1758 }
1759
1760//------------------------------------------------------------------------------
1761
1764 template<class T = int>
1765 TIME_SHIELD_CONSTEXPR ts_ms_t next_day_start_ms(ts_ms_t ts_ms, T days = 1) noexcept {
1767 }
1768
1769//------------------------------------------------------------------------------
1770
1773 TIME_SHIELD_CONSTEXPR inline ts_t day_end(ts_t ts = time_shield::ts()) noexcept {
1774 return end_of_day(ts);
1775 }
1776
1777//------------------------------------------------------------------------------
1778
1781 TIME_SHIELD_CONSTEXPR inline ts_t day_end_sec(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
1782 return end_of_day_sec(ts_ms);
1783 }
1784
1785//------------------------------------------------------------------------------
1786
1789 TIME_SHIELD_CONSTEXPR inline ts_ms_t day_end_ms(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
1790 return end_of_day_ms(ts_ms);
1791 }
1792
1793//------------------------------------------------------------------------------
1794
1797 template<class T1 = Weekday>
1798 TIME_SHIELD_CONSTEXPR T1 day_of_week(year_t year, int month, int day) {
1799 return day_of_week_date<T1>(year, month, day);
1800 }
1801
1804 template<class T1 = Weekday>
1805 TIME_SHIELD_CONSTEXPR T1 day_of_week(year_t year, Month month, int day) {
1806 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1807 }
1808
1811 template<class T1 = Weekday>
1812 TIME_SHIELD_CONSTEXPR T1 get_weekday(year_t year, int month, int day) {
1813 return day_of_week_date<T1>(year, month, day);
1814 }
1815
1818 template<class T1 = Weekday>
1819 TIME_SHIELD_CONSTEXPR T1 get_weekday(year_t year, Month month, int day) {
1820 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1821 }
1822
1825 template<class T1 = Weekday>
1826 TIME_SHIELD_CONSTEXPR T1 weekday(year_t year, int month, int day) {
1827 return day_of_week_date<T1>(year, month, day);
1828 }
1829
1832 template<class T1 = Weekday>
1833 TIME_SHIELD_CONSTEXPR T1 weekday(year_t year, Month month, int day) {
1834 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1835 }
1836
1839 template<class T1 = Weekday>
1840 TIME_SHIELD_CONSTEXPR T1 dow(year_t year, int month, int day) {
1841 return day_of_week_date<T1>(year, month, day);
1842 }
1843
1846 template<class T1 = Weekday>
1847 TIME_SHIELD_CONSTEXPR T1 dow(year_t year, Month month, int day) {
1848 return day_of_week_date<T1>(year, static_cast<int>(month), day);
1849 }
1850
1851//------------------------------------------------------------------------------
1852
1856 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1857 TIME_SHIELD_CONSTEXPR T1 get_dow(const T2& date) {
1858 return weekday_of_date<T1>(date);
1859 }
1860
1864 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1865 TIME_SHIELD_CONSTEXPR T1 dow_from_date(const T2& date) {
1866 return weekday_of_date<T1>(date);
1867 }
1868
1872 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1873 TIME_SHIELD_CONSTEXPR T1 weekday_of(const T2& date) {
1874 return weekday_of_date<T1>(date);
1875 }
1876
1880 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1881 TIME_SHIELD_CONSTEXPR T1 day_of_week_dt(const T2& date) {
1882 return weekday_of_date<T1>(date);
1883 }
1884
1888 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1889 TIME_SHIELD_CONSTEXPR T1 day_of_week(const T2& date) {
1890 return weekday_of_date<T1>(date);
1891 }
1892
1896 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1897 TIME_SHIELD_CONSTEXPR T1 dow(const T2& date) {
1898 return weekday_of_date<T1>(date);
1899 }
1900
1904 template<class T1 = Weekday, class T2, typename std::enable_if<std::is_class<T2>::value, int>::type = 0>
1905 TIME_SHIELD_CONSTEXPR T1 wd(const T2& date) {
1906 return weekday_of_date<T1>(date);
1907 }
1908
1909//------------------------------------------------------------------------------
1910
1911
1914 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1915 TIME_SHIELD_CONSTEXPR T day_of_week(U ts) noexcept {
1916 return weekday_of_ts<T>(ts);
1917 }
1918
1921 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1922 TIME_SHIELD_CONSTEXPR T dow_ts(U ts) noexcept {
1923 return weekday_of_ts<T>(ts);
1924 }
1925
1928 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1929 TIME_SHIELD_CONSTEXPR T get_dow_from_ts(U ts) noexcept {
1930 return weekday_of_ts<T>(ts);
1931 }
1932
1933//------------------------------------------------------------------------------
1934
1937 template<class T = Weekday, class U, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
1938 TIME_SHIELD_CONSTEXPR T wd_ts(U ts) noexcept {
1939 return weekday_of_ts<T>(ts);
1940 }
1941
1942//------------------------------------------------------------------------------
1943
1946 template<class T = Weekday>
1947 TIME_SHIELD_CONSTEXPR T day_of_week_ms(ts_ms_t ts_ms) {
1948 return weekday_of_ts_ms<T>(ts_ms);
1949 }
1950
1953 template<class T = Weekday>
1954 TIME_SHIELD_CONSTEXPR T wd_ms(ts_ms_t ts_ms) {
1955 return weekday_of_ts_ms<T>(ts_ms);
1956 }
1957
1958//------------------------------------------------------------------------------
1959
1962 TIME_SHIELD_CONSTEXPR inline ts_t month_begin(ts_t ts = time_shield::ts()) {
1963 return start_of_month(ts);
1964 }
1965
1966//------------------------------------------------------------------------------
1967
1970 TIME_SHIELD_CONSTEXPR inline ts_t last_day_of_month(ts_t ts = time_shield::ts()) {
1971 return end_of_month(ts);
1972 }
1973
1974//------------------------------------------------------------------------------
1975
1978 TIME_SHIELD_CONSTEXPR inline ts_t final_sunday_of_month(ts_t ts = time_shield::ts()) {
1979 return last_sunday_of_month(ts);
1980 }
1981
1982//------------------------------------------------------------------------------
1983
1986 template<class T1 = int, class T2 = year_t, class T3 = int>
1987 TIME_SHIELD_CONSTEXPR inline T1 final_sunday_month_day(T2 year, T3 month) {
1988 return last_sunday_month_day(year, month);
1989 }
1990
1991//------------------------------------------------------------------------------
1992
1995 TIME_SHIELD_CONSTEXPR inline ts_t hour_begin(ts_t ts = time_shield::ts()) noexcept {
1996 return start_of_hour(ts);
1997 }
1998
1999//------------------------------------------------------------------------------
2000
2003 TIME_SHIELD_CONSTEXPR inline ts_t hour_begin_sec(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
2004 return start_of_hour_sec(ts_ms);
2005 }
2006
2007//------------------------------------------------------------------------------
2008
2011 TIME_SHIELD_CONSTEXPR inline ts_ms_t hour_begin_ms(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
2012 return start_of_hour_ms(ts_ms);
2013 }
2014
2015//------------------------------------------------------------------------------
2016
2019 TIME_SHIELD_CONSTEXPR inline ts_t finish_of_hour(ts_t ts = time_shield::ts()) noexcept {
2020 return end_of_hour(ts);
2021 }
2022
2023//------------------------------------------------------------------------------
2024
2027 TIME_SHIELD_CONSTEXPR inline ts_t finish_of_hour_sec(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
2028 return end_of_hour_sec(ts_ms);
2029 }
2030
2031//------------------------------------------------------------------------------
2032
2035 TIME_SHIELD_CONSTEXPR inline ts_ms_t finish_of_hour_ms(ts_ms_t ts_ms = time_shield::ts_ms()) noexcept {
2036 return end_of_hour_ms(ts_ms);
2037 }
2038
2039//------------------------------------------------------------------------------
2040
2043 template<class T = int>
2044 TIME_SHIELD_CONSTEXPR T hour_in_day(ts_t ts = time_shield::ts()) noexcept {
2045 return hour_of_day(ts);
2046 }
2047
2048//------------------------------------------------------------------------------
2049
2052 TIME_SHIELD_CONSTEXPR inline ts_t week_begin(ts_t ts = time_shield::ts()) {
2053 return start_of_week(ts);
2054 }
2055
2056//------------------------------------------------------------------------------
2057
2060 TIME_SHIELD_CONSTEXPR inline ts_t finish_of_week(ts_t ts = time_shield::ts()) {
2061 return end_of_week(ts);
2062 }
2063
2064//------------------------------------------------------------------------------
2065
2068 TIME_SHIELD_CONSTEXPR inline ts_t saturday_begin(ts_t ts = time_shield::ts()) {
2069 return start_of_saturday(ts);
2070 }
2071
2072//------------------------------------------------------------------------------
2073
2076 TIME_SHIELD_CONSTEXPR inline ts_t min_begin(ts_t ts = time_shield::ts()) noexcept {
2077 return start_of_min(ts);
2078 }
2079
2080//------------------------------------------------------------------------------
2081
2084 TIME_SHIELD_CONSTEXPR inline ts_t finish_of_min(ts_t ts = time_shield::ts()) noexcept {
2085 return end_of_min(ts);
2086 }
2087
2088//------------------------------------------------------------------------------
2089
2092 TIME_SHIELD_CONSTEXPR inline bool workday(ts_t ts) noexcept {
2093 return is_workday(ts);
2094 }
2095
2099 TIME_SHIELD_CONSTEXPR inline bool workday_ms(ts_ms_t ts_ms) noexcept {
2100 return is_workday_ms(ts_ms);
2101 }
2102
2105 TIME_SHIELD_CONSTEXPR inline bool workday(year_t year, int month, int day) noexcept {
2106 return is_workday(year, month, day);
2107 }
2108
2111 template<class T>
2112 TIME_SHIELD_CONSTEXPR inline tz_t tz_offset(const T& tz) noexcept {
2113 return to_tz_offset(tz);
2114 }
2115
2118 TIME_SHIELD_CONSTEXPR inline tz_t offset_hm(int hour, int min = 0) noexcept {
2119 return tz_offset_hm(hour, min);
2120 }
2121
2124 TIME_SHIELD_CONSTEXPR inline bool valid_tz_offset(tz_t off) noexcept {
2125 return is_valid_tz_offset(off);
2126 }
2127
2129
2130}; // namespace time_shield
2131
2132#endif // TIME_SHIELD_HEADER_CONVERSIONS_TIME_CONVERSION_ALIASES_HPP_INCLUDED
TIME_SHIELD_CONSTEXPR T diff_in_days(ts_t start, ts_t stop) noexcept
Alias for days_between function.
TIME_SHIELD_CONSTEXPR ts_t day_end_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_day_sec function.
TIME_SHIELD_CONSTEXPR T start_of_day_from_unix_day_ms(dse_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
TIME_SHIELD_CONSTEXPR T1 ms_to_sec(T2 ts_ms) noexcept
Converts a timestamp from milliseconds to seconds.
TIME_SHIELD_CONSTEXPR T unix_day(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
TIME_SHIELD_CONSTEXPR T start_of_day_from_unix_day(dse_t unix_day) noexcept
Alias for unix_day_to_ts function.
TIME_SHIELD_CONSTEXPR T to_unix_year(ts_t ts) noexcept
Alias for years_since_epoch function.
TIME_SHIELD_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.
TIME_SHIELD_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 T dse_to_ts(dse_t unix_day) noexcept
Short alias for unix_day_to_ts.
TIME_SHIELD_CONSTEXPR ts_ms_t year_begin_date_ms(T year)
Alias for start_of_year_date_ms function.
ts_ms_t year_start_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for start_of_year_ms function.
TIME_SHIELD_CONSTEXPR ts_ms_t get_ts_ms(year_t year, int month, int day)
Alias for to_timestamp_ms.
TIME_SHIELD_CONSTEXPR T unixday_to_ts_ms(dse_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
TIME_SHIELD_CONSTEXPR ts_t finish_of_hour(ts_t ts=time_shield::ts()) noexcept
Alias for end_of_hour function.
TIME_SHIELD_CONSTEXPR bool workday(ts_t ts) noexcept
Alias for is_workday(ts_t).
TIME_SHIELD_CONSTEXPR ts_t day_start_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_day_sec function.
TIME_SHIELD_CONSTEXPR T unix_year(ts_t ts) noexcept
Alias for years_since_epoch function.
TIME_SHIELD_CONSTEXPR T days_in_year_ts(ts_t ts=time_shield::ts())
Alias for num_days_in_year_ts function.
TIME_SHIELD_CONSTEXPR T1 get_weekday(year_t year, int month, int day)
Alias for day_of_week_date.
TIME_SHIELD_CONSTEXPR ts_t day_start(ts_t ts=time_shield::ts()) noexcept
Alias for start_of_day function.
TIME_SHIELD_CONSTEXPR T get_unixday(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
TIME_SHIELD_CONSTEXPR ts_t min_begin(ts_t ts=time_shield::ts()) noexcept
Alias for start_of_min function.
TIME_SHIELD_CONSTEXPR bool is_valid_tz_offset(tz_t off) noexcept
Check if a numeric offset is within supported bounds.
TIME_SHIELD_CONSTEXPR T1 day_of_week_dt(const T2 &date)
Alias for weekday_of_date.
TIME_SHIELD_CONSTEXPR T day_of_week_ms(ts_ms_t ts_ms)
Alias for weekday_of_ts_ms function.
TIME_SHIELD_CONSTEXPR ts_t year_begin_date(T year)
Alias for start_of_year_date function.
TIME_SHIELD_CONSTEXPR T uday(ts_t ts=time_shield::ts()) noexcept
Alias for days_since_epoch function.
TIME_SHIELD_CONSTEXPR ts_t saturday_begin(ts_t ts=time_shield::ts())
Alias for start_of_saturday function.
TIME_SHIELD_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 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.
TIME_SHIELD_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.
TIME_SHIELD_CONSTEXPR ts_t year_begin(ts_t ts=time_shield::ts())
Alias for start_of_year function.
TIME_SHIELD_CONSTEXPR ts_ms_t day_start_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for start_of_day_ms 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.
TIME_SHIELD_CONSTEXPR T1 weekday_of_date(const T2 &date)
Get the day of the week from a date structure.
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.
T to_dt_struct_ms(ts_ms_t ts)
Alias for to_date_time_ms function.
TIME_SHIELD_CONSTEXPR ts_t hour_begin(ts_t ts=time_shield::ts()) noexcept
Alias for start_of_hour function.
TIME_SHIELD_CONSTEXPR ts_t final_sunday_of_month(ts_t ts=time_shield::ts())
Alias for last_sunday_of_month function.
TIME_SHIELD_CONSTEXPR T days(ts_t start, ts_t stop) noexcept
Alias for days_between function.
TIME_SHIELD_CONSTEXPR T uday_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
TIME_SHIELD_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 T unixday_to_ts(dse_t unix_day) noexcept
Alias for unix_day_to_ts function.
TIME_SHIELD_CONSTEXPR T1 days_in_year(T2 year) noexcept
Alias for num_days_in_year function.
TIME_SHIELD_CONSTEXPR ts_t next_day_start(ts_t ts, T days=1) noexcept
Alias for start_of_next_day function.
TIME_SHIELD_CONSTEXPR bool valid_tz_offset(tz_t off) noexcept
Alias for is_valid_tz_offset.
TIME_SHIELD_CONSTEXPR T umin(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
TIME_SHIELD_CONSTEXPR T get_days_difference(ts_t start, ts_t stop) noexcept
Alias for days_between function.
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 T1 weekday(year_t year, int month, int day)
Alias for day_of_week_date.
TIME_SHIELD_CONSTEXPR ts_t last_day_of_month(ts_t ts=time_shield::ts())
Alias for end_of_month function.
TIME_SHIELD_CONSTEXPR ts_t year_start(ts_t ts=time_shield::ts())
Alias for start_of_year function.
TIME_SHIELD_CONSTEXPR T hour_in_day(ts_t ts=time_shield::ts()) noexcept
Alias for hour_of_day function.
TIME_SHIELD_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 tm_to_fts(const std::tm *timeinfo) -> decltype(tm_to_ftimestamp(timeinfo))
Alias for tm_to_ftimestamp.
TIME_SHIELD_CONSTEXPR T get_dow_from_ts(U ts) noexcept
Alias for weekday_of_ts.
TIME_SHIELD_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 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.
TIME_SHIELD_CONSTEXPR ts_t finish_of_hour_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_hour_sec function.
TIME_SHIELD_CONSTEXPR tz_t tz_offset_hm(int hour, int min=0) noexcept
Build offset in seconds from hours/minutes.
TIME_SHIELD_CONSTEXPR T1 dow_from_date(const T2 &date)
Alias for weekday_of_date.
TIME_SHIELD_CONSTEXPR T1 dow(year_t year, int month, int day)
Alias for day_of_week_date.
TIME_SHIELD_CONSTEXPR ts_t finish_of_min(ts_t ts=time_shield::ts()) noexcept
Alias for end_of_min function.
TIME_SHIELD_CONSTEXPR ts_ms_t day_end_ms(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Alias for end_of_day_ms function.
TIME_SHIELD_CONSTEXPR T minutes_since_epoch(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
TIME_SHIELD_CONSTEXPR tz_t tz_offset(const T &tz) noexcept
Alias for to_tz_offset.
TIME_SHIELD_CONSTEXPR T dse(ts_t ts=time_shield::ts()) noexcept
Short alias for days_since_epoch.
TIME_SHIELD_CONSTEXPR T unixday_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
TIME_SHIELD_CONSTEXPR T unixday(ts_t ts=time_shield::ts()) noexcept
Alias for days_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.
TIME_SHIELD_CONSTEXPR T1 weekday_of(const T2 &date)
Alias for weekday_of_date.
TIME_SHIELD_CONSTEXPR T get_days(ts_t start, ts_t stop) noexcept
Alias for days_between function.
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.
TIME_SHIELD_CONSTEXPR T dow_ts(U ts) noexcept
Alias for weekday_of_ts.
TIME_SHIELD_CONSTEXPR T next_day_from_unix_day_ms(dse_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day_ms function.
TIME_SHIELD_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.
TIME_SHIELD_CONSTEXPR T dse_to_ts_ms(dse_t unix_day) noexcept
Short alias for unix_day_to_ts_ms.
TIME_SHIELD_CONSTEXPR bool workday_ms(ts_ms_t ts_ms) noexcept
Alias for is_workday(ts_ms_t).
TIME_SHIELD_CONSTEXPR T uday_to_ts_ms(dse_t unix_day) noexcept
Alias for unix_day_to_ts_ms function.
TIME_SHIELD_CONSTEXPR T1 day_of_week(year_t year, int month, int day)
Alias for day_of_week_date.
TIME_SHIELD_CONSTEXPR ts_t week_begin(ts_t ts=time_shield::ts())
Alias for start_of_week function.
TIME_SHIELD_CONSTEXPR ts_t finish_of_week(ts_t ts=time_shield::ts())
Alias for end_of_week function.
TIME_SHIELD_CONSTEXPR T1 days_in_month(T2 year, T3 month) noexcept
Alias for num_days_in_month function.
TIME_SHIELD_CONSTEXPR T1 get_dow(const T2 &date)
Alias for weekday_of_date.
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.
TIME_SHIELD_CONSTEXPR ts_t year_end(ts_t ts=time_shield::ts())
Alias for end_of_year function.
TIME_SHIELD_CONSTEXPR T unix_day_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch 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.
TIME_SHIELD_CONSTEXPR T1 wd(const T2 &date)
Alias for weekday_of_date.
TIME_SHIELD_CONSTEXPR T to_unix_min(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
TIME_SHIELD_CONSTEXPR ts_t day_end(ts_t ts=time_shield::ts()) noexcept
Alias for end_of_day function.
TIME_SHIELD_CONSTEXPR T unix_min(ts_t ts=time_shield::ts())
Alias for min_since_epoch function.
TIME_SHIELD_CONSTEXPR T dse_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Short alias for days_since_epoch_ms.
T1 to_dt(T2 ts)
Alias for to_date_time function.
TIME_SHIELD_CONSTEXPR T wd_ts(U ts) noexcept
Alias for weekday_of_ts.
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.
TIME_SHIELD_CONSTEXPR tz_t to_tz_offset(const T &tz) noexcept
Convert time zone struct to offset in seconds.
TIME_SHIELD_CONSTEXPR T uday_to_ts(dse_t unix_day) noexcept
Alias for unix_day_to_ts function.
TIME_SHIELD_CONSTEXPR T next_day_from_unix_day(dse_t unix_day) noexcept
Alias for start_of_next_day_from_unix_day 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 get_unixday_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Alias for days_since_epoch function.
TIME_SHIELD_CONSTEXPR T year_ms(ts_ms_t ts_ms=time_shield::ts_ms())
Alias for year_of_ms function.
TIME_SHIELD_CONSTEXPR ts_t tm_to_timestamp(const std::tm *timeinfo)
Converts a std::tm structure to a timestamp.
TIME_SHIELD_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 fts_t dt_to_ftimestamp(const T &date_time)
Converts a date-time structure to a floating-point timestamp.
TIME_SHIELD_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.
TIME_SHIELD_CONSTEXPR fts_t tm_to_ftimestamp(const std::tm *timeinfo)
Converts a std::tm structure to a floating-point timestamp.
TIME_SHIELD_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 T weekday_of_ts(ts_t ts) noexcept
Get the second of the week day from a timestamp.
TIME_SHIELD_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 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_hour(ts_t ts=time_shield::ts()) noexcept
Get the timestamp at the start of the hour.
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.
TIME_SHIELD_CONSTEXPR ts_t end_of_min(ts_t ts=time_shield::ts()) noexcept
Get the timestamp of the end 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.
TIME_SHIELD_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 ts_t end_of_year(ts_t ts=time_shield::ts())
Get the end-of-year timestamp.
TIME_SHIELD_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 start_of_year(ts_t ts) noexcept
Get the start of the year timestamp.
TIME_SHIELD_CONSTEXPR ts_t start_of_day(ts_t ts=time_shield::ts()) noexcept
Get the start of the day timestamp.
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_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.
TIME_SHIELD_CONSTEXPR ts_ms_t dt_to_timestamp_ms(const T &date_time)
Converts a date-time structure to a timestamp in milliseconds.
TIME_SHIELD_CONSTEXPR ts_t dt_to_timestamp(const T &date_time)
Converts a date-time structure to a timestamp.
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 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 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 start_of_hour_sec(ts_ms_t ts_ms=time_shield::ts_ms()) noexcept
Get the timestamp at the start of the hour.
TIME_SHIELD_CONSTEXPR ts_t end_of_month(ts_t ts=time_shield::ts())
Get the last timestamp of the current month.
TIME_SHIELD_CONSTEXPR ts_t start_of_week(ts_t ts=time_shield::ts())
Get the timestamp of the beginning of the week.
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.
TIME_SHIELD_CONSTEXPR ts_t start_of_saturday(ts_t ts=time_shield::ts())
Get the timestamp of the start of Saturday.
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.
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.
T1 to_date_time(T2 ts)
Converts a timestamp to a date-time structure.
TIME_SHIELD_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_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.
TIME_SHIELD_CONSTEXPR T1 num_days_in_month(T2 year, T3 month) noexcept
Get the number of days in a month.
TIME_SHIELD_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_t start_of_prev_day(ts_t ts=time_shield::ts(), T days=1) noexcept
Get timestamp of the start of the previous day.
TIME_SHIELD_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 T weekday_of_ts_ms(ts_ms_t ts_ms)
Get the weekday from a timestamp in milliseconds.
TIME_SHIELD_CONSTEXPR ts_ms_t start_of_year_date_ms(T year)
Get the timestamp in milliseconds of the start of the year.
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
int64_t dse_t
Unix day count since 1970‑01‑01 (days since epoch).
Definition types.hpp:41
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
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:40
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.
TIME_SHIELD_CONSTEXPR bool is_workday(ts_t ts) noexcept
Check if a given timestamp corresponds to a workday (Monday to Friday).
TIME_SHIELD_CONSTEXPR bool is_workday_ms(ts_ms_t ts_ms) noexcept
Check if a given timestamp in milliseconds corresponds to a workday (Monday to Friday).
Main namespace for the Time Shield library.
TIME_SHIELD_CONSTEXPR T unix_day_to_ts_ms(dse_t unix_day) noexcept
Converts a UNIX day to a timestamp in milliseconds.
TIME_SHIELD_CONSTEXPR T years_since_epoch(ts_t ts) noexcept
Converts a UNIX timestamp to a year.
TIME_SHIELD_CONSTEXPR T unix_day_to_ts(dse_t unix_day) noexcept
Converts a UNIX day to a timestamp in seconds.
TIME_SHIELD_CONSTEXPR T days_since_epoch_ms(ts_ms_t t_ms=time_shield::ts_ms()) noexcept
Get UNIX day from milliseconds timestamp.
TIME_SHIELD_CONSTEXPR T start_of_next_day_from_unix_day(dse_t unix_day) noexcept
Converts a UNIX day to a timestamp representing the start of the next day in seconds.
TIME_SHIELD_CONSTEXPR T days_since_epoch(ts_t ts=time_shield::ts()) noexcept
Get UNIX day.
TIME_SHIELD_CONSTEXPR T min_since_epoch(ts_t ts=time_shield::ts())
Get UNIX minute.
TIME_SHIELD_CONSTEXPR T start_of_next_day_from_unix_day_ms(dse_t unix_day) noexcept
Converts a UNIX day to a timestamp representing the start of the next day in milliseconds.
TIME_SHIELD_CONSTEXPR T days_between(ts_t start, ts_t stop) noexcept
Get the number of days between two timestamps.