You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/29 07:46:26 UTC

[GitHub] [doris] HappenLee commented on a diff in pull request #15312: [Bug](timediff) Fix wrong result for function `timediff`

HappenLee commented on code in PR #15312:
URL: https://github.com/apache/doris/pull/15312#discussion_r1058768522


##########
be/src/util/date_func.cpp:
##########
@@ -109,4 +109,28 @@ int32_t time_to_buffer_from_double(double time, char* buffer) {
     return buffer - begin;
 }
 
+std::string time_to_buffer_from_double(double time) {
+    fmt::memory_buffer buffer;
+    if (time < 0) {
+        time = -time;
+        fmt::format_to(buffer, "-");
+    }
+    if (time > 3020399) {
+        time = 3020399;
+    }
+    int64_t hour = (int64_t)(time / 3600);
+    int32_t minute = ((int32_t)(time / 60)) % 60;
+    int32_t second = ((int32_t)time) % 60;
+    if (hour >= 100) {
+        fmt::format_to(buffer, fmt::format("{}", hour));

Review Comment:
   use `{:2d}` to do format



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org