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 15:52:47 UTC

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

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

 ##########
 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?
   What about the comment above, that seems to indicate this might be on purpose?
   Generally I agree that `floorDiv` could be appropriate in any place the input could be negative; maybe there are more.

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