Skip to content

Commit 4bba902

Browse files
author
Davies Liu
committed
specify the timezone in tests
1 parent 5c60bc6 commit 4bba902

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,14 @@ class DateTimeUtilsSuite extends SparkFunSuite {
497497
}
498498
}
499499

500-
// Daylight Saving Time
501-
test("2016-03-13 09:59:59.0", "PST", "2016-03-13 01:59:59.0")
502-
test("2016-03-13 10:00:00.0", "PST", "2016-03-13 03:00:00.0")
503-
test("2016-11-06 08:59:59.0", "PST", "2016-11-06 01:59:59.0")
504-
test("2016-11-06 09:00:00.0", "PST", "2016-11-06 01:00:00.0")
505-
test("2016-11-06 10:00:00.0", "PST", "2016-11-06 02:00:00.0")
500+
DateTimeTestUtils.withDefaultTimeZone(TimeZone.getTimeZone("PST")) {
501+
// Daylight Saving Time
502+
test("2016-03-13 09:59:59.0", "PST", "2016-03-13 01:59:59.0")
503+
test("2016-03-13 10:00:00.0", "PST", "2016-03-13 03:00:00.0")
504+
test("2016-11-06 08:59:59.0", "PST", "2016-11-06 01:59:59.0")
505+
test("2016-11-06 09:00:00.0", "PST", "2016-11-06 01:00:00.0")
506+
test("2016-11-06 10:00:00.0", "PST", "2016-11-06 02:00:00.0")
507+
}
506508
}
507509

508510
test("to UTC timestamp") {
@@ -520,14 +522,18 @@ class DateTimeUtilsSuite extends SparkFunSuite {
520522
}
521523
}
522524

523-
// Daylight Saving Time
524-
test("2016-03-13 01:59:59", "PST", "2016-03-13 09:59:59.0")
525-
test("2016-03-13 03:00:00", "PST", "2016-03-13 10:00:00.0")
526-
test("2016-11-06 00:59:59", "PST", "2016-11-06 07:59:59.0")
527-
// 2016-11-06 01:00:00 PST could be 2016-11-06 08:00:00 UTC or 2016-11-06 09:00:00 UTC
528-
test("2016-11-06 01:00:00", "PST", "2016-11-06 09:00:00.0")
529-
test("2016-11-06 01:59:59", "PST", "2016-11-06 09:59:59.0")
530-
test("2016-11-06 02:00:00", "PST", "2016-11-06 10:00:00.0")
525+
DateTimeTestUtils.withDefaultTimeZone(TimeZone.getTimeZone("PST")) {
526+
// Daylight Saving Time
527+
test("2016-03-13 01:59:59", "PST", "2016-03-13 09:59:59.0")
528+
// 2016-03-13 02:00:00 PST does not exists
529+
test("2016-03-13 02:00:00", "PST", "2016-03-13 10:00:00.0")
530+
test("2016-03-13 03:00:00", "PST", "2016-03-13 10:00:00.0")
531+
test("2016-11-06 00:59:59", "PST", "2016-11-06 07:59:59.0")
532+
// 2016-11-06 01:00:00 PST could be 2016-11-06 08:00:00 UTC or 2016-11-06 09:00:00 UTC
533+
test("2016-11-06 01:00:00", "PST", "2016-11-06 09:00:00.0")
534+
test("2016-11-06 01:59:59", "PST", "2016-11-06 09:59:59.0")
535+
test("2016-11-06 02:00:00", "PST", "2016-11-06 10:00:00.0")
536+
}
531537
}
532538

533539
test("daysToMillis and millisToDays") {

0 commit comments

Comments
 (0)