1/**************************************************************************/
2/* time.cpp */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#include "time.h"
32
33#include "core/os/os.h"
34
35#define UNIX_EPOCH_YEAR_AD 1970 // 1970
36#define SECONDS_PER_DAY (24 * 60 * 60) // 86400
37#define IS_LEAP_YEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400)))
38#define YEAR_SIZE(year) (IS_LEAP_YEAR(year) ? 366 : 365)
39
40#define YEAR_KEY "year"
41#define MONTH_KEY "month"
42#define DAY_KEY "day"
43#define WEEKDAY_KEY "weekday"
44#define HOUR_KEY "hour"
45#define MINUTE_KEY "minute"
46#define SECOND_KEY "second"
47#define DST_KEY "dst"
48
49// Table of number of days in each month (for regular year and leap year).
50static const uint8_t MONTH_DAYS_TABLE[2][12] = {
51 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
52 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
53};
54
55#define UNIX_TIME_TO_HMS \
56 uint8_t hour, minute, second; \
57 { \
58 /* The time of the day (in seconds since start of day). */ \
59 uint32_t day_clock = Math::posmod(p_unix_time_val, SECONDS_PER_DAY); \
60 /* On x86 these 4 lines can be optimized to only 2 divisions. */ \
61 second = day_clock % 60; \
62 day_clock /= 60; \
63 minute = day_clock % 60; \
64 hour = day_clock / 60; \
65 }
66
67#define UNIX_TIME_TO_YMD \
68 int64_t year; \
69 Month month; \
70 uint8_t day; \
71 /* The day number since Unix epoch (0-index). Days before 1970 are negative. */ \
72 int64_t day_number = Math::floor(p_unix_time_val / (double)SECONDS_PER_DAY); \
73 { \
74 int64_t day_number_copy = day_number; \
75 year = UNIX_EPOCH_YEAR_AD; \
76 uint8_t month_zero_index = 0; \
77 while (day_number_copy >= YEAR_SIZE(year)) { \
78 day_number_copy -= YEAR_SIZE(year); \
79 year++; \
80 } \
81 while (day_number_copy < 0) { \
82 year--; \
83 day_number_copy += YEAR_SIZE(year); \
84 } \
85 /* After the above, day_number now represents the day of the year (0-index). */ \
86 while (day_number_copy >= MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month_zero_index]) { \
87 day_number_copy -= MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month_zero_index]; \
88 month_zero_index++; \
89 } \
90 /* After the above, day_number now represents the day of the month (0-index). */ \
91 month = (Month)(month_zero_index + 1); \
92 day = day_number_copy + 1; \
93 }
94
95#define VALIDATE_YMDHMS(ret) \
96 ERR_FAIL_COND_V_MSG(month == 0, ret, "Invalid month value of: " + itos(month) + ", months are 1-indexed and cannot be 0. See the Time.Month enum for valid values."); \
97 ERR_FAIL_COND_V_MSG(month < 0, ret, "Invalid month value of: " + itos(month) + "."); \
98 ERR_FAIL_COND_V_MSG(month > 12, ret, "Invalid month value of: " + itos(month) + ". See the Time.Month enum for valid values."); \
99 ERR_FAIL_COND_V_MSG(hour > 23, ret, "Invalid hour value of: " + itos(hour) + "."); \
100 ERR_FAIL_COND_V_MSG(hour < 0, ret, "Invalid hour value of: " + itos(hour) + "."); \
101 ERR_FAIL_COND_V_MSG(minute > 59, ret, "Invalid minute value of: " + itos(minute) + "."); \
102 ERR_FAIL_COND_V_MSG(minute < 0, ret, "Invalid minute value of: " + itos(minute) + "."); \
103 ERR_FAIL_COND_V_MSG(second > 59, ret, "Invalid second value of: " + itos(second) + " (leap seconds are not supported)."); \
104 ERR_FAIL_COND_V_MSG(second < 0, ret, "Invalid second value of: " + itos(second) + "."); \
105 ERR_FAIL_COND_V_MSG(day == 0, ret, "Invalid day value of: " + itos(day) + ", days are 1-indexed and cannot be 0."); \
106 ERR_FAIL_COND_V_MSG(day < 0, ret, "Invalid day value of: " + itos(day) + "."); \
107 /* Do this check after month is tested as valid. */ \
108 uint8_t days_in_this_month = MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month - 1]; \
109 ERR_FAIL_COND_V_MSG(day > days_in_this_month, ret, "Invalid day value of: " + itos(day) + " which is larger than the maximum for this month, " + itos(days_in_this_month) + ".");
110
111#define YMD_TO_DAY_NUMBER \
112 /* The day number since Unix epoch (0-index). Days before 1970 are negative. */ \
113 int64_t day_number = day - 1; \
114 /* Add the days in the months to day_number. */ \
115 for (int i = 0; i < month - 1; i++) { \
116 day_number += MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][i]; \
117 } \
118 /* Add the days in the years to day_number. */ \
119 if (year >= UNIX_EPOCH_YEAR_AD) { \
120 for (int64_t iyear = UNIX_EPOCH_YEAR_AD; iyear < year; iyear++) { \
121 day_number += YEAR_SIZE(iyear); \
122 } \
123 } else { \
124 for (int64_t iyear = UNIX_EPOCH_YEAR_AD - 1; iyear >= year; iyear--) { \
125 day_number -= YEAR_SIZE(iyear); \
126 } \
127 }
128
129#define PARSE_ISO8601_STRING(ret) \
130 int64_t year = UNIX_EPOCH_YEAR_AD; \
131 Month month = MONTH_JANUARY; \
132 int day = 1; \
133 int hour = 0; \
134 int minute = 0; \
135 int second = 0; \
136 { \
137 bool has_date = false, has_time = false; \
138 String date, time; \
139 if (p_datetime.find_char('T') > 0) { \
140 has_date = has_time = true; \
141 PackedStringArray array = p_datetime.split("T"); \
142 ERR_FAIL_COND_V_MSG(array.size() < 2, ret, "Invalid ISO 8601 date/time string."); \
143 date = array[0]; \
144 time = array[1]; \
145 } else if (p_datetime.find_char(' ') > 0) { \
146 has_date = has_time = true; \
147 PackedStringArray array = p_datetime.split(" "); \
148 ERR_FAIL_COND_V_MSG(array.size() < 2, ret, "Invalid ISO 8601 date/time string."); \
149 date = array[0]; \
150 time = array[1]; \
151 } else if (p_datetime.find_char('-', 1) > 0) { \
152 has_date = true; \
153 date = p_datetime; \
154 } else if (p_datetime.find_char(':') > 0) { \
155 has_time = true; \
156 time = p_datetime; \
157 } \
158 /* Set the variables from the contents of the string. */ \
159 if (has_date) { \
160 PackedInt32Array array = date.split_ints("-", false); \
161 ERR_FAIL_COND_V_MSG(array.size() < 3, ret, "Invalid ISO 8601 date string."); \
162 year = array[0]; \
163 month = (Month)array[1]; \
164 day = array[2]; \
165 /* Handle negative years. */ \
166 if (p_datetime.find_char('-') == 0) { \
167 year *= -1; \
168 } \
169 } \
170 if (has_time) { \
171 PackedInt32Array array = time.split_ints(":", false); \
172 ERR_FAIL_COND_V_MSG(array.size() < 3, ret, "Invalid ISO 8601 time string."); \
173 hour = array[0]; \
174 minute = array[1]; \
175 second = array[2]; \
176 } \
177 }
178
179#define EXTRACT_FROM_DICTIONARY \
180 /* Get all time values from the dictionary. If it doesn't exist, set the */ \
181 /* values to the default values for Unix epoch (1970-01-01 00:00:00). */ \
182 int64_t year = p_datetime.has(YEAR_KEY) ? int64_t(p_datetime[YEAR_KEY]) : UNIX_EPOCH_YEAR_AD; \
183 Month month = Month((p_datetime.has(MONTH_KEY)) ? int(p_datetime[MONTH_KEY]) : 1); \
184 int day = p_datetime.has(DAY_KEY) ? int(p_datetime[DAY_KEY]) : 1; \
185 int hour = p_datetime.has(HOUR_KEY) ? int(p_datetime[HOUR_KEY]) : 0; \
186 int minute = p_datetime.has(MINUTE_KEY) ? int(p_datetime[MINUTE_KEY]) : 0; \
187 int second = p_datetime.has(SECOND_KEY) ? int(p_datetime[SECOND_KEY]) : 0;
188
189Time *Time::singleton = nullptr;
190
191Time *Time::get_singleton() {
192 if (!singleton) {
193 memnew(Time);
194 }
195 return singleton;
196}
197
198Dictionary Time::get_datetime_dict_from_unix_time(int64_t p_unix_time_val) const {
199 UNIX_TIME_TO_HMS
200 UNIX_TIME_TO_YMD
201 Dictionary datetime;
202 datetime[YEAR_KEY] = year;
203 datetime[MONTH_KEY] = (uint8_t)month;
204 datetime[DAY_KEY] = day;
205 // Unix epoch was a Thursday (day 0 aka 1970-01-01).
206 datetime[WEEKDAY_KEY] = Math::posmod(day_number + WEEKDAY_THURSDAY, 7);
207 datetime[HOUR_KEY] = hour;
208 datetime[MINUTE_KEY] = minute;
209 datetime[SECOND_KEY] = second;
210
211 return datetime;
212}
213
214Dictionary Time::get_date_dict_from_unix_time(int64_t p_unix_time_val) const {
215 UNIX_TIME_TO_YMD
216 Dictionary datetime;
217 datetime[YEAR_KEY] = year;
218 datetime[MONTH_KEY] = (uint8_t)month;
219 datetime[DAY_KEY] = day;
220 // Unix epoch was a Thursday (day 0 aka 1970-01-01).
221 datetime[WEEKDAY_KEY] = Math::posmod(day_number + WEEKDAY_THURSDAY, 7);
222
223 return datetime;
224}
225
226Dictionary Time::get_time_dict_from_unix_time(int64_t p_unix_time_val) const {
227 UNIX_TIME_TO_HMS
228 Dictionary datetime;
229 datetime[HOUR_KEY] = hour;
230 datetime[MINUTE_KEY] = minute;
231 datetime[SECOND_KEY] = second;
232
233 return datetime;
234}
235
236String Time::get_datetime_string_from_unix_time(int64_t p_unix_time_val, bool p_use_space) const {
237 UNIX_TIME_TO_HMS
238 UNIX_TIME_TO_YMD
239 // vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
240 String timestamp = vformat("%04d-%02d-%02d", year, (uint8_t)month, day);
241 if (p_use_space) {
242 timestamp = vformat("%s %02d:%02d:%02d", timestamp, hour, minute, second);
243 } else {
244 timestamp = vformat("%sT%02d:%02d:%02d", timestamp, hour, minute, second);
245 }
246
247 return timestamp;
248}
249
250String Time::get_date_string_from_unix_time(int64_t p_unix_time_val) const {
251 UNIX_TIME_TO_YMD
252 // Android is picky about the types passed to make Variant, so we need a cast.
253 return vformat("%04d-%02d-%02d", year, (uint8_t)month, day);
254}
255
256String Time::get_time_string_from_unix_time(int64_t p_unix_time_val) const {
257 UNIX_TIME_TO_HMS
258 return vformat("%02d:%02d:%02d", hour, minute, second);
259}
260
261Dictionary Time::get_datetime_dict_from_datetime_string(String p_datetime, bool p_weekday) const {
262 PARSE_ISO8601_STRING(Dictionary())
263 Dictionary dict;
264 dict[YEAR_KEY] = year;
265 dict[MONTH_KEY] = (uint8_t)month;
266 dict[DAY_KEY] = day;
267 if (p_weekday) {
268 YMD_TO_DAY_NUMBER
269 // Unix epoch was a Thursday (day 0 aka 1970-01-01).
270 dict[WEEKDAY_KEY] = Math::posmod(day_number + WEEKDAY_THURSDAY, 7);
271 }
272 dict[HOUR_KEY] = hour;
273 dict[MINUTE_KEY] = minute;
274 dict[SECOND_KEY] = second;
275
276 return dict;
277}
278
279String Time::get_datetime_string_from_datetime_dict(const Dictionary p_datetime, bool p_use_space) const {
280 ERR_FAIL_COND_V_MSG(p_datetime.is_empty(), "", "Invalid datetime Dictionary: Dictionary is empty.");
281 EXTRACT_FROM_DICTIONARY
282 VALIDATE_YMDHMS("")
283 // vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
284 String timestamp = vformat("%04d-%02d-%02d", year, (uint8_t)month, day);
285 if (p_use_space) {
286 timestamp = vformat("%s %02d:%02d:%02d", timestamp, hour, minute, second);
287 } else {
288 timestamp = vformat("%sT%02d:%02d:%02d", timestamp, hour, minute, second);
289 }
290 return timestamp;
291}
292
293int64_t Time::get_unix_time_from_datetime_dict(const Dictionary p_datetime) const {
294 ERR_FAIL_COND_V_MSG(p_datetime.is_empty(), 0, "Invalid datetime Dictionary: Dictionary is empty");
295 EXTRACT_FROM_DICTIONARY
296 VALIDATE_YMDHMS(0)
297 YMD_TO_DAY_NUMBER
298 return day_number * SECONDS_PER_DAY + hour * 3600 + minute * 60 + second;
299}
300
301int64_t Time::get_unix_time_from_datetime_string(String p_datetime) const {
302 PARSE_ISO8601_STRING(-1)
303 VALIDATE_YMDHMS(0)
304 YMD_TO_DAY_NUMBER
305 return day_number * SECONDS_PER_DAY + hour * 3600 + minute * 60 + second;
306}
307
308String Time::get_offset_string_from_offset_minutes(int64_t p_offset_minutes) const {
309 String sign;
310 if (p_offset_minutes < 0) {
311 sign = "-";
312 p_offset_minutes = -p_offset_minutes;
313 } else {
314 sign = "+";
315 }
316 // These two lines can be optimized to one instruction on x86 and others.
317 // Note that % is acceptable here only because we ensure it's positive.
318 int64_t offset_hours = p_offset_minutes / 60;
319 int64_t offset_minutes = p_offset_minutes % 60;
320 return vformat("%s%02d:%02d", sign, offset_hours, offset_minutes);
321}
322
323Dictionary Time::get_datetime_dict_from_system(bool p_utc) const {
324 OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
325 Dictionary datetime;
326 datetime[YEAR_KEY] = dt.year;
327 datetime[MONTH_KEY] = (uint8_t)dt.month;
328 datetime[DAY_KEY] = dt.day;
329 datetime[WEEKDAY_KEY] = (uint8_t)dt.weekday;
330 datetime[HOUR_KEY] = dt.hour;
331 datetime[MINUTE_KEY] = dt.minute;
332 datetime[SECOND_KEY] = dt.second;
333 datetime[DST_KEY] = dt.dst;
334 return datetime;
335}
336
337Dictionary Time::get_date_dict_from_system(bool p_utc) const {
338 OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
339 Dictionary date_dictionary;
340 date_dictionary[YEAR_KEY] = dt.year;
341 date_dictionary[MONTH_KEY] = (uint8_t)dt.month;
342 date_dictionary[DAY_KEY] = dt.day;
343 date_dictionary[WEEKDAY_KEY] = (uint8_t)dt.weekday;
344 return date_dictionary;
345}
346
347Dictionary Time::get_time_dict_from_system(bool p_utc) const {
348 OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
349 Dictionary time_dictionary;
350 time_dictionary[HOUR_KEY] = dt.hour;
351 time_dictionary[MINUTE_KEY] = dt.minute;
352 time_dictionary[SECOND_KEY] = dt.second;
353 return time_dictionary;
354}
355
356String Time::get_datetime_string_from_system(bool p_utc, bool p_use_space) const {
357 OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
358 // vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
359 String timestamp = vformat("%04d-%02d-%02d", dt.year, (uint8_t)dt.month, dt.day);
360 if (p_use_space) {
361 timestamp = vformat("%s %02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second);
362 } else {
363 timestamp = vformat("%sT%02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second);
364 }
365
366 return timestamp;
367}
368
369String Time::get_date_string_from_system(bool p_utc) const {
370 OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
371 // Android is picky about the types passed to make Variant, so we need a cast.
372 return vformat("%04d-%02d-%02d", dt.year, (uint8_t)dt.month, dt.day);
373}
374
375String Time::get_time_string_from_system(bool p_utc) const {
376 OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
377 return vformat("%02d:%02d:%02d", dt.hour, dt.minute, dt.second);
378}
379
380Dictionary Time::get_time_zone_from_system() const {
381 OS::TimeZoneInfo info = OS::get_singleton()->get_time_zone_info();
382 Dictionary ret_timezone;
383 ret_timezone["bias"] = info.bias;
384 ret_timezone["name"] = info.name;
385 return ret_timezone;
386}
387
388double Time::get_unix_time_from_system() const {
389 return OS::get_singleton()->get_unix_time();
390}
391
392uint64_t Time::get_ticks_msec() const {
393 return OS::get_singleton()->get_ticks_msec();
394}
395
396uint64_t Time::get_ticks_usec() const {
397 return OS::get_singleton()->get_ticks_usec();
398}
399
400void Time::_bind_methods() {
401 ClassDB::bind_method(D_METHOD("get_datetime_dict_from_unix_time", "unix_time_val"), &Time::get_datetime_dict_from_unix_time);
402 ClassDB::bind_method(D_METHOD("get_date_dict_from_unix_time", "unix_time_val"), &Time::get_date_dict_from_unix_time);
403 ClassDB::bind_method(D_METHOD("get_time_dict_from_unix_time", "unix_time_val"), &Time::get_time_dict_from_unix_time);
404 ClassDB::bind_method(D_METHOD("get_datetime_string_from_unix_time", "unix_time_val", "use_space"), &Time::get_datetime_string_from_unix_time, DEFVAL(false));
405 ClassDB::bind_method(D_METHOD("get_date_string_from_unix_time", "unix_time_val"), &Time::get_date_string_from_unix_time);
406 ClassDB::bind_method(D_METHOD("get_time_string_from_unix_time", "unix_time_val"), &Time::get_time_string_from_unix_time);
407 ClassDB::bind_method(D_METHOD("get_datetime_dict_from_datetime_string", "datetime", "weekday"), &Time::get_datetime_dict_from_datetime_string);
408 ClassDB::bind_method(D_METHOD("get_datetime_string_from_datetime_dict", "datetime", "use_space"), &Time::get_datetime_string_from_datetime_dict);
409 ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime_dict", "datetime"), &Time::get_unix_time_from_datetime_dict);
410 ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime_string", "datetime"), &Time::get_unix_time_from_datetime_string);
411 ClassDB::bind_method(D_METHOD("get_offset_string_from_offset_minutes", "offset_minutes"), &Time::get_offset_string_from_offset_minutes);
412
413 ClassDB::bind_method(D_METHOD("get_datetime_dict_from_system", "utc"), &Time::get_datetime_dict_from_system, DEFVAL(false));
414 ClassDB::bind_method(D_METHOD("get_date_dict_from_system", "utc"), &Time::get_date_dict_from_system, DEFVAL(false));
415 ClassDB::bind_method(D_METHOD("get_time_dict_from_system", "utc"), &Time::get_time_dict_from_system, DEFVAL(false));
416 ClassDB::bind_method(D_METHOD("get_datetime_string_from_system", "utc", "use_space"), &Time::get_datetime_string_from_system, DEFVAL(false), DEFVAL(false));
417 ClassDB::bind_method(D_METHOD("get_date_string_from_system", "utc"), &Time::get_date_string_from_system, DEFVAL(false));
418 ClassDB::bind_method(D_METHOD("get_time_string_from_system", "utc"), &Time::get_time_string_from_system, DEFVAL(false));
419 ClassDB::bind_method(D_METHOD("get_time_zone_from_system"), &Time::get_time_zone_from_system);
420 ClassDB::bind_method(D_METHOD("get_unix_time_from_system"), &Time::get_unix_time_from_system);
421 ClassDB::bind_method(D_METHOD("get_ticks_msec"), &Time::get_ticks_msec);
422 ClassDB::bind_method(D_METHOD("get_ticks_usec"), &Time::get_ticks_usec);
423
424 BIND_ENUM_CONSTANT(MONTH_JANUARY);
425 BIND_ENUM_CONSTANT(MONTH_FEBRUARY);
426 BIND_ENUM_CONSTANT(MONTH_MARCH);
427 BIND_ENUM_CONSTANT(MONTH_APRIL);
428 BIND_ENUM_CONSTANT(MONTH_MAY);
429 BIND_ENUM_CONSTANT(MONTH_JUNE);
430 BIND_ENUM_CONSTANT(MONTH_JULY);
431 BIND_ENUM_CONSTANT(MONTH_AUGUST);
432 BIND_ENUM_CONSTANT(MONTH_SEPTEMBER);
433 BIND_ENUM_CONSTANT(MONTH_OCTOBER);
434 BIND_ENUM_CONSTANT(MONTH_NOVEMBER);
435 BIND_ENUM_CONSTANT(MONTH_DECEMBER);
436
437 BIND_ENUM_CONSTANT(WEEKDAY_SUNDAY);
438 BIND_ENUM_CONSTANT(WEEKDAY_MONDAY);
439 BIND_ENUM_CONSTANT(WEEKDAY_TUESDAY);
440 BIND_ENUM_CONSTANT(WEEKDAY_WEDNESDAY);
441 BIND_ENUM_CONSTANT(WEEKDAY_THURSDAY);
442 BIND_ENUM_CONSTANT(WEEKDAY_FRIDAY);
443 BIND_ENUM_CONSTANT(WEEKDAY_SATURDAY);
444}
445
446Time::Time() {
447 ERR_FAIL_COND_MSG(singleton, "Singleton for Time already exists.");
448 singleton = this;
449}
450
451Time::~Time() {
452 singleton = nullptr;
453}
454