Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
constants.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
3#define _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
4
9
10#include <cstdint>
11#include <limits>
12
13namespace time_shield {
14
31
32 // Common millisecond durations
33 constexpr int64_t MS_1 = 1;
34 constexpr int64_t MS_5 = 5;
35 constexpr int64_t MS_10 = 10;
36 constexpr int64_t MS_50 = 50;
37 constexpr int64_t MS_100 = 100;
38 constexpr int64_t MS_250 = 250;
39 constexpr int64_t MS_500 = 500;
40 constexpr int64_t MS_750 = 750;
41
42 // Common second durations
43 constexpr int64_t SEC_1 = 1;
44 constexpr int64_t SEC_2 = 2;
45 constexpr int64_t SEC_3 = 3;
46 constexpr int64_t SEC_5 = 5;
47 constexpr int64_t SEC_10 = 10;
48 constexpr int64_t SEC_15 = 15;
49 constexpr int64_t SEC_30 = 30;
50
51 // Common minute durations
52 constexpr int64_t MIN_1 = 1;
53 constexpr int64_t MIN_2 = 2;
54 constexpr int64_t MIN_5 = 5;
55 constexpr int64_t MIN_10 = 10;
56 constexpr int64_t MIN_15 = 15;
57 constexpr int64_t MIN_30 = 30;
58
59 // Common hour durations
60 constexpr int64_t HOUR_1 = 1;
61 constexpr int64_t HOUR_2 = 2;
62 constexpr int64_t HOUR_3 = 3;
63 constexpr int64_t HOUR_4 = 4;
64 constexpr int64_t HOUR_5 = 5;
65 constexpr int64_t HOUR_8 = 8;
66 constexpr int64_t HOUR_12 = 12;
67 constexpr int64_t HOUR_24 = 24;
68
69 // Nanoseconds and microseconds
70 constexpr int64_t NS_PER_US = 1000;
71 constexpr int64_t NS_PER_MS = 1000000;
72 constexpr int64_t NS_PER_SEC = 1000000000;
73
74 // Microseconds and milliseconds
75 constexpr int64_t US_PER_SEC = 1000000;
76 constexpr int64_t MS_PER_SEC = 1000;
77 constexpr int64_t MS_PER_1_SEC = 1000;
78 constexpr int64_t MS_PER_5_SEC = 5000;
79 constexpr int64_t MS_PER_10_SEC = 10000;
80 constexpr int64_t MS_PER_15_SEC = 15000;
81 constexpr int64_t MS_PER_30_SEC = 30000;
82 constexpr int64_t MS_PER_MIN = 60000;
83 constexpr int64_t MS_PER_1_MIN = 60000;
84 constexpr int64_t MS_PER_5_MIN = 300000;
85 constexpr int64_t MS_PER_10_MIN = 600000;
86 constexpr int64_t MS_PER_15_MIN = 900000;
87 constexpr int64_t MS_PER_30_MIN = 1800000;
88 constexpr int64_t MS_PER_HALF_HOUR = 1800000;
89 constexpr int64_t MS_PER_HOUR = 3600000;
90 constexpr int64_t MS_PER_1_HOUR = 3600000;
91 constexpr int64_t MS_PER_2_HOUR = 7200000;
92 constexpr int64_t MS_PER_4_HOUR = 14400000;
93 constexpr int64_t MS_PER_5_HOUR = 18000000;
94 constexpr int64_t MS_PER_8_HOUR = 28800000;
95 constexpr int64_t MS_PER_12_HOUR = 43200000;
96 constexpr int64_t MS_PER_DAY = 86400000;
97
98 // Seconds
99 constexpr int64_t SEC_PER_MIN = 60;
100 constexpr int64_t SEC_PER_1_MIN = 60;
101 constexpr int64_t SEC_PER_3_MIN = 180;
102 constexpr int64_t SEC_PER_5_MIN = 300;
103 constexpr int64_t SEC_PER_10_MIN = 600;
104 constexpr int64_t SEC_PER_15_MIN = 900;
105 constexpr int64_t SEC_PER_HALF_HOUR = 1800;
106 constexpr int64_t SEC_PER_HOUR = 3600;
107 constexpr int64_t SEC_PER_1_HOUR = 3600;
108 constexpr int64_t SEC_PER_2_HOUR = 7200;
109 constexpr int64_t SEC_PER_4_HOUR = 14400;
110 constexpr int64_t SEC_PER_5_HOUR = 18000;
111 constexpr int64_t SEC_PER_8_HOUR = 28800;
112 constexpr int64_t SEC_PER_12_HOUR = 43200;
113 constexpr int64_t SEC_PER_DAY = 86400;
114 constexpr int64_t SEC_PER_YEAR = 31536000;
115 constexpr int64_t AVG_SEC_PER_YEAR = 31557600;
116 constexpr int64_t SEC_PER_LEAP_YEAR = 31622400;
117 constexpr int64_t SEC_PER_4_YEARS = 126230400;
118 constexpr int64_t SEC_PER_FIRST_100_YEARS = 3155760000;
119 constexpr int64_t SEC_PER_100_YEARS = 3155673600;
120 constexpr int64_t SEC_PER_400_YEARS = 12622780800;
121 constexpr int64_t MAX_SEC_PER_DAY = 86399;
122
123 // Minutes
124 constexpr int64_t MIN_PER_HOUR = 60;
125 constexpr int64_t MIN_PER_DAY = 1440;
126 constexpr int64_t MIN_PER_1_DAY = 1440;
127 constexpr int64_t MIN_PER_2_DAY = 2*1440;
128 constexpr int64_t MIN_PER_5_DAY = 5*1440;
129 constexpr int64_t MIN_PER_7_DAY = 7*1440;
130 constexpr int64_t MIN_PER_WEEK = 10080;
131 constexpr int64_t MIN_PER_10_DAY = 10*1440;
132 constexpr int64_t MIN_PER_15_DAY = 15*1440;
133 constexpr int64_t MIN_PER_30_DAY = 15*1440;
134 constexpr int64_t MIN_PER_MONTH = 40320;
135 constexpr int64_t MAX_MOON_MIN = 42523;
136
137 // Hours and days
138 constexpr int64_t HOURS_PER_DAY = 24;
139 constexpr int64_t DAYS_PER_WEEK = 7;
140 constexpr int64_t DAYS_PER_LEAP_YEAR = 366;
141 constexpr int64_t DAYS_PER_YEAR = 365;
142 constexpr int64_t DAYS_PER_4_YEARS = 1461;
143
144 // Months and years
145 const int64_t MONTHS_PER_YEAR = 12;
146 const int64_t MAX_DAYS_PER_MONTH = 31;
147 const int64_t LEAP_YEAR_PER_100_YEAR = 24;
148 const int64_t LEAP_YEAR_PER_400_YEAR = 97;
149
150 // Epoch and maximum values
151 constexpr int64_t UNIX_EPOCH = 1970;
152 constexpr int64_t OLE_EPOCH = 25569;
153 constexpr int64_t MAX_YEAR = 292277022000LL;
154 constexpr int64_t MIN_YEAR = -2967369602200LL;
155 constexpr int64_t ERROR_YEAR = 9223372036854770000LL;
156 constexpr int64_t MAX_TIMESTAMP = 9223371890843040000LL;
157 constexpr int64_t ERROR_TIMESTAMP = 9223372036854770000LL;
158 constexpr double MAX_OADATE = (std::numeric_limits<double>::max)();
159 constexpr double AVG_DAYS_PER_YEAR = 365.25;
160
162
163}; // namespace time_shield
164
165#endif // _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
constexpr int64_t ERROR_YEAR
Error year value.
constexpr int64_t MIN_PER_15_DAY
Minutes per 15 day.
const int64_t MAX_DAYS_PER_MONTH
Maximum days per month.
constexpr int64_t MIN_PER_30_DAY
Minutes per 30 day.
constexpr int64_t SEC_PER_12_HOUR
Seconds per 12 hour.
constexpr int64_t MIN_1
1 minute
Definition constants.hpp:52
constexpr int64_t SEC_PER_4_HOUR
Seconds per 4 hour.
const int64_t LEAP_YEAR_PER_100_YEAR
Leap years per 100 years.
constexpr int64_t SEC_15
15 seconds
Definition constants.hpp:48
constexpr int64_t HOUR_4
4 hours
Definition constants.hpp:63
constexpr int64_t SEC_PER_10_MIN
Seconds per 10 minute.
constexpr int64_t MIN_PER_HOUR
Minutes per hour.
constexpr int64_t SEC_PER_8_HOUR
Seconds per 8 hour.
constexpr int64_t DAYS_PER_4_YEARS
Days per 4 years.
constexpr int64_t ERROR_TIMESTAMP
Error timestamp value.
constexpr int64_t MIN_15
15 minutes
Definition constants.hpp:56
constexpr double MAX_OADATE
Maximum OLE automation date.
constexpr int64_t SEC_PER_5_MIN
Seconds per 5 minute.
constexpr int64_t MIN_2
2 minutes
Definition constants.hpp:53
constexpr int64_t DAYS_PER_WEEK
Days per week.
constexpr double AVG_DAYS_PER_YEAR
Average days per year.
constexpr int64_t MS_PER_30_SEC
Milliseconds per 30 second.
Definition constants.hpp:81
constexpr int64_t SEC_PER_YEAR
Seconds per year (365 days)
const int64_t LEAP_YEAR_PER_400_YEAR
Leap years per 400 years.
constexpr int64_t SEC_5
5 seconds
Definition constants.hpp:46
constexpr int64_t SEC_PER_FIRST_100_YEARS
Seconds per first 100 years.
constexpr int64_t MIN_10
10 minutes
Definition constants.hpp:55
constexpr int64_t HOUR_24
24 hours
Definition constants.hpp:67
constexpr int64_t MIN_PER_WEEK
Minutes per week.
constexpr int64_t SEC_PER_1_HOUR
Seconds per 1 hour.
const int64_t MONTHS_PER_YEAR
Months per year.
constexpr int64_t DAYS_PER_YEAR
Days per year.
constexpr int64_t MS_PER_8_HOUR
Milliseconds per 8 hour.
Definition constants.hpp:94
constexpr int64_t HOURS_PER_DAY
Hours per day.
constexpr int64_t MS_50
50 milliseconds
Definition constants.hpp:36
constexpr int64_t MS_PER_HALF_HOUR
Milliseconds per half hour.
Definition constants.hpp:88
constexpr int64_t SEC_2
2 seconds
Definition constants.hpp:44
constexpr int64_t HOUR_8
8 hours
Definition constants.hpp:65
constexpr int64_t MS_PER_5_HOUR
Milliseconds per 5 hour.
Definition constants.hpp:93
constexpr int64_t OLE_EPOCH
OLE automation date since UNIX epoch.
constexpr int64_t MS_PER_30_MIN
Milliseconds per 30 minute.
Definition constants.hpp:87
constexpr int64_t MS_PER_2_HOUR
Milliseconds per 2 hour.
Definition constants.hpp:91
constexpr int64_t SEC_PER_100_YEARS
Seconds per 100 years.
constexpr int64_t MIN_PER_2_DAY
Minutes per 2 day.
constexpr int64_t MIN_PER_10_DAY
Minutes per 10 day.
constexpr int64_t MS_PER_5_MIN
Milliseconds per 5 minute.
Definition constants.hpp:84
constexpr int64_t MS_100
100 milliseconds
Definition constants.hpp:37
constexpr int64_t SEC_PER_2_HOUR
Seconds per 2 hour.
constexpr int64_t MAX_YEAR
Maximum representable year.
constexpr int64_t MS_PER_MIN
Milliseconds per minute.
Definition constants.hpp:82
constexpr int64_t SEC_PER_15_MIN
Seconds per 15 minute.
constexpr int64_t MS_PER_15_SEC
Milliseconds per 15 second.
Definition constants.hpp:80
constexpr int64_t MS_5
5 milliseconds
Definition constants.hpp:34
constexpr int64_t SEC_PER_LEAP_YEAR
Seconds per leap year (366 days)
constexpr int64_t AVG_SEC_PER_YEAR
Average seconds per year (365.25 days)
constexpr int64_t MIN_PER_DAY
Minutes per day.
constexpr int64_t MS_750
750 milliseconds
Definition constants.hpp:40
constexpr int64_t SEC_10
10 seconds
Definition constants.hpp:47
constexpr int64_t MIN_5
5 minutes
Definition constants.hpp:54
constexpr int64_t SEC_1
1 second
Definition constants.hpp:43
constexpr int64_t MS_500
500 milliseconds
Definition constants.hpp:39
constexpr int64_t SEC_30
30 seconds
Definition constants.hpp:49
constexpr int64_t DAYS_PER_LEAP_YEAR
Days per leap year.
constexpr int64_t MS_PER_10_MIN
Milliseconds per 10 minute.
Definition constants.hpp:85
constexpr int64_t SEC_PER_HOUR
Seconds per hour.
constexpr int64_t UNIX_EPOCH
Start year of UNIX time.
constexpr int64_t NS_PER_US
Nanoseconds per microsecond.
Definition constants.hpp:70
constexpr int64_t SEC_PER_3_MIN
Seconds per 3 minute.
constexpr int64_t HOUR_2
2 hours
Definition constants.hpp:61
constexpr int64_t NS_PER_MS
Nanoseconds per millisecond.
Definition constants.hpp:71
constexpr int64_t MS_PER_DAY
Milliseconds per day.
Definition constants.hpp:96
constexpr int64_t MIN_PER_1_DAY
Minutes per 1 day.
constexpr int64_t MIN_PER_MONTH
Minutes per month (28 days)
constexpr int64_t MIN_30
30 minutes
Definition constants.hpp:57
constexpr int64_t MS_PER_1_SEC
Milliseconds per 1 second.
Definition constants.hpp:77
constexpr int64_t MAX_SEC_PER_DAY
Maximum seconds per day.
constexpr int64_t MS_PER_SEC
Milliseconds per second.
Definition constants.hpp:76
constexpr int64_t SEC_PER_400_YEARS
Seconds per 400 years.
constexpr int64_t HOUR_3
3 hours
Definition constants.hpp:62
constexpr int64_t SEC_PER_DAY
Seconds per day.
constexpr int64_t HOUR_12
12 hours
Definition constants.hpp:66
constexpr int64_t SEC_PER_1_MIN
Seconds per 1 minute.
constexpr int64_t HOUR_1
1 hour
Definition constants.hpp:60
constexpr int64_t MS_PER_10_SEC
Milliseconds per 10 seconds.
Definition constants.hpp:79
constexpr int64_t SEC_PER_MIN
Seconds per minute.
Definition constants.hpp:99
constexpr int64_t NS_PER_SEC
Nanoseconds per second.
Definition constants.hpp:72
constexpr int64_t MS_PER_4_HOUR
Milliseconds per 4 hour.
Definition constants.hpp:92
constexpr int64_t MS_10
10 milliseconds
Definition constants.hpp:35
constexpr int64_t MS_PER_HOUR
Milliseconds per hour.
Definition constants.hpp:89
constexpr int64_t SEC_PER_5_HOUR
Seconds per 5 hour.
constexpr int64_t MS_PER_12_HOUR
Milliseconds per 12 hour.
Definition constants.hpp:95
constexpr int64_t MIN_PER_5_DAY
Minutes per 5 day.
constexpr int64_t MS_PER_5_SEC
Milliseconds per 5 second.
Definition constants.hpp:78
constexpr int64_t US_PER_SEC
Microseconds per second.
Definition constants.hpp:75
constexpr int64_t MAX_MOON_MIN
Maximum lunar minutes.
constexpr int64_t MS_PER_1_HOUR
Milliseconds per 1 hour.
Definition constants.hpp:90
constexpr int64_t SEC_PER_4_YEARS
Seconds per 4 years.
constexpr int64_t MS_PER_1_MIN
Milliseconds per 1 minute.
Definition constants.hpp:83
constexpr int64_t MIN_YEAR
Minimum representable year.
constexpr int64_t MAX_TIMESTAMP
Maximum timestamp value.
constexpr int64_t HOUR_5
5 hours
Definition constants.hpp:64
constexpr int64_t MS_250
250 milliseconds
Definition constants.hpp:38
constexpr int64_t SEC_3
3 seconds
Definition constants.hpp:45
constexpr int64_t MS_1
1 millisecond
Definition constants.hpp:33
constexpr int64_t SEC_PER_HALF_HOUR
Seconds per half hour.
constexpr int64_t MIN_PER_7_DAY
Minutes per 7 day.
constexpr int64_t MS_PER_15_MIN
Milliseconds per 15 minute.
Definition constants.hpp:86
Main namespace for the Time Shield library.