MCPcopy Create free account
hub / github.com/BlazingDB/blazingsql / timestamp_to_tm

Function timestamp_to_tm

engine/src/io/data_parser/sql/PostgreSQLParser.cpp:74–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74static 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
95static inline std::string date_to_string(std::int32_t jd) {
96 // For date conversion see

Callers 1

timestamp_to_stringFunction · 0.85

Calls 2

date_to_ymdFunction · 0.85
time_to_hmsFunction · 0.85

Tested by

no test coverage detected