MCPcopy Create free account
hub / github.com/ByConity/ByConity / getPhysicalTime

Function getPhysicalTime

programs/tso/client_test.cpp:42–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40constexpr size_t LOGICAL_BITMASK = 0x3FFFF;
41
42std::string getPhysicalTime(DB::UInt64 timestamp)
43{
44 timestamp = timestamp >> LOGICAL_BITS; /// get the physical time
45 auto milli = timestamp + 8 * 60 * 60 * 1000; /// specified to Beijing timezone
46 auto mTime = std::chrono::milliseconds(milli);
47 auto tp = std::chrono::time_point<std::chrono::system_clock,std::chrono::milliseconds>(mTime);
48 auto tt = std::chrono::system_clock::to_time_t(tp);
49 auto now = std::gmtime(&tt);
50
51 std::stringstream ss;
52 ss << now->tm_year + 1900
53 << "/" << std::setfill('0') << std::setw(2) << now->tm_mon + 1
54 << "/" << std::setfill('0') << std::setw(2) << now->tm_mday
55 << " " << std::setfill('0') << std::setw(2) << now->tm_hour
56 << ":" << std::setfill('0') << std::setw(2) << now->tm_min
57 << ":" << std::setfill('0') << std::setw(2) << now->tm_sec;
58
59 return ss.str();
60}
61
62std::string getLogicalTime(DB::UInt64 timestamp)
63{

Callers 1

mainFunction · 0.85

Calls 1

strMethod · 0.45

Tested by

no test coverage detected