| 61 | } |
| 62 | |
| 63 | std::string UtcTimestamp::ToIsoTime(bool include_ms) const { |
| 64 | const auto ms_sec = (utc_timestamp_ / 1'000'000) % 1'000; |
| 65 | const auto system_time = static_cast<std::time_t>(utc_timestamp_ / 1'000'000'000); |
| 66 | std::ostringstream text; |
| 67 | if (struct tm *bt = std::gmtime(&system_time); |
| 68 | bt != nullptr ) { |
| 69 | text << std::put_time(bt, "%H:%M:%S"); |
| 70 | } |
| 71 | if (ms_sec > 0 && include_ms) { |
| 72 | text << '.' << std::setfill('0') << std::setw(3) << ms_sec; |
| 73 | } |
| 74 | text << "Z"; |
| 75 | return text.str(); |
| 76 | } |
| 77 | |
| 78 | std::string UtcTimestamp::ToIsoDateTime(bool include_ms) const { |
| 79 | const auto ms_sec = (utc_timestamp_ / 1'000'000) % 1'000; |