You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/17 17:25:37 UTC

[GitHub] MaxGekk commented on a change in pull request #23815: [SPARK-26908][SQL] Fix DateTimeUtils.toMillis and millisToDays

MaxGekk commented on a change in pull request #23815: [SPARK-26908][SQL] Fix DateTimeUtils.toMillis and millisToDays
URL: https://github.com/apache/spark/pull/23815#discussion_r257514514
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
 ##########
 @@ -85,7 +85,7 @@ object DateTimeUtils {
     // SPARK-6785: use Math.floor so negative number of days (dates before 1970)
     // will correctly work as input for function toJavaDate(Int)
     val millisLocal = millisUtc + timeZone.getOffset(millisUtc)
-    Math.floor(millisLocal.toDouble / MILLIS_PER_DAY).toInt
+    Math.floorDiv(millisLocal, MILLIS_PER_DAY).toInt
 
 Review comment:
   > I see, because `floorDiv` rounds towards 0?
   
   For example, if we have an old date (negative in milliseconds) `<old year>-12-31 23:59:59.999456`. `floorDiv` should produce `<old year>-12-31 23:59:59.999` instead of `<old year+1>-01-01 00:00:00.000`. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org