diff --git a/deps/build.jl b/deps/build.jl index f8ff96257..77adf1cd5 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,5 +1,13 @@ import TimeZones: TZDATA_DIR, COMPILED_DIR -import TimeZones.Olson: REGIONS, compile +import TimeZones.Olson: compile + +# See "ftp://ftp.iana.org/tz/data/Makefile" PRIMARY_YDATA for listing of +# regions to include. YDATA includes historical zones which we'll ignore. +const REGIONS = ( + "africa", "antarctica", "asia", "australasia", + "europe", "northamerica", "southamerica", + # "pacificnew", "etcetera", "backward", # Historical zones +) isdir(TZDATA_DIR) || mkdir(TZDATA_DIR) isdir(COMPILED_DIR) || mkdir(COMPILED_DIR) diff --git a/deps/tzdata/utc b/deps/tzdata/utc new file mode 100644 index 000000000..fcaf88efc --- /dev/null +++ b/deps/tzdata/utc @@ -0,0 +1,5 @@ +# Zones specifically for TimeZones.jl + +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone UTC 0 - UTC +Zone GMT 0 - GMT diff --git a/src/timezones/Olson.jl b/src/timezones/Olson.jl index 8c16491d6..47aae8d9f 100644 --- a/src/timezones/Olson.jl +++ b/src/timezones/Olson.jl @@ -6,11 +6,6 @@ import ..TimeZones: TZDATA_DIR, COMPILED_DIR, ZERO, MIN_GMT_OFFSET, MAX_GMT_OFFS MIN_SAVE, MAX_SAVE, ABS_DIFF_OFFSET, Time, toseconds import ..TimeZones: TimeZone, FixedTimeZone, VariableTimeZone, Transition, Time -const REGIONS = ( - "africa", "antarctica", "asia", "australasia", - "europe", "northamerica", "southamerica", -) - # Zone type maps to an Olson Timezone database entity type Zone gmtoffset::Time @@ -509,8 +504,8 @@ end function load(tzdata_dir::AbstractString=TZDATA_DIR) timezones = Dict{AbstractString,TimeZone}() - for region in REGIONS - zones, rules = tzparse(joinpath(tzdata_dir, region)) + for filename in readdir(tzdata_dir) + zones, rules = tzparse(joinpath(tzdata_dir, filename)) merge!(timezones, resolve(zones, rules)) end return timezones diff --git a/test/timezone_names.jl b/test/timezone_names.jl index 5bc7cf958..83a4bc9c6 100644 --- a/test/timezone_names.jl +++ b/test/timezone_names.jl @@ -5,3 +5,8 @@ names = timezone_names() @test length(names) >= 429 @test isa(names, Array{AbstractString}) @test issorted(names) + +# Make sure that extra timezones exist from "deps/tzdata/utc". +# If tests fail try rebuilding the package: Pkg.build("TimeZones") +@test "UTC" in names +@test "GMT" in names