@@ -233,15 +233,8 @@ Dictionary Time::get_time_dict_from_unix_time(int64_t p_unix_time_val) const {
233
233
String Time::get_datetime_string_from_unix_time (int64_t p_unix_time_val, bool p_use_space) const {
234
234
UNIX_TIME_TO_HMS
235
235
UNIX_TIME_TO_YMD
236
- // vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
237
- String timestamp = vformat (" %04d-%02d-%02d" , year, (uint8_t )month, day);
238
- if (p_use_space) {
239
- timestamp = vformat (" %s %02d:%02d:%02d" , timestamp, hour, minute, second);
240
- } else {
241
- timestamp = vformat (" %sT%02d:%02d:%02d" , timestamp, hour, minute, second);
242
- }
243
-
244
- return timestamp;
236
+ const String format_string = p_use_space ? " %04d-%02d-%02d %02d:%02d:%02d" : " %04d-%02d-%02dT%02d:%02d:%02d" ;
237
+ return vformat (format_string, year, (uint8_t )month, day, hour, minute, second);
245
238
}
246
239
247
240
String Time::get_date_string_from_unix_time (int64_t p_unix_time_val) const {
@@ -277,14 +270,8 @@ String Time::get_datetime_string_from_datetime_dict(const Dictionary &p_datetime
277
270
ERR_FAIL_COND_V_MSG (p_datetime.is_empty (), " " , " Invalid datetime Dictionary: Dictionary is empty." );
278
271
EXTRACT_FROM_DICTIONARY
279
272
VALIDATE_YMDHMS (" " )
280
- // vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
281
- String timestamp = vformat (" %04d-%02d-%02d" , year, (uint8_t )month, day);
282
- if (p_use_space) {
283
- timestamp = vformat (" %s %02d:%02d:%02d" , timestamp, hour, minute, second);
284
- } else {
285
- timestamp = vformat (" %sT%02d:%02d:%02d" , timestamp, hour, minute, second);
286
- }
287
- return timestamp;
273
+ const String format_string = p_use_space ? " %04d-%02d-%02d %02d:%02d:%02d" : " %04d-%02d-%02dT%02d:%02d:%02d" ;
274
+ return vformat (format_string, year, (uint8_t )month, day, hour, minute, second);
288
275
}
289
276
290
277
int64_t Time::get_unix_time_from_datetime_dict (const Dictionary &p_datetime) const {
@@ -352,15 +339,8 @@ Dictionary Time::get_time_dict_from_system(bool p_utc) const {
352
339
353
340
String Time::get_datetime_string_from_system (bool p_utc, bool p_use_space) const {
354
341
OS::DateTime dt = OS::get_singleton ()->get_datetime (p_utc);
355
- // vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
356
- String timestamp = vformat (" %04d-%02d-%02d" , dt.year , (uint8_t )dt.month , dt.day );
357
- if (p_use_space) {
358
- timestamp = vformat (" %s %02d:%02d:%02d" , timestamp, dt.hour , dt.minute , dt.second );
359
- } else {
360
- timestamp = vformat (" %sT%02d:%02d:%02d" , timestamp, dt.hour , dt.minute , dt.second );
361
- }
362
-
363
- return timestamp;
342
+ const String format_string = p_use_space ? " %04d-%02d-%02d %02d:%02d:%02d" : " %04d-%02d-%02dT%02d:%02d:%02d" ;
343
+ return vformat (format_string, dt.year , (uint8_t )dt.month , dt.day , dt.hour , dt.minute , dt.second );
364
344
}
365
345
366
346
String Time::get_date_string_from_system (bool p_utc) const {
0 commit comments