| 72 | } |
| 73 | |
| 74 | static inline int timestamp_to_tm( |
| 75 | std::int64_t dt, struct tm & tm, std::int32_t & msec) { |
| 76 | std::int64_t dDate, POSTGRESQL_EPOCH_DATE = 2451545; |
| 77 | std::int64_t time; |
| 78 | std::uint64_t USECS_PER_DAY = 86400000000; |
| 79 | time = dt; |
| 80 | |
| 81 | dDate = time / USECS_PER_DAY; |
| 82 | if (dDate != 0) { time -= dDate * USECS_PER_DAY; } |
| 83 | |
| 84 | if (time < 0) { |
| 85 | time += USECS_PER_DAY; |
| 86 | dDate -= 1; |
| 87 | } |
| 88 | dDate += POSTGRESQL_EPOCH_DATE; |
| 89 | |
| 90 | date_to_ymd( |
| 91 | static_cast<std::int32_t>(dDate), tm.tm_year, tm.tm_mon, tm.tm_mday); |
| 92 | time_to_hms(time, tm.tm_hour, tm.tm_min, tm.tm_sec, msec); |
| 93 | } |
| 94 | |
| 95 | static inline std::string date_to_string(std::int32_t jd) { |
| 96 | // For date conversion see |
no test coverage detected