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 2020/04/19 09:07:39 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #3300: Use Google/CCTZ to replace boost at timezone function

morningman commented on a change in pull request #3300: Use Google/CCTZ to replace boost at timezone function
URL: https://github.com/apache/incubator-doris/pull/3300#discussion_r410857512
 
 

 ##########
 File path: be/src/runtime/datetime_value.h
 ##########
 @@ -494,6 +498,33 @@ class DateTimeValue {
         return _neg ? -tmp : tmp;
     }
 
+    bool find_cctz_time_zone(const std::string& timezone, cctz::time_zone& ctz) const {
+        re2::StringPiece value;
+        if (time_zone_offset_format_reg.Match(timezone, 0, timezone.size(), RE2::UNANCHORED, &value, 1)) {
+            bool postive = value[0] != '-';
+
+            //Regular expression guarantees hour and minute mush be int 
+            int hour = std::stoi(value.substr(1, 2).as_string());
+            int minute = std::stoi(value.substr(4, 2).as_string());
+
+            // timezone offsets around the world extended from -12:00 to +14:00
+            if (!postive && hour > 12) {
+                return false;
+            } else if (postive && hour > 14) {
+                return false;
+            }
+            int offset = hour * 60 * 60 + minute * 60;
+            offset *= postive ? 1 : -1;
+            ctz = cctz::fixed_time_zone(cctz::seconds(offset));
+            return true;
+        } else if (timezone == "CST"){
+            // Supports offset and region timezone type, "CST" use here is compatibility purposes.
+            ctz = cctz::fixed_time_zone(cctz::seconds(8 * 60 * 60));
 
 Review comment:
   Missing return value

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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