drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] oleg-zinovev commented on a change in pull request #2284: DRILL-7926: Age Function Fix
Date Tue, 03 Aug 2021 22:40:12 GMT

oleg-zinovev commented on a change in pull request #2284:
URL: https://github.com/apache/drill/pull/2284#discussion_r682148293



##########
File path: exec/vector/src/main/java/org/apache/drill/exec/vector/DateUtilities.java
##########
@@ -213,11 +216,27 @@ public static LocalDate fromDrillDate(long value) {
     return LocalDate.ofEpochDay(value / daysToStandardMillis);
   }
 
-  public static long toDrillTimestamp(Instant instant) {
-    return instant.toEpochMilli();
+  /**
+   * Convert to seconds since the _local_ Unix epoch, midnight 1970-01-01
+   * in the configured time zone.
+   * @param instant an Instant representing a moment in time.
+   * @param zoneId Drill's configured time zone.
+   * @return the Drill timestamp value corresponding to instant.
+   */
+  public static long toDrillTimestamp(Instant instant, ZoneId zoneId) {
+    LocalDateTime ldt = instant.atZone(zoneId).toLocalDateTime();
+    return ldt.atZone(ZoneId.of("UTC")).toEpochSecond()*1000;

Review comment:
       1) I think we should use the `toInstant().toEpochMilli()`. Current implementation loses
information about milliseconds.
   2) `ZoneId.of ("UTC")` is a good candidate for creating a constant




-- 
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: dev-unsubscribe@drill.apache.org

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



Mime
View raw message