| 443 | } |
| 444 | |
| 445 | std::string tmToString( |
| 446 | const std::tm& tmValue, |
| 447 | uint64_t nanos, |
| 448 | const std::string& format, |
| 449 | const TimestampToStringOptions& options) { |
| 450 | auto width = static_cast<int>(options.precision); |
| 451 | auto value = |
| 452 | options.precision == TimestampToStringOptions::Precision::kMilliseconds |
| 453 | ? nanos / 1'000'000 |
| 454 | : nanos; |
| 455 | |
| 456 | std::ostringstream oss; |
| 457 | oss << std::put_time(&tmValue, format.c_str()); |
| 458 | |
| 459 | if (options.mode != TimestampToStringOptions::Mode::kDateOnly) { |
| 460 | oss << '.' << std::setfill('0') << std::setw(width) << value; |
| 461 | } |
| 462 | |
| 463 | return oss.str(); |
| 464 | } |
| 465 | |
| 466 | TEST(TimestampTest, epochToUtc) { |
| 467 | std::tm tm{}; |
no test coverage detected