GH-49952: [C++][Gandiva] Use timegm in date_time_test utilities#49953
Conversation
|
|
lriggs
left a comment
There was a problem hiding this comment.
Thanks for the follow up.
There was a problem hiding this comment.
Pull request overview
This PR updates Gandiva’s C++ datetime test utilities to interpret tm inputs as UTC (rather than local time) to avoid DST / timezone-dependent behavior in tests.
Changes:
- Replaced
mktime()withtimegm()in UTC timestamp utilities used by tests. - Added a Windows compatibility mapping so
timegm()resolves to_mkgmtimeon_WIN32. - Simplified
Epoch()by removing the prior MSVC/localtime workaround.
Comments suppressed due to low confidence (1)
cpp/src/gandiva/tests/date_time_test.cc:95
DaysSince()still usesmktime()(local time) even thoughEpoch()/MillisSince()now use UTC (timegm()). This keeps part of the date/time test utilities timezone/DST-dependent and contradicts the PR goal of making the tests deterministic. SwitchDaysSince()totimegm()(with the existing Windows mapping) and update the error message accordingly.
// time_t is an arithmetic type on both POSIX and Windows, we can simply
// subtract to get a duration in seconds.
return static_cast<int64_t>(ts - base_line) * 1000 + millis;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit d0c59fa. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 9 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
As discussed in PR #49887, the Gandiva datetime test utilities currently use
mktime(), which interprets timestamps as local time and can behave differently across platforms and DST boundaries.This PR switches the test utilities to
timegm()so timestamps are interpreted consistently as UTC. This also removes the existing workaround logic inEpoch()that was previously needed formktime()behavior on Windows/MSVC.What changes are included in this PR?
mktime()withtimegm()indate_time_test.cc_mkgmtimeEpoch()Are these changes tested?
DateTimeTestProjector.TestFromUtcTimestamprepeatedly locallygandiva-projector-testsuite successfullyAre there any user-facing changes?
No.