| 92 | } |
| 93 | |
| 94 | int32_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 | |
| 114 | TEST_F(DateTimeTestProjector, TestIsNull) { |
| 115 | auto d0 = field("d0", date64()); |