MCPcopy Create free account
hub / github.com/apache/arrow / DaysSince

Function DaysSince

cpp/src/gandiva/tests/date_time_test.cc:94–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94int32_t DaysSince(time_t base_line, int32_t yy, int32_t mm, int32_t dd, int32_t hr,
95 int32_t min, int32_t sec, int32_t millis) {
96 struct tm given_ts;
97 memset(&given_ts, 0, sizeof(struct tm));
98 given_ts.tm_year = (yy - 1900);
99 given_ts.tm_mon = (mm - 1);
100 given_ts.tm_mday = dd;
101 given_ts.tm_hour = hr;
102 given_ts.tm_min = min;
103 given_ts.tm_sec = sec;
104
105 time_t ts = mktime(&given_ts);
106 if (ts == static_cast<time_t>(-1)) {
107 ARROW_LOG(FATAL) << "mktime() failed";
108 }
109 // time_t is an arithmetic type on both POSIX and Windows, we can simply
110 // subtract to get a duration in seconds.
111 return static_cast<int32_t>(((ts - base_line) * 1000 + millis) / MILLIS_IN_DAY);
112}
113
114TEST_F(DateTimeTestProjector, TestIsNull) {
115 auto d0 = field("d0", date64());

Callers 1

TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected