HeartLinked commented on code in PR #206: URL: https://github.com/apache/iceberg-cpp/pull/206#discussion_r2342796967
########## src/iceberg/expression/literal.cc: ########## @@ -19,13 +19,34 @@ #include "iceberg/expression/literal.h" +#include <chrono> #include <cmath> #include <concepts> +#include <cstdint> +#include <iomanip> #include "iceberg/exception.h" namespace iceberg { +namespace { + +int32_t MicrosToDays(int64_t micros_since_epoch) { + std::chrono::microseconds micros(micros_since_epoch); + auto days_duration = std::chrono::floor<std::chrono::days>(micros); + return static_cast<int32_t>(days_duration.count()); +} + +time_t timegm_custom(std::tm* tm) { Review Comment: The key difference here is that std::mktime interprets the input std::tm as being in the system's local timezone, while timegm (and its Windows equivalent _mkgmtime) interprets it as UTC. According to the Iceberg specification, timestamp strings without an explicit timezone (like "2023-05-15T12:00:00") must be interpreted as UTC. Since our parser creates a std::tm that represents a UTC time, we must use a function like timegm that performs a direct conversion without applying any local timezone offsets. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org