HeartLinked commented on code in PR #206:
URL: https://github.com/apache/iceberg-cpp/pull/206#discussion_r2321094285
##########
src/iceberg/expression/literal.cc:
##########
@@ -26,6 +26,16 @@
namespace iceberg {
+namespace {
+
+constexpr int64_t kMicrosPerDay = 86400000000LL; // 24 * 60 * 60 * 1000 * 1000
+
+int32_t MicrosToDays(int64_t micros) {
+ return static_cast<int32_t>(std::floor(static_cast<double>(micros) /
kMicrosPerDay));
Review Comment:
Good catch on the floating-point conversion. I investigated using simple
integer division, but it truncates rather than floors, which fails for pre-1970
dates (e.g., -1us becomes day 0, not -1).
I've switched to using std::chrono::floor, as it's the correct, safe, and
idiomatic C++ solution for this conversion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]