Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
constants.mqh
Go to the documentation of this file.
1//+------------------------------------------------------------------+
2//| constants.mqh |
3//| Time Shield - MQL5 Constants |
4//| Copyright 2025, NewYaroslav |
5//| https://github.com/NewYaroslav/time-shield-cpp |
6//+------------------------------------------------------------------+
7#ifndef __TIME_SHIELD_CONSTANTS_MQH__
8#define __TIME_SHIELD_CONSTANTS_MQH__
9
15
16#property copyright "Copyright 2025, NewYaroslav"
17#property link "https://github.com/NewYaroslav/time-shield-cpp"
18#property strict
19
20namespace time_shield {
21
38
39 // Common millisecond durations
40 const long MS_1 = 1;
41 const long MS_5 = 5;
42 const long MS_10 = 10;
43 const long MS_50 = 50;
44 const long MS_100 = 100;
45 const long MS_250 = 250;
46 const long MS_500 = 500;
47 const long MS_750 = 750;
48
49 // Common second durations
50 const long SEC_1 = 1;
51 const long SEC_2 = 2;
52 const long SEC_3 = 3;
53 const long SEC_5 = 5;
54 const long SEC_10 = 10;
55 const long SEC_15 = 15;
56 const long SEC_30 = 30;
57
58 // Common minute durations
59 const long MIN_1 = 1;
60 const long MIN_2 = 2;
61 const long MIN_5 = 5;
62 const long MIN_10 = 10;
63 const long MIN_15 = 15;
64 const long MIN_30 = 30;
65
66 // Common hour durations
67 const long HOUR_1 = 1;
68 const long HOUR_2 = 2;
69 const long HOUR_3 = 3;
70 const long HOUR_4 = 4;
71 const long HOUR_5 = 5;
72 const long HOUR_8 = 8;
73 const long HOUR_12 = 12;
74 const long HOUR_24 = 24;
75
76 // Nanoseconds and microseconds
77 const long NS_PER_US = 1000;
78 const long NS_PER_MS = 1000000;
79 const long NS_PER_SEC = 1000000000;
80
81 // Microseconds and milliseconds
82 const long US_PER_SEC = 1000000;
83 const long MS_PER_SEC = 1000;
84 const long MS_PER_1_SEC = 1000;
85 const long MS_PER_5_SEC = 5000;
86 const long MS_PER_10_SEC = 10000;
87 const long MS_PER_15_SEC = 15000;
88 const long MS_PER_30_SEC = 30000;
89 const long MS_PER_MIN = 60000;
90 const long MS_PER_1_MIN = 60000;
91 const long MS_PER_5_MIN = 300000;
92 const long MS_PER_10_MIN = 600000;
93 const long MS_PER_15_MIN = 900000;
94 const long MS_PER_30_MIN = 1800000;
95 const long MS_PER_HALF_HOUR = 1800000;
96 const long MS_PER_HOUR = 3600000;
97 const long MS_PER_1_HOUR = 3600000;
98 const long MS_PER_2_HOUR = 7200000;
99 const long MS_PER_4_HOUR = 14400000;
100 const long MS_PER_5_HOUR = 18000000;
101 const long MS_PER_8_HOUR = 28800000;
102 const long MS_PER_12_HOUR = 43200000;
103 const long MS_PER_DAY = 86400000;
104
105 // Seconds
106 const long SEC_PER_MIN = 60;
107 const long SEC_PER_1_MIN = 60;
108 const long SEC_PER_3_MIN = 180;
109 const long SEC_PER_5_MIN = 300;
110 const long SEC_PER_10_MIN = 600;
111 const long SEC_PER_15_MIN = 900;
112 const long SEC_PER_HALF_HOUR = 1800;
113 const long SEC_PER_HOUR = 3600;
114 const long SEC_PER_1_HOUR = 3600;
115 const long SEC_PER_2_HOUR = 7200;
116 const long SEC_PER_4_HOUR = 14400;
117 const long SEC_PER_5_HOUR = 18000;
118 const long SEC_PER_8_HOUR = 28800;
119 const long SEC_PER_12_HOUR = 43200;
120 const long SEC_PER_DAY = 86400;
121 const long SEC_PER_YEAR = 31536000;
122 const long AVG_SEC_PER_YEAR = 31557600;
123 const long SEC_PER_LEAP_YEAR = 31622400;
124 const long SEC_PER_4_YEARS = 126230400;
125 const long SEC_PER_FIRST_100_YEARS = 3155760000;
126 const long SEC_PER_100_YEARS = 3155673600;
127 const long SEC_PER_400_YEARS = 12622780800;
128 const long MAX_SEC_PER_DAY = 86399;
129
130 // Minutes
131 const long MIN_PER_HOUR = 60;
132 const long MIN_PER_DAY = 1440;
133 const long MIN_PER_1_DAY = 1440;
134 const long MIN_PER_2_DAY = 2*1440;
135 const long MIN_PER_5_DAY = 5*1440;
136 const long MIN_PER_7_DAY = 7*1440;
137 const long MIN_PER_WEEK = 10080;
138 const long MIN_PER_10_DAY = 10*1440;
139 const long MIN_PER_15_DAY = 15*1440;
140 const long MIN_PER_30_DAY = 15*1440;
141 const long MIN_PER_MONTH = 40320;
142 const long MAX_MOON_MIN = 42523;
143
144 // Hours and days
145 const long HOURS_PER_DAY = 24;
146 const long DAYS_PER_WEEK = 7;
147 const long DAYS_PER_LEAP_YEAR = 366;
148 const long DAYS_PER_YEAR = 365;
149 const long DAYS_PER_4_YEARS = 1461;
150
151 // Months and years
152 const long MONTHS_PER_YEAR = 12;
153 const long MAX_DAYS_PER_MONTH = 31;
154 const long LEAP_YEAR_PER_100_YEAR = 24;
155 const long LEAP_YEAR_PER_400_YEAR = 97;
156
157 // Epoch and maximum values
158 const long UNIX_EPOCH = 1970;
159 const long OLE_EPOCH = 25569;
160 const long MAX_YEAR = 292277022000;
161 const long MIN_YEAR = -2967369602200;
162 const long ERROR_YEAR = 9223372036854770000;
163 const long MAX_TIMESTAMP = 9223371890843040000;
164 const long ERROR_TIMESTAMP = 9223372036854770000;
165 const double MAX_OADATE = 1.7976931348623158e+308;
166 const double AVG_DAYS_PER_YEAR = 365.25;
167
169
170}; // namespace time_shield
171
172#endif // __TIME_SHIELD_CONSTANTS_MQH__
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.