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
20
31
37 const char* to_cstr(const Weekday &value, const FormatType &format = UPPERCASE_NAME) {
38 static const char* const uppercase_names[] = {
39 "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
40 };
41 static const char* const short_names[] = {
42 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
43 };
44 static const char* const full_names[] = {
45 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
46 };
47 switch (format) {
48 default:
49 case UPPERCASE_NAME:
50 return uppercase_names[static_cast<size_t>(value)];
51 case SHORT_NAME:
52 return short_names[static_cast<size_t>(value)];
53 case FULL_NAME:
54 return full_names[static_cast<size_t>(value)];
55 };
56 }
57
63 const std::string& to_str(const Weekday &value, const FormatType &format = UPPERCASE_NAME) {
64 static const std::array<std::string, 7> uppercase_names = {
65 "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
66 };
67 static const std::array<std::string, 7> short_names = {
68 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
69 };
70 static const std::array<std::string, 7> full_names = {
71 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
72 };
73 switch (format) {
74 default:
75 case UPPERCASE_NAME:
76 return uppercase_names[static_cast<size_t>(value)];
77 case SHORT_NAME:
78 return short_names[static_cast<size_t>(value)];
79 case FULL_NAME:
80 return full_names[static_cast<size_t>(value)];
81 };
82 }
83
99
105 const char* to_cstr(const Month &value, const FormatType &format = UPPERCASE_NAME) {
106 static const char* const uppercase_names[] = {
107 "",
108 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
109 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
110 };
111 static const char* const short_names[] = {
112 "",
113 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
114 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
115 };
116 static const char* const full_names[] = {
117 "",
118 "January", "February", "March", "April", "May", "June",
119 "July", "August", "September", "October", "November", "December"
120 };
121 switch (format) {
122 default:
123 case UPPERCASE_NAME:
124 return uppercase_names[static_cast<size_t>(value)];
125 case SHORT_NAME:
126 return short_names[static_cast<size_t>(value)];
127 case FULL_NAME:
128 return full_names[static_cast<size_t>(value)];
129 };
130 }
131
137 const std::string& to_str(const Month &value, const FormatType &format = UPPERCASE_NAME) {
138 static const std::array<std::string, 13> uppercase_names = {
139 "",
140 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
141 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
142 };
143 static const std::array<std::string, 13> short_names = {
144 "",
145 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
146 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
147 };
148 static const std::array<std::string, 13> full_names = {
149 "",
150 "January", "February", "March", "April", "May", "June",
151 "July", "August", "September", "October", "November", "December"
152 };
153 switch (format) {
154 default:
155 case UPPERCASE_NAME:
156 return uppercase_names[static_cast<size_t>(value)];
157 case SHORT_NAME:
158 return short_names[static_cast<size_t>(value)];
159 case FULL_NAME:
160 return full_names[static_cast<size_t>(value)];
161 };
162 }
163
176
182 const char* to_cstr(const TimeZone &value, const FormatType &format = UPPERCASE_NAME) {
183 static const char* const uppercase_names[] = {
184 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "UNKNOWN"
185 };
186 static const char* const short_names[] = {
187 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "Unknown"
188 };
189 static const char* const full_names[] = {
190 "Greenwich Mean Time", "Coordinated Universal Time", "Eastern European Time",
191 "Central European Time", "Western European Time", "Eastern European Summer Time",
192 "Central European Summer Time", "Western European Summer Time", "Unknown Time Zone"
193 };
194 switch (format) {
195 default:
196 case UPPERCASE_NAME:
197 return uppercase_names[static_cast<size_t>(value)];
198 case SHORT_NAME:
199 return short_names[static_cast<size_t>(value)];
200 case FULL_NAME:
201 return full_names[static_cast<size_t>(value)];
202 }
203 }
204
210 const std::string& to_str(const TimeZone &value, const FormatType &format = UPPERCASE_NAME) {
211 static const std::array<std::string, 9> uppercase_names = {
212 "GMT", "UTC", "EET", "CET", "WET", "EEST", "CEST", "WEST", "UNKNOWN"
213 };
214 static const std::array<std::string, 9> short_names = {
215 "gmt", "utc", "eet", "cet", "wet", "eest", "cest", "west", "unknown"
216 };
217 static const std::array<std::string, 9> full_names = {
218 "Greenwich Mean Time", "Coordinated Universal Time", "Eastern European Time",
219 "Central European Time", "Western European Time", "Eastern European Summer Time",
220 "Central European Summer Time", "Western European Summer Time", "Unknown Time Zone"
221 };
222 switch (format) {
223 default:
224 case UPPERCASE_NAME:
225 return uppercase_names[static_cast<size_t>(value)];
226 case SHORT_NAME:
227 return short_names[static_cast<size_t>(value)];
228 case FULL_NAME:
229 return full_names[static_cast<size_t>(value)];
230 }
231 }
232
244
257
258}; // namespace time_shield
259
260#endif // _TIME_SHIELD_ENUMS_HPP_INCLUDED
Main namespace for the Time Shield library.
Definition constants.hpp:12
const std::string & to_str(const Weekday &value, const FormatType &format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
Definition enums.hpp:63
MoonPhase
Enumeration of the moon phases.
Definition enums.hpp:234
@ LAST_QUARTER
Last Quarter Moon.
Definition enums.hpp:240
@ NEW_MOON
New Moon.
Definition enums.hpp:242
@ WAXING_CRESCENT
Waxing Crescent Moon.
Definition enums.hpp:235
@ FIRST_QUARTER
First Quarter Moon.
Definition enums.hpp:236
@ WANING_CRESCENT
Waning Crescent Moon.
Definition enums.hpp:241
@ WANING_GIBBOUS
Waning Gibbous Moon.
Definition enums.hpp:239
@ WAXING_GIBBOUS
Waxing Gibbous Moon.
Definition enums.hpp:237
@ FULL_MOON
Full Moon.
Definition enums.hpp:238
const char * to_cstr(const Weekday &value, const FormatType &format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
Definition enums.hpp:37
TimeFormatType
Enumeration of time format types.
Definition enums.hpp:246
@ AMERICAN_MONTH_DAY
American date format (e.g., "06/06/2024")
Definition enums.hpp:252
@ EUROPEAN_TIME
European time format (e.g., "12:30")
Definition enums.hpp:255
@ MQL5_FULL
MQL5 time format (e.g., "2024.06.06 12:30:45")
Definition enums.hpp:249
@ ISO8601_NO_TZ
ISO8601 format without time zone (e.g., "2024-06-06T12:30:45")
Definition enums.hpp:248
@ MQL5_TIME_ONLY
MQL5 time format (e.g., "12:30:45")
Definition enums.hpp:251
@ MQL5_DATE_ONLY
MQL5 date format (e.g., "2024.06.06")
Definition enums.hpp:250
@ AMERICAN_TIME
American time format (e.g., "12:30 PM")
Definition enums.hpp:254
@ EUROPEAN_MONTH_DAY
European date format (e.g., "06.06.2024")
Definition enums.hpp:253
@ ISO8601_WITH_TZ
ISO8601 format with time zone (e.g., "2024-06-06T12:30:45+03:00")
Definition enums.hpp:247
FormatType
Enumeration of the format options for representing a weekday or month.
Definition enums.hpp:15
@ SHORT_NAME
Short name.
Definition enums.hpp:17
@ UPPERCASE_NAME
Uppercase short name.
Definition enums.hpp:16
@ FULL_NAME
Full name.
Definition enums.hpp:18
Month
Enumeration of the months of the year.
Definition enums.hpp:85
@ AUG
August.
Definition enums.hpp:93
@ NOV
November.
Definition enums.hpp:96
@ MAY
May.
Definition enums.hpp:90
@ DEC
December.
Definition enums.hpp:97
@ JAN
January.
Definition enums.hpp:86
@ APR
April.
Definition enums.hpp:89
@ FEB
February.
Definition enums.hpp:87
@ OCT
October.
Definition enums.hpp:95
@ JUL
July.
Definition enums.hpp:92
@ JUN
June.
Definition enums.hpp:91
@ MAR
March.
Definition enums.hpp:88
@ SEP
September.
Definition enums.hpp:94
TimeZone
Enumeration of the time zones.
Definition enums.hpp:165
@ UTC
Coordinated Universal Time.
Definition enums.hpp:167
@ GMT
Greenwich Mean Time.
Definition enums.hpp:166
@ CET
Central European Time.
Definition enums.hpp:169
@ EET
Eastern European Time.
Definition enums.hpp:168
@ CEST
Central European Summer Time.
Definition enums.hpp:172
@ WEST
Western European Summer Time.
Definition enums.hpp:173
@ WET
Western European Time.
Definition enums.hpp:170
@ UNKNOWN
Unknown Time Zone.
Definition enums.hpp:174
@ EEST
Eastern European Summer Time.
Definition enums.hpp:171
Weekday
Enumeration of the days of the week.
Definition enums.hpp:22
@ WED
Wednesday.
Definition enums.hpp:26
@ MON
Monday.
Definition enums.hpp:24
@ SUN
Sunday.
Definition enums.hpp:23
@ TUE
Tuesday.
Definition enums.hpp:25
@ SAT
Saturday.
Definition enums.hpp:29
@ FRI
Friday.
Definition enums.hpp:28
@ THU
Thursday.
Definition enums.hpp:27