Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
enums.hpp
Go to the documentation of this file.
1#pragma once
6#ifndef _TIME_SHIELD_ENUMS_HPP_INCLUDED
7#define _TIME_SHIELD_ENUMS_HPP_INCLUDED
8
9#include <string>
10#include <array>
11
12namespace time_shield {
13
31
38
49
55 const char* to_cstr(Weekday value, FormatType format = UPPERCASE_NAME) {
56 static const char* const uppercase_names[] = {
57 "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
58 };
59 static const char* const short_names[] = {
60 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
61 };
62 static const char* const full_names[] = {
63 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
64 };
65 switch (format) {
66 default:
67 case UPPERCASE_NAME:
68 return uppercase_names[static_cast<size_t>(value)];
69 case SHORT_NAME:
70 return short_names[static_cast<size_t>(value)];
71 case FULL_NAME:
72 return full_names[static_cast<size_t>(value)];
73 };
74 }
75
81 const std::string& to_str(Weekday value, FormatType format = UPPERCASE_NAME) {
82 static const std::array<std::string, 7> uppercase_names = {
83 "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
84 };
85 static const std::array<std::string, 7> short_names = {
86 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
87 };
88 static const std::array<std::string, 7> full_names = {
89 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
90 };
91 switch (format) {
92 default:
93 case UPPERCASE_NAME:
94 return uppercase_names[static_cast<size_t>(value)];
95 case SHORT_NAME:
96 return short_names[static_cast<size_t>(value)];
97 case FULL_NAME:
98 return full_names[static_cast<size_t>(value)];
99 };
100 }
101
117
123 const char* to_cstr(Month value, FormatType format = UPPERCASE_NAME) {
124 static const char* const uppercase_names[] = {
125 "",
126 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
127 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
128 };
129 static const char* const short_names[] = {
130 "",
131 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
132 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
133 };
134 static const char* const full_names[] = {
135 "",
136 "January", "February", "March", "April", "May", "June",
137 "July", "August", "September", "October", "November", "December"
138 };
139 switch (format) {
140 default:
141 case UPPERCASE_NAME:
142 return uppercase_names[static_cast<size_t>(value)];
143 case SHORT_NAME:
144 return short_names[static_cast<size_t>(value)];
145 case FULL_NAME:
146 return full_names[static_cast<size_t>(value)];
147 };
148 }
149
155 const std::string& to_str(Month value, FormatType format = UPPERCASE_NAME) {
156 static const std::array<std::string, 13> uppercase_names = {
157 "",
158 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
159 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
160 };
161 static const std::array<std::string, 13> short_names = {
162 "",
163 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
164 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
165 };
166 static const std::array<std::string, 13> full_names = {
167 "",
168 "January", "February", "March", "April", "May", "June",
169 "July", "August", "September", "October", "November", "December"
170 };
171 switch (format) {
172 default:
173 case UPPERCASE_NAME:
174 return uppercase_names[static_cast<size_t>(value)];
175 case SHORT_NAME:
176 return short_names[static_cast<size_t>(value)];
177 case FULL_NAME:
178 return full_names[static_cast<size_t>(value)];
179 };
180 }
181
194
200 const char* to_cstr(TimeZone value, FormatType format = UPPERCASE_NAME) {
201 static const char* const uppercase_names[] = {
202 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "UNKNOWN"
203 };
204 static const char* const short_names[] = {
205 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "Unknown"
206 };
207 static const char* const full_names[] = {
208 "Greenwich Mean Time", "Coordinated Universal Time", "Eastern European Time",
209 "Central European Time", "Western European Time", "Eastern European Summer Time",
210 "Central European Summer Time", "Western European Summer Time", "Unknown Time Zone"
211 };
212 switch (format) {
213 default:
214 case UPPERCASE_NAME:
215 return uppercase_names[static_cast<size_t>(value)];
216 case SHORT_NAME:
217 return short_names[static_cast<size_t>(value)];
218 case FULL_NAME:
219 return full_names[static_cast<size_t>(value)];
220 }
221 }
222
228 const std::string& to_str(TimeZone value, FormatType format = UPPERCASE_NAME) {
229 static const std::array<std::string, 9> uppercase_names = {
230 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "UNKNOWN"
231 };
232 static const std::array<std::string, 9> short_names = {
233 "gmt", "utc", "eet", "cet", "wet", "eest", "cest", "west", "unknown"
234 };
235 static const std::array<std::string, 9> full_names = {
236 "Greenwich Mean Time", "Coordinated Universal Time", "Eastern European Time",
237 "Central European Time", "Western European Time", "Eastern European Summer Time",
238 "Central European Summer Time", "Western European Summer Time", "Unknown Time Zone"
239 };
240 switch (format) {
241 default:
242 case UPPERCASE_NAME:
243 return uppercase_names[static_cast<size_t>(value)];
244 case SHORT_NAME:
245 return short_names[static_cast<size_t>(value)];
246 case FULL_NAME:
247 return full_names[static_cast<size_t>(value)];
248 }
249 }
250
262
275
277
278}; // namespace time_shield
279
280#endif // _TIME_SHIELD_ENUMS_HPP_INCLUDED
MoonPhase
Enumeration of the moon phases.
Definition enums.hpp:252
TimeFormatType
Enumeration of time format types.
Definition enums.hpp:264
FormatType
Enumeration of the format options for representing a weekday or month.
Definition enums.hpp:33
Month
Enumeration of the months of the year.
Definition enums.hpp:103
TimeZone
Enumeration of the time zones.
Definition enums.hpp:183
const char * to_cstr(Weekday value, FormatType format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
Definition enums.hpp:55
Weekday
Enumeration of the days of the week.
Definition enums.hpp:40
const std::string & to_str(Weekday value, FormatType format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
Definition enums.hpp:81
@ LAST_QUARTER
Last Quarter Moon.
Definition enums.hpp:258
@ NEW_MOON
New Moon.
Definition enums.hpp:260
@ WAXING_CRESCENT
Waxing Crescent Moon.
Definition enums.hpp:253
@ FIRST_QUARTER
First Quarter Moon.
Definition enums.hpp:254
@ WANING_CRESCENT
Waning Crescent Moon.
Definition enums.hpp:259
@ WANING_GIBBOUS
Waning Gibbous Moon.
Definition enums.hpp:257
@ WAXING_GIBBOUS
Waxing Gibbous Moon.
Definition enums.hpp:255
@ FULL_MOON
Full Moon.
Definition enums.hpp:256
@ AMERICAN_MONTH_DAY
American date format (e.g., "06/06/2024")
Definition enums.hpp:270
@ EUROPEAN_TIME
European time format (e.g., "12:30")
Definition enums.hpp:273
@ MQL5_FULL
MQL5 time format (e.g., "2024.06.06 12:30:45")
Definition enums.hpp:267
@ ISO8601_NO_TZ
ISO8601 format without time zone (e.g., "2024-06-06T12:30:45")
Definition enums.hpp:266
@ MQL5_TIME_ONLY
MQL5 time format (e.g., "12:30:45")
Definition enums.hpp:269
@ MQL5_DATE_ONLY
MQL5 date format (e.g., "2024.06.06")
Definition enums.hpp:268
@ AMERICAN_TIME
American time format (e.g., "12:30 PM")
Definition enums.hpp:272
@ EUROPEAN_MONTH_DAY
European date format (e.g., "06.06.2024")
Definition enums.hpp:271
@ ISO8601_WITH_TZ
ISO8601 format with time zone (e.g., "2024-06-06T12:30:45+03:00")
Definition enums.hpp:265
@ SHORT_NAME
Short name.
Definition enums.hpp:35
@ UPPERCASE_NAME
Uppercase short name.
Definition enums.hpp:34
@ FULL_NAME
Full name.
Definition enums.hpp:36
@ AUG
August.
Definition enums.hpp:111
@ NOV
November.
Definition enums.hpp:114
@ MAY
May.
Definition enums.hpp:108
@ DEC
December.
Definition enums.hpp:115
@ JAN
January.
Definition enums.hpp:104
@ APR
April.
Definition enums.hpp:107
@ FEB
February.
Definition enums.hpp:105
@ OCT
October.
Definition enums.hpp:113
@ JUL
July.
Definition enums.hpp:110
@ JUN
June.
Definition enums.hpp:109
@ MAR
March.
Definition enums.hpp:106
@ SEP
September.
Definition enums.hpp:112
@ UTC
Coordinated Universal Time.
Definition enums.hpp:185
@ GMT
Greenwich Mean Time.
Definition enums.hpp:184
@ CET
Central European Time.
Definition enums.hpp:187
@ EET
Eastern European Time.
Definition enums.hpp:186
@ CEST
Central European Summer Time.
Definition enums.hpp:190
@ WEST
Western European Summer Time.
Definition enums.hpp:191
@ WET
Western European Time.
Definition enums.hpp:188
@ UNKNOWN
Unknown Time Zone.
Definition enums.hpp:192
@ EEST
Eastern European Summer Time.
Definition enums.hpp:189
@ WED
Wednesday.
Definition enums.hpp:44
@ MON
Monday.
Definition enums.hpp:42
@ SUN
Sunday.
Definition enums.hpp:41
@ TUE
Tuesday.
Definition enums.hpp:43
@ SAT
Saturday.
Definition enums.hpp:47
@ FRI
Friday.
Definition enums.hpp:46
@ THU
Thursday.
Definition enums.hpp:45
Main namespace for the Time Shield library.
Definition constants.hpp:12