Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
enums.mqh
Go to the documentation of this file.
1//+------------------------------------------------------------------+
2//| enums.mqh |
3//| Time Shield - MQL5 Enumerations |
4//| Copyright 2025, NewYaroslav |
5//| https://github.com/NewYaroslav/time-shield-cpp |
6//+------------------------------------------------------------------+
7#ifndef __TIME_SHIELD_ENUMS_MQH__
8#define __TIME_SHIELD_ENUMS_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
24
27 UPPERCASE_NAME = 0,
29 FULL_NAME,
30 };
31
33 enum Weekday {
34 SUN = 0,
35 MON,
36 TUE,
37 WED,
38 THU,
39 FRI,
40 SAT
41 };
42
49 static const string uppercase_names[] = {
50 "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
51 };
52 static const string short_names[] = {
53 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
54 };
55 static const string full_names[] = {
56 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
57 };
58 switch(format) {
59 default:
60 case UPPERCASE_NAME:
61 return uppercase_names[(int)value];
62 case SHORT_NAME:
63 return short_names[(int)value];
64 case FULL_NAME:
65 return full_names[(int)value];
66 }
67 return "";
68 }
69
71 enum Month {
72 JAN = 1,
73 FEB,
74 MAR,
75 APR,
76 MAY,
77 JUN,
78 JUL,
79 AUG,
80 SEP,
81 OCT,
82 NOV,
83 DEC
84 };
85
91 string to_month_str(Month value, FormatType format = UPPERCASE_NAME) {
92 static const string uppercase_names[] = {
93 "",
94 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
95 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
96 };
97 static const string short_names[] = {
98 "",
99 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
100 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
101 };
102 static const string full_names[] = {
103 "",
104 "January", "February", "March", "April", "May", "June",
105 "July", "August", "September", "October", "November", "December"
106 };
107 switch(format) {
108 default:
109 case UPPERCASE_NAME:
110 return uppercase_names[(int)value];
111 case SHORT_NAME:
112 return short_names[(int)value];
113 case FULL_NAME:
114 return full_names[(int)value];
115 }
116 return "";
117 }
118
120 enum TimeZone {
121 GMT,
122 UTC,
123 EET,
124 CET,
125 WET,
126 EEST,
127 CEST,
128 WEST,
129 UNKNOWN
130 };
131
138 static const string uppercase_names[] = {
139 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "UNKNOWN"
140 };
141 static const string short_names[] = {
142 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "Unknown"
143 };
144 static const string full_names[] = {
145 "Greenwich Mean Time", "Coordinated Universal Time", "Eastern European Time",
146 "Central European Time", "Western European Time", "Eastern European Summer Time",
147 "Central European Summer Time", "Western European Summer Time", "Unknown Time Zone"
148 };
149 switch(format) {
150 default:
151 case UPPERCASE_NAME:
152 return uppercase_names[(int)value];
153 case SHORT_NAME:
154 return short_names[(int)value];
155 case FULL_NAME:
156 return full_names[(int)value];
157 }
158 return "";
159 }
160
172
185
187
188 string to_str(Weekday value, FormatType format = UPPERCASE_NAME) {
189 return to_weekday_str(value, format);
190 }
191
192 string to_str(Month value, FormatType format = UPPERCASE_NAME) {
193 return to_month_str(value, format);
194 }
195
196 string to_str(TimeZone value, FormatType format = UPPERCASE_NAME) {
197 return to_timezone_str(value, format);
198 }
199
200}; // namespace time_shield
201
202#endif // __TIME_SHIELD_ENUMS_MQH__
string to_timezone_str(TimeZone value, FormatType format=UPPERCASE_NAME)
Converts a TimeZone enum value to a string.
Definition enums.mqh:137
string to_weekday_str(Weekday value, FormatType format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
Definition enums.mqh:48
string to_month_str(Month value, FormatType format=UPPERCASE_NAME)
Converts a Month enum value to a string.
Definition enums.mqh:91
@ SHORT_NAME
Short name.
Definition enums.hpp:20
@ FULL_NAME
Full name.
Definition enums.hpp:21
@ UPPERCASE_NAME
Uppercase short name.
Definition enums.hpp:19
const std::string & to_str(Weekday value, FormatType format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
Definition enums.hpp:69
@ FULL_MOON
Full Moon.
Definition enums.hpp:251
@ NEW_MOON
New Moon.
Definition enums.hpp:255
@ WAXING_GIBBOUS
Waxing Gibbous Moon.
Definition enums.hpp:250
@ FIRST_QUARTER
First Quarter Moon.
Definition enums.hpp:249
@ WANING_CRESCENT
Waning Crescent Moon.
Definition enums.hpp:254
@ WAXING_CRESCENT
Waxing Crescent Moon.
Definition enums.hpp:248
@ LAST_QUARTER
Last Quarter Moon.
Definition enums.hpp:253
@ WANING_GIBBOUS
Waning Gibbous Moon.
Definition enums.hpp:252
@ EUROPEAN_TIME
European time format (e.g., "12:30")
Definition enums.hpp:269
@ ISO8601_NO_TZ
ISO8601 format without time zone (e.g., "2024-06-06T12:30:45")
Definition enums.hpp:262
@ AMERICAN_MONTH_DAY
American date format (e.g., "06/06/2024")
Definition enums.hpp:266
@ ISO8601_WITH_TZ
ISO8601 format with time zone (e.g., "2024-06-06T12:30:45+03:00")
Definition enums.hpp:261
@ MQL5_FULL
MQL5 time format (e.g., "2024.06.06 12:30:45")
Definition enums.hpp:263
@ MQL5_DATE_ONLY
MQL5 date format (e.g., "2024.06.06")
Definition enums.hpp:264
@ MQL5_TIME_ONLY
MQL5 time format (e.g., "12:30:45")
Definition enums.hpp:265
@ AMERICAN_TIME
American time format (e.g., "12:30 PM")
Definition enums.hpp:268
@ EUROPEAN_MONTH_DAY
European date format (e.g., "06.06.2024")
Definition enums.hpp:267
@ SEP
September.
Definition enums.hpp:101
@ OCT
October.
Definition enums.hpp:102
@ FEB
February.
Definition enums.hpp:94
@ JUN
June.
Definition enums.hpp:98
@ MAY
May.
Definition enums.hpp:97
@ NOV
November.
Definition enums.hpp:103
@ MAR
March.
Definition enums.hpp:95
@ AUG
August.
Definition enums.hpp:100
@ DEC
December.
Definition enums.hpp:104
@ APR
April.
Definition enums.hpp:96
@ JAN
January.
Definition enums.hpp:93
@ JUL
July.
Definition enums.hpp:99
@ EET
Eastern European Time.
Definition enums.hpp:178
@ CEST
Central European Summer Time.
Definition enums.hpp:182
@ WEST
Western European Summer Time.
Definition enums.hpp:183
@ WET
Western European Time.
Definition enums.hpp:180
@ UNKNOWN
Unknown Time Zone.
Definition enums.hpp:184
@ UTC
Coordinated Universal Time.
Definition enums.hpp:177
@ GMT
Greenwich Mean Time.
Definition enums.hpp:176
@ EEST
Eastern European Summer Time.
Definition enums.hpp:181
@ CET
Central European Time.
Definition enums.hpp:179
@ TUE
Tuesday.
Definition enums.hpp:29
@ SUN
Sunday.
Definition enums.hpp:27
@ MON
Monday.
Definition enums.hpp:28
@ FRI
Friday.
Definition enums.hpp:32
@ SAT
Saturday.
Definition enums.hpp:33
@ THU
Thursday.
Definition enums.hpp:31
@ WED
Wednesday.
Definition enums.hpp:30
Main namespace for the Time Shield library.