Skip to content

Commit

Permalink
Merge pull request #9 from invenia/fixed
Browse files Browse the repository at this point in the history
Added extra FixedTimeZones
  • Loading branch information
omus committed Oct 7, 2015
2 parents a9f89a2 + 147ab2e commit b5dacd8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
10 changes: 9 additions & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
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
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
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

0 comments on commit b5dacd8

Please sign in to comment.