You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2019/10/21 03:41:53 UTC

[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #462: [IOTDB-253]time expression

LeiRui commented on a change in pull request #462: [IOTDB-253]time expression
URL: https://github.com/apache/incubator-iotdb/pull/462#discussion_r336825146
 
 

 ##########
 File path: server/src/main/java/org/apache/iotdb/db/qp/constant/DatetimeUtils.java
 ##########
 @@ -475,6 +475,66 @@ public static long convertDatetimeStrToLong(String str, ZoneOffset offset, int d
     return getInstantWithPrecision(str, timestampPrecision);
   }
 
+  /**
+   * convert duration string to millisecond, microsecond or nanosecond.
+   */
+  public static long convertDurationStrToLong(long value, String unit, String timestampPrecision) {
+
+    long res = value;
+    switch (unit) {
+      case "y":
+        res *= 365 * 86400_000;
+        break;
+      case "mo":
+        res *= 30 * 86400_000;
+        break;
+      case "w":
+        res *= 7 * 86400_000;
+        break;
+      case "d":
+        res *= 86400_000;
+        break;
+      case "h":
+        res *= 3600_000;
+        break;
+      case "m":
+        res *= 60_000;
+        break;
+      case "s":
+        res *= 1_000;
+        break;
+      default:
 
 Review comment:
   Plus Plus, why doesn't the default branch throw an exception?

----------------------------------------------------------------
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