| 3552 | } |
| 3553 | |
| 3554 | static bool PortableLocaltime(time_t seconds, struct tm* out) { |
| 3555 | #if defined(_MSC_VER) |
| 3556 | return localtime_s(out, &seconds) == 0; |
| 3557 | #elif defined(__MINGW32__) || defined(__MINGW64__) |
| 3558 | // MINGW <time.h> provides neither localtime_r nor localtime_s, but uses |
| 3559 | // Windows' localtime(), which has a thread-local tm buffer. |
| 3560 | struct tm* tm_ptr = localtime(&seconds); // NOLINT |
| 3561 | if (tm_ptr == NULL) |
| 3562 | return false; |
| 3563 | *out = *tm_ptr; |
| 3564 | return true; |
| 3565 | #else |
| 3566 | return localtime_r(&seconds, out) != NULL; |
| 3567 | #endif |
| 3568 | } |
| 3569 | |
| 3570 | // Converts the given epoch time in milliseconds to a date string in the ISO |
| 3571 | // 8601 format, without the timezone information. |
no test coverage detected