Skip to content

Commit

Permalink
Add test for FAQ example max_year
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Apr 7, 2017
1 parent ccf6194 commit 8ad0e8d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/TimeZones.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ if lowercase(get(ENV, "CI", "false")) == "true"
@test TimeZone("Etc/GMT") == FixedTimeZone("Etc/GMT", 0)
@test TimeZone("Etc/GMT+12") == FixedTimeZone("Etc/GMT+12", -12 * 3600)
@test TimeZone("Etc/GMT-14") == FixedTimeZone("Etc/GMT-14", 14 * 3600)


# Compile tz source files with an extended max_year. An example from the FAQ.
warsaw = TimeZone("Europe/Warsaw")
@test last(warsaw.transitions) == ZonedDateTime(2037, 10, 25, 1, warsaw)
@test warsaw.cutoff == Nullable(DateTime(2038, 3, 28, 1))
@test_throws TimeZones.UnhandledTimeError ZonedDateTime(DateTime(2039), warsaw)

TimeZones.TZData.compile(max_year=2200)
new_warsaw = TimeZone("Europe/Warsaw")

@test last(new_warsaw.transitions) == ZonedDateTime(2200, 10, 26, 1, new_warsaw)
@test new_warsaw.cutoff == Nullable(DateTime(2201, 3, 29, 1))
ZonedDateTime(2100, new_warsaw) # Test this doesn't throw an exception

@test_throws TimeZones.UnhandledTimeError ZonedDateTime(2100, warsaw)
end

0 comments on commit 8ad0e8d

Please sign in to comment.