From 883611676f1d17ed1708a01599f857d34ee18f82 Mon Sep 17 00:00:00 2001 From: Andrzej Fiedukowicz Date: Wed, 1 Feb 2017 17:23:12 +0100 Subject: [PATCH] Improve current_date function testing The test was only using TZ with positive shift, this change allows to test if the code works properly for negative shift as well. --- .../presto/operator/scalar/TestDateTimeFunctions.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestDateTimeFunctions.java b/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestDateTimeFunctions.java index 7957ff5336b6..5b046dc7b31b 100644 --- a/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestDateTimeFunctions.java +++ b/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestDateTimeFunctions.java @@ -31,6 +31,7 @@ import org.joda.time.DateTimeZone; import org.joda.time.LocalTime; import org.joda.time.ReadableInstant; +import org.joda.time.chrono.ISOChronology; import org.testng.annotations.Test; import java.time.Instant; @@ -119,8 +120,13 @@ public void testCurrentDateTimezone() throws Exception { TimeZoneKey kievTimeZoneKey = getTimeZoneKey("Europe/Kiev"); - for (long instant = new DateTime(2000, 6, 15, 0, 0).getMillis(); instant < new DateTime(2016, 6, 15, 0, 0).getMillis(); instant += TimeUnit.HOURS.toMillis(1)) { + TimeZoneKey montrealTimeZoneKey = getTimeZoneKey("America/Montreal"); + // We expect UTC millis later on so we have to use UTC chronology + for (long instant = ISOChronology.getInstanceUTC().getDateTimeMillis(2000, 6, 15, 0, 0, 0, 0); + instant < ISOChronology.getInstanceUTC().getDateTimeMillis(2016, 6, 15, 0, 0, 0, 0); + instant += TimeUnit.HOURS.toMillis(1)) { assertCurrentDateAtInstant(kievTimeZoneKey, instant); + assertCurrentDateAtInstant(montrealTimeZoneKey, instant); assertCurrentDateAtInstant(TIME_ZONE_KEY, instant); } }