caiconghui commented on a change in pull request #6384:
URL: https://github.com/apache/incubator-doris/pull/6384#discussion_r690106418



##########
File path: be/src/util/date_func.cpp
##########
@@ -55,11 +55,55 @@ uint24_t timestamp_from_date(const std::string& date_str) {
 }
 
 std::string time_str_from_double(double time) {

Review comment:
       removed

##########
File path: be/src/util/date_func.cpp
##########
@@ -55,11 +55,55 @@ uint24_t timestamp_from_date(const std::string& date_str) {
 }
 
 std::string time_str_from_double(double time) {
+    std::string result;
+    result.reserve(MAX_TIME_WIDTH);
     if (time < 0) {
         time = -time;
-        return fmt::format("-{:02d}:{:02d}:{:02d}", (int64_t)(time / 60 / 60), 
((int64_t)(time / 60)) % 60, ((int64_t)time) % 60);
+        result.push_back('-');
     }
-    return fmt::format("{:02d}:{:02d}:{:02d}", (int64_t)(time / 60 / 60), 
((int64_t)(time / 60)) % 60, ((int64_t)time) % 60);
+    int64_t hour = (int64_t)(time / 3600);
+    if (hour >= 100) {
+        auto f = fmt::format_int(hour);
+        result.append(f.data(), f.size());
+    } else {
+        result.push_back((char)('0' + (hour / 10)));
+        result.push_back((char)('0' + (hour % 10)));
+    }
+    result.push_back(':');
+    int32_t minute = ((int32_t)(time / 60)) % 60;
+    result.push_back((char)('0' + (minute / 10)));
+    result.push_back((char)('0' + (minute % 10)));
+    result.push_back(':');
+    int32_t second = ((int32_t)time) % 60;
+    result.push_back((char)('0' + (second / 10)));
+    result.push_back((char)('0' + (second % 10)));
+    return result;
+}
+
+int32_t time_to_buffer_from_double(double time, char* buffer) {

Review comment:
       added




-- 
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-unsubscr...@doris.apache.org

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



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

Reply via email to