Skip to content

Commit

Permalink
Merge pull request #139 from JuliaTime/cv/compat-0.7-alpha
Browse files Browse the repository at this point in the history
Compatibility with Julia 0.7.0-alpha
  • Loading branch information
omus authored Jun 6, 2018
2 parents afcceb9 + 0dac2ed commit be4ebb9
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ os:
- osx
- linux
julia:
- "0.6"
- 0.6
- 0.7
- nightly
notifications:
email: false
Expand All @@ -13,9 +14,7 @@ script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# Avoid setting JULIA_TZ_VERSION if the deps/build.jl file has been modified
- git fetch origin +:refs/remotes/origin/HEAD; if ! git diff --quiet origin/HEAD HEAD -- deps/build.jl; then unset JULIA_TZ_VERSION; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("TimeZones")'
- OPTIONS=$(julia -e 'using Mocking; print(DISABLE_COMPILED_MODULES_STR)')
- julia $OPTIONS -e 'Pkg.test("TimeZones"; coverage=true)'
- julia -e 'Pkg.clone(pwd()); Pkg.build("TimeZones"); Pkg.test("TimeZones"; coverage=true)'
after_success:
- julia -e 'cd(Pkg.dir("TimeZones")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
- julia -e 'cd(Pkg.dir("TimeZones")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.6
Compat 0.62
Compat 0.66
Mocking 0.4.1
Nullables 0.0.3
@windows LightXML 0.2
@windows EzXML 0.6
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

matrix:
allow_failures:
# Failing due to https://github.com/bicycle1885/EzXML.jl/issues/66
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
13 changes: 10 additions & 3 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import Base: +, -, .+, .-, broadcast
import Base: +, -, .+, .-
import Compat: @static

if VERSION < v"0.7.0-DEV.4955"
import Base: broadcast
const broadcasted = broadcast
else
import Base.Broadcast: broadcasted
end

# ZonedDateTime arithmetic
(+)(x::ZonedDateTime) = x
(-)(x::ZonedDateTime, y::ZonedDateTime) = x.utc_datetime - y.utc_datetime
Expand All @@ -18,7 +25,7 @@ function (-)(zdt::ZonedDateTime, p::TimePeriod)
return ZonedDateTime(zdt.utc_datetime - p, timezone(zdt); from_utc=true)
end

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

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

broadcast(::typeof(-), r::StepRange{ZonedDateTime}, p::DatePeriod) = broadcast(+, r, -p)
broadcasted(::typeof(-), r::StepRange{ZonedDateTime}, p::DatePeriod) = broadcast(+, r, -p)
12 changes: 9 additions & 3 deletions src/parse.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Compat.Dates: DateFormat, DatePart, tryparsenext, format, min_width, max_width,
default_format
using Compat: isletter

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

# https://github.com/JuliaLang/julia/pull/25261
if VERSION < v"0.7.0-DEV.5126"
iterate(str::String, i::Int) = next(str, i)
end

function tryparsenext_fixedtz(str, i, len, min_width::Int=1, max_width::Int=0)
tz_start, tz_end = i, 0
min_pos = min_width <= 0 ? i : i + min_width - 1
max_pos = max_width <= 0 ? len : min(chr2ind(str, ind2chr(str,i) + max_width - 1), len)
state = 1
@inbounds while i <= max_pos
c, ii = next(str, i)
c, ii = iterate(str, i)::Tuple{Char, Int}
if state == 1 && (c == '-' || c == '+')
state = 2
tz_end = i
Expand Down Expand Up @@ -49,8 +55,8 @@ function tryparsenext_tz(str, i, len, min_width::Int=1, max_width::Int=0)
min_pos = min_width <= 0 ? i : i + min_width - 1
max_pos = max_width <= 0 ? len : min(chr2ind(str, ind2chr(str,i) + max_width - 1), len)
@inbounds while i <= max_pos
c, ii = next(str, i)
if c == '/' || c == '_' || isalpha(c)
c, ii = iterate(str, i)::Tuple{Char, Int}
if c == '/' || c == '_' || isletter(c)
tz_end = i
else
break
Expand Down
2 changes: 1 addition & 1 deletion src/tzdata/archive.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Compat: @static, Sys, devnull

if Sys.iswindows()
const exe7z = joinpath(JULIA_HOME, "7z.exe")
const exe7z = joinpath(Sys.BINDIR, "7z.exe")
end

"""
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function optional(ex::Expr)
if i in dynamic
name, value = arg.args
new_sig[i] = name
default[dynamic .== i] = value
default[dynamic .== i] .= value
else
new_sig[i] = arg
end
Expand Down
22 changes: 8 additions & 14 deletions src/winzone/WindowsTimeZoneIDs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module WindowsTimeZoneIDs
using Compat: @info

import ...TimeZones: DEPS_DIR
using LightXML
using EzXML

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

function compile(xml_file::AbstractString)
# Get the timezone conversions from the file
xdoc = parse_file(xml_file)
xroot = root(xdoc)
windows_zones = find_element(xroot, "windowsZones")
map_timezones = find_element(windows_zones, "mapTimezones")
map_zones = get_elements_by_tagname(map_timezones, "mapZone")
doc = readxml(xml_file)

# Territory "001" is the global default
map_zones = find(doc, "//mapZone[@territory='001']")

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

# Dictionary to store the windows to time zone conversions
translation = Dict{String,String}()
for map_zone in map_zones
# Territory "001" is the global default
if attribute(map_zone, "territory") == "001"
win_name = attribute(map_zone, "other")
posix_name = attribute(map_zone, "type")
translation[win_name] = posix_name
end
win_name = map_zone["other"]
posix_name = map_zone["type"]
translation[win_name] = posix_name
end

free(xdoc)

return translation
end

Expand Down
18 changes: 5 additions & 13 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using Mocking
using Compat: occursin, @info, @warn
Mocking.enable(force=true)
const compiled_modules_enabled = false

compiled_modules_enabled = Mocking.compiled_modules_enabled()
if compiled_modules_enabled
flag = Mocking.COMPILED_MODULES_FLAG
@warn "`julia` not started with `--$flag=no`. Disabling tests that require Mocking"
else
Mocking.enable()
end

VERSION < v"0.7-" && import Compat: Test
using Test
import Compat: Sys, occursin, @info, @warn
using Compat.Unicode
using Compat.Test
using TimeZones
import TimeZones: PKG_DIR, ARCHIVE_DIR
import TimeZones.TZData: ZoneDict, RuleDict, tzparse, resolve, build
import Compat: Sys
using Compat.Unicode
using Nullables

const TZDATA_VERSION = "2016j"
Expand Down

0 comments on commit be4ebb9

Please sign in to comment.