zhiqiang-hhhh commented on code in PR #35681:
URL: https://github.com/apache/doris/pull/35681#discussion_r1630805377
##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -3367,16 +3370,28 @@ void DateV2Value<T>::from_unixtime(int64_t timestamp,
int32_t nano_seconds,
static const cctz::time_point<cctz::sys_seconds> epoch =
std::chrono::time_point_cast<cctz::sys_seconds>(
std::chrono::system_clock::from_time_t(0));
- cctz::time_point<cctz::sys_seconds> t = epoch + cctz::seconds(timestamp);
-
- const auto tp = cctz::convert(t, ctz);
- if (scale > 6) [[unlikely]] {
+ // Do rounding before looking up the time zone.
+ if (scale > 6) {
scale = 6;
}
+ nano_seconds /= common::exp10_i32(9 - scale - 1);
+
+ if (nano_seconds % 10 >= 5) {
+ nano_seconds += 10;
+ }
+
+ if (nano_seconds >= common::exp10_i32(scale + 1)) {
+ timestamp += 1;
+ nano_seconds = 0;
+ }
+
+ int32_t millisecond = (nano_seconds /= 10) * common::exp10_i32(6 - scale);
Review Comment:
fixed
--
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]