MCPcopy Create free account
hub / github.com/bytedance/bolt / tmToString

Function tmToString

bolt/type/tests/TimestampTest.cpp:445–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445std::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
466TEST(TimestampTest, epochToUtc) {
467 std::tm tm{};

Callers 4

toStringFunction · 0.85
toStringMethod · 0.85
timestampToStringFunction · 0.85
testTmToStringFunction · 0.85

Calls 1

strMethod · 0.80

Tested by

no test coverage detected