Skip to content

Commit

Permalink
Remove manual addition of "Etc" timezones
Browse files Browse the repository at this point in the history
All of the fixed timezones that were added can be found in the file
"etcetera" from the IANA website. Even though we could support these
timezones I think we shouldn't as they are deemed historical along with
"backward".

Additionally, the "Etc/GMT(+|-)\d+" can be confusing as their labels
("GMT+1") have the opposite offset (-3600 seconds).

See ftp://ftp.iana.org/tz/data/etcetera for details.
  • Loading branch information
omus committed Oct 7, 2015
1 parent 7bd4185 commit 147ab2e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 60 deletions.
24 changes: 10 additions & 14 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import TimeZones: TZDATA_DIR, COMPILED_DIR, fixed_timezones
import TimeZones.Olson: REGIONS, compile
import TimeZones: TZDATA_DIR, COMPILED_DIR
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)
Expand Down Expand Up @@ -42,16 +50,4 @@ for file in readdir(COMPILED_DIR)
end
compile(TZDATA_DIR, COMPILED_DIR)

info("Adding additional FixedTimeZones")
for (name, tz) in fixed_timezones()
parts = split(name, "/")
tz_dir, tz_file = joinpath(COMPILED_DIR, parts[1:end-1]...), parts[end]

isdir(tz_dir) || mkpath(tz_dir)

open(joinpath(tz_dir, tz_file), "w") do fp
serialize(fp, tz)
end
end

info("Successfully processed TimeZone data")
5 changes: 5 additions & 0 deletions deps/tzdata/utc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Zones specifically for TimeZones.jl

# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone UTC 0 - UTC
Zone GMT 0 - GMT
1 change: 0 additions & 1 deletion src/TimeZones.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ include("timezones/io.jl")
include("timezones/adjusters.jl")
include("timezones/Olson.jl")
include("timezones/conversions.jl")
include("timezones/fixed.jl")

function TimeZone(name::AbstractString)
tz_path = joinpath(COMPILED_DIR, split(name, "/")...)
Expand Down
9 changes: 2 additions & 7 deletions src/timezones/Olson.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions src/timezones/fixed.jl

This file was deleted.

1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ include("timezones/arithmetic.jl")
include("timezones/io.jl")
include("timezones/adjusters.jl")
include("timezones/conversions.jl")
include("timezones/fixed.jl")
include("timezone_names.jl")
5 changes: 5 additions & 0 deletions test/timezone_names.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 0 additions & 18 deletions test/timezones/fixed.jl

This file was deleted.

0 comments on commit 147ab2e

Please sign in to comment.