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

Function toStringAlt

bolt/type/tests/TimestampTest.cpp:277–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275
276namespace {
277std::string toStringAlt(
278 const Timestamp& t,
279 TimestampToStringOptions::Precision precision) {
280 auto seconds = t.getSeconds();
281 std::tm tmValue;
282 BOLT_CHECK_NOT_NULL(gmtime_r((const time_t*)&seconds, &tmValue));
283 auto width = static_cast<int>(precision);
284 auto value = precision == TimestampToStringOptions::Precision::kMilliseconds
285 ? t.getNanos() / 1'000'000
286 : t.getNanos();
287 std::ostringstream oss;
288 oss << std::put_time(&tmValue, "%F %T");
289 oss << '.' << std::setfill('0') << std::setw(width) << value;
290 return oss.str();
291}
292} // namespace
293
294TEST(TimestampTest, compareWithToStringAlt) {

Callers 1

TESTFunction · 0.85

Calls 1

strMethod · 0.80

Tested by

no test coverage detected