Skip to content

Commit be4ebb9

Browse files
authored
Merge pull request #139 from JuliaTime/cv/compat-0.7-alpha
Compatibility with Julia 0.7.0-alpha
2 parents afcceb9 + 0dac2ed commit be4ebb9

File tree

9 files changed

+44
-41
lines changed

9 files changed

+44
-41
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ os:
33
- osx
44
- linux
55
julia:
6-
- "0.6"
6+
- 0.6
7+
- 0.7
78
- nightly
89
notifications:
910
email: false
@@ -13,9 +14,7 @@ script:
1314
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
1415
# Avoid setting JULIA_TZ_VERSION if the deps/build.jl file has been modified
1516
- git fetch origin +:refs/remotes/origin/HEAD; if ! git diff --quiet origin/HEAD HEAD -- deps/build.jl; then unset JULIA_TZ_VERSION; fi
16-
- julia -e 'Pkg.clone(pwd()); Pkg.build("TimeZones")'
17-
- OPTIONS=$(julia -e 'using Mocking; print(DISABLE_COMPILED_MODULES_STR)')
18-
- julia $OPTIONS -e 'Pkg.test("TimeZones"; coverage=true)'
17+
- julia -e 'Pkg.clone(pwd()); Pkg.build("TimeZones"); Pkg.test("TimeZones"; coverage=true)'
1918
after_success:
2019
- julia -e 'cd(Pkg.dir("TimeZones")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
2120
- julia -e 'cd(Pkg.dir("TimeZones")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
julia 0.6
2-
Compat 0.62
2+
Compat 0.66
33
Mocking 0.4.1
44
Nullables 0.0.3
5-
@windows LightXML 0.2
5+
@windows EzXML 0.6

appveyor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ environment:
44
matrix:
55
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
66
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
7+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
8+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
79
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
810
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
911

1012
matrix:
1113
allow_failures:
14+
# Failing due to https://github.com/bicycle1885/EzXML.jl/issues/66
15+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
16+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
1217
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
1318
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
1419

src/arithmetic.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import Base: +, -, .+, .-, broadcast
1+
import Base: +, -, .+, .-
22
import Compat: @static
33

4+
if VERSION < v"0.7.0-DEV.4955"
5+
import Base: broadcast
6+
const broadcasted = broadcast
7+
else
8+
import Base.Broadcast: broadcasted
9+
end
10+
411
# ZonedDateTime arithmetic
512
(+)(x::ZonedDateTime) = x
613
(-)(x::ZonedDateTime, y::ZonedDateTime) = x.utc_datetime - y.utc_datetime
@@ -18,7 +25,7 @@ function (-)(zdt::ZonedDateTime, p::TimePeriod)
1825
return ZonedDateTime(zdt.utc_datetime - p, timezone(zdt); from_utc=true)
1926
end
2027

21-
function broadcast(::typeof(+), r::StepRange{ZonedDateTime}, p::DatePeriod)
28+
function broadcasted(::typeof(+), r::StepRange{ZonedDateTime}, p::DatePeriod)
2229
start, step, stop = first(r), Base.step(r), last(r)
2330

2431
# Since the localtime + period can result in an invalid local datetime when working with
@@ -42,4 +49,4 @@ function broadcast(::typeof(+), r::StepRange{ZonedDateTime}, p::DatePeriod)
4249
return StepRange(start, step, stop)
4350
end
4451

45-
broadcast(::typeof(-), r::StepRange{ZonedDateTime}, p::DatePeriod) = broadcast(+, r, -p)
52+
broadcasted(::typeof(-), r::StepRange{ZonedDateTime}, p::DatePeriod) = broadcast(+, r, -p)

src/parse.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Compat.Dates: DateFormat, DatePart, tryparsenext, format, min_width, max_width,
22
default_format
3+
using Compat: isletter
34

45
# Handle Nullable deprecation on Julia 0.7
56
if VERSION < v"0.7.0-DEV.3017"
@@ -8,13 +9,18 @@ else
89
nullable(T::Type, x) = x # Ignore nullable container type T
910
end
1011

12+
# https://github.com/JuliaLang/julia/pull/25261
13+
if VERSION < v"0.7.0-DEV.5126"
14+
iterate(str::String, i::Int) = next(str, i)
15+
end
16+
1117
function tryparsenext_fixedtz(str, i, len, min_width::Int=1, max_width::Int=0)
1218
tz_start, tz_end = i, 0
1319
min_pos = min_width <= 0 ? i : i + min_width - 1
1420
max_pos = max_width <= 0 ? len : min(chr2ind(str, ind2chr(str,i) + max_width - 1), len)
1521
state = 1
1622
@inbounds while i <= max_pos
17-
c, ii = next(str, i)
23+
c, ii = iterate(str, i)::Tuple{Char, Int}
1824
if state == 1 && (c == '-' || c == '+')
1925
state = 2
2026
tz_end = i
@@ -49,8 +55,8 @@ function tryparsenext_tz(str, i, len, min_width::Int=1, max_width::Int=0)
4955
min_pos = min_width <= 0 ? i : i + min_width - 1
5056
max_pos = max_width <= 0 ? len : min(chr2ind(str, ind2chr(str,i) + max_width - 1), len)
5157
@inbounds while i <= max_pos
52-
c, ii = next(str, i)
53-
if c == '/' || c == '_' || isalpha(c)
58+
c, ii = iterate(str, i)::Tuple{Char, Int}
59+
if c == '/' || c == '_' || isletter(c)
5460
tz_end = i
5561
else
5662
break

src/tzdata/archive.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Compat: @static, Sys, devnull
22

33
if Sys.iswindows()
4-
const exe7z = joinpath(JULIA_HOME, "7z.exe")
4+
const exe7z = joinpath(Sys.BINDIR, "7z.exe")
55
end
66

77
"""

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function optional(ex::Expr)
4848
if i in dynamic
4949
name, value = arg.args
5050
new_sig[i] = name
51-
default[dynamic .== i] = value
51+
default[dynamic .== i] .= value
5252
else
5353
new_sig[i] = arg
5454
end

src/winzone/WindowsTimeZoneIDs.jl

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module WindowsTimeZoneIDs
33
using Compat: @info
44

55
import ...TimeZones: DEPS_DIR
6-
using LightXML
6+
using EzXML
77

88
# A mapping of Windows timezone names to Olson timezone names.
99
# Details on the contents of this file can be found at:
@@ -17,27 +17,21 @@ isdir(WINDOWS_XML_DIR) || mkdir(WINDOWS_XML_DIR)
1717

1818
function compile(xml_file::AbstractString)
1919
# Get the timezone conversions from the file
20-
xdoc = parse_file(xml_file)
21-
xroot = root(xdoc)
22-
windows_zones = find_element(xroot, "windowsZones")
23-
map_timezones = find_element(windows_zones, "mapTimezones")
24-
map_zones = get_elements_by_tagname(map_timezones, "mapZone")
20+
doc = readxml(xml_file)
21+
22+
# Territory "001" is the global default
23+
map_zones = find(doc, "//mapZone[@territory='001']")
2524

2625
# TODO: Eliminate the Etc/* POSIX names here? See Windows section of `localzone`
2726

2827
# Dictionary to store the windows to time zone conversions
2928
translation = Dict{String,String}()
3029
for map_zone in map_zones
31-
# Territory "001" is the global default
32-
if attribute(map_zone, "territory") == "001"
33-
win_name = attribute(map_zone, "other")
34-
posix_name = attribute(map_zone, "type")
35-
translation[win_name] = posix_name
36-
end
30+
win_name = map_zone["other"]
31+
posix_name = map_zone["type"]
32+
translation[win_name] = posix_name
3733
end
3834

39-
free(xdoc)
40-
4135
return translation
4236
end
4337

test/runtests.jl

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
using Mocking
2-
using Compat: occursin, @info, @warn
2+
Mocking.enable(force=true)
3+
const compiled_modules_enabled = false
34

4-
compiled_modules_enabled = Mocking.compiled_modules_enabled()
5-
if compiled_modules_enabled
6-
flag = Mocking.COMPILED_MODULES_FLAG
7-
@warn "`julia` not started with `--$flag=no`. Disabling tests that require Mocking"
8-
else
9-
Mocking.enable()
10-
end
11-
12-
VERSION < v"0.7-" && import Compat: Test
13-
using Test
5+
import Compat: Sys, occursin, @info, @warn
6+
using Compat.Unicode
7+
using Compat.Test
148
using TimeZones
159
import TimeZones: PKG_DIR, ARCHIVE_DIR
1610
import TimeZones.TZData: ZoneDict, RuleDict, tzparse, resolve, build
17-
import Compat: Sys
18-
using Compat.Unicode
1911
using Nullables
2012

2113
const TZDATA_VERSION = "2016j"

0 commit comments

Comments
 (0)