| 40 | constexpr size_t LOGICAL_BITMASK = 0x3FFFF; |
| 41 | |
| 42 | std::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 | |
| 62 | std::string getLogicalTime(DB::UInt64 timestamp) |
| 63 | { |