diff --git a/.travis.yml b/.travis.yml index ab9bcfa41..1431d0145 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ os: - osx - linux julia: - - "0.4" - - "0.5" - "0.6" - nightly notifications: diff --git a/REQUIRE b/REQUIRE index 5d4b55e56..6ab2d2aab 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ -julia 0.4 -Compat 0.25 +julia 0.6 +Compat 0.27 Mocking 0.2 @windows LightXML 0.2 diff --git a/appveyor.yml b/appveyor.yml index 4037d8f45..806f5cf62 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,12 +2,6 @@ environment: JULIA_TZ_VERSION: "2016j" matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe" - COVERAGE: "true" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe" - COVERAGE: "true" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" COVERAGE: "true" - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" diff --git a/src/conversions.jl b/src/conversions.jl index 55a37ac1c..1bde5c53a 100644 --- a/src/conversions.jl +++ b/src/conversions.jl @@ -49,11 +49,11 @@ function zdt2unix(zdt::ZonedDateTime) Dates.datetime2unix(utc(zdt)) end -function zdt2unix{T<:Integer}(::Type{T}, zdt::ZonedDateTime) +function zdt2unix(::Type{T}, zdt::ZonedDateTime) where T<:Integer floor(T, Dates.datetime2unix(utc(zdt))) end -function zdt2unix{T<:Number}(::Type{T}, zdt::ZonedDateTime) +function zdt2unix(::Type{T}, zdt::ZonedDateTime) where T<:Number convert(T, Dates.datetime2unix(utc(zdt))) end diff --git a/src/exceptions.jl b/src/exceptions.jl index 953f31908..75e5b2868 100644 --- a/src/exceptions.jl +++ b/src/exceptions.jl @@ -9,7 +9,7 @@ import Compat: @compat The provided local datetime is ambiguous within the specified timezone. Typically occurs on daylight saving time transitions which "fall back" causing duplicate hour long period. """ -type AmbiguousTimeError <: TimeError +mutable struct AmbiguousTimeError <: TimeError local_dt::DateTime timezone::TimeZone end @@ -26,7 +26,7 @@ The provided local datetime is does not exist within the specified timezone. Typ occurs on daylight saving time transitions which "spring forward" causing an hour long period to be skipped. """ -type NonExistentTimeError <: TimeError +mutable struct NonExistentTimeError <: TimeError local_dt::DateTime timezone::TimeZone end diff --git a/src/local.jl b/src/local.jl index c27464798..1d18ed43b 100644 --- a/src/local.jl +++ b/src/local.jl @@ -1,9 +1,9 @@ # Determine the local system's time zone # Based upon Python's tzlocal https://pypi.python.org/pypi/tzlocal -import Compat: @static, is_apple, is_unix, is_windows, readstring +import Compat: @static, readstring, Sys using Mocking -if is_windows() +if Sys.iswindows() import TimeZones.WindowsTimeZoneIDs: WINDOWS_TRANSLATION end @@ -13,7 +13,7 @@ end Returns a `TimeZone` object that is equivalent to the system's current time zone. """ function localzone() - @static if is_apple() + @static if Sys.isapple() name = @mock readstring(`systemsetup -gettimezone`) # Appears to only work as root if contains(name, "Time Zone: ") name = strip(replace(name, "Time Zone: ", "")) @@ -23,7 +23,7 @@ function localzone() name = match(r"(?<=zoneinfo/).*$", name).match end return TimeZone(name) - elseif is_unix() + elseif Sys.isunix() name = "" validnames = timezone_names() @@ -115,7 +115,7 @@ function localzone() read_tzfile(f, "local") end end - elseif is_windows() + elseif Sys.iswindows() # Windows powershell should be available on Windows 7 and above win_name = strip(@mock readstring(`powershell -Command "[TimeZoneInfo]::Local.Id"`)) diff --git a/src/types.jl b/src/types.jl index ef25f472a..cd2d1497c 100644 --- a/src/types.jl +++ b/src/types.jl @@ -28,7 +28,7 @@ const FIXED_TIME_ZONE_REGEX = r""" A `TimeZone` with a constant offset for all of time. """ -immutable FixedTimeZone <: TimeZone +struct FixedTimeZone <: TimeZone name::Symbol offset::UTCOffset end @@ -89,7 +89,7 @@ function FixedTimeZone(s::AbstractString) return FixedTimeZone(name, offset) end -immutable Transition +struct Transition utc_datetime::DateTime # Instant where new zone applies zone::FixedTimeZone end @@ -101,7 +101,7 @@ Base.isless(x::Transition,y::Transition) = isless(x.utc_datetime,y.utc_datetime) A `TimeZone` with an offset that changes over time. """ -immutable VariableTimeZone <: TimeZone +struct VariableTimeZone <: TimeZone name::Symbol transitions::Vector{Transition} cutoff::Nullable{DateTime} @@ -126,7 +126,7 @@ end # A `DateTime` that includes `TimeZone` information. # """ -immutable ZonedDateTime <: TimeType +struct ZonedDateTime <: TimeType utc_datetime::DateTime timezone::TimeZone zone::FixedTimeZone # The current zone for the utc_datetime. diff --git a/src/tzdata/archive.jl b/src/tzdata/archive.jl index 57a46da21..11b7c05ca 100644 --- a/src/tzdata/archive.jl +++ b/src/tzdata/archive.jl @@ -1,6 +1,6 @@ -import Compat: @static, is_windows +import Compat: @static, Sys -if is_windows() +if Sys.iswindows() const exe7z = joinpath(JULIA_HOME, "7z.exe") end @@ -12,7 +12,7 @@ specified only the files given will be extracted. The `verbose` flag can be used additional information to STDOUT. """ function extract(archive, directory, files=AbstractString[]; verbose::Bool=false) - @static if is_windows() + @static if Sys.iswindows() cmd = pipeline(`$exe7z x $archive -y -so`, `$exe7z x -si -y -ttar -o$directory $files`) else cmd = `tar xvf $archive --directory=$directory $files` @@ -31,7 +31,7 @@ end Determines if the given `path` is an archive. """ function isarchive(path) - @static if is_windows() + @static if Sys.iswindows() success(`$exe7z t $path -y`) else success(`tar tf $path`) @@ -44,7 +44,7 @@ end Returns the file names contained in the `archive`. """ function readarchive(archive) - @static if is_windows() + @static if Sys.iswindows() files = AbstractString[] header = "-" ^ 24 content = false diff --git a/src/tzdata/compile.jl b/src/tzdata/compile.jl index d8b9b86f3..ff9b85378 100644 --- a/src/tzdata/compile.jl +++ b/src/tzdata/compile.jl @@ -16,7 +16,7 @@ else end # Zone type maps to an Olson Timezone database entity -type Zone +mutable struct Zone gmtoffset::TimeOffset save::TimeOffset rules::AbstractString @@ -39,7 +39,7 @@ function Base.isless(x::Zone,y::Zone) end # Rules govern how Daylight Savings transitions happen for a given time zone -type Rule +mutable struct Rule from::Nullable{Int} # First year rule applies to::Nullable{Int} # Rule applies up until, but not including this year month::Int # Month in which DST transition happens diff --git a/src/tzdata/timeoffset.jl b/src/tzdata/timeoffset.jl index c2235efe8..91ae1347d 100644 --- a/src/tzdata/timeoffset.jl +++ b/src/tzdata/timeoffset.jl @@ -3,7 +3,7 @@ import Base.Dates: Period, TimePeriod, Week, Day, Hour, Minute, Second, Millisec value, toms, hour, minute, second # Convenience type for working with HH:MM:SS. -immutable TimeOffset <: TimePeriod +struct TimeOffset <: TimePeriod seconds::Int end const ZERO = TimeOffset(0) @@ -50,7 +50,9 @@ end convert(::Type{Second}, t::TimeOffset) = Second(value(t)) convert(::Type{Millisecond}, t::TimeOffset) = Millisecond(value(t) * 1000) -promote_rule{P<:Union{Week,Day,Hour,Minute,Second}}(::Type{P}, ::Type{TimeOffset}) = Second + +const WDHMS = Union{Week,Day,Hour,Minute,Second} +promote_rule(::Type{P}, ::Type{TimeOffset}) where P<:WDHMS = Second promote_rule(::Type{Millisecond}, ::Type{TimeOffset}) = Millisecond # https://en.wikipedia.org/wiki/ISO_8601#Times diff --git a/src/tzfile.jl b/src/tzfile.jl index b206e175d..96b7da94e 100644 --- a/src/tzfile.jl +++ b/src/tzfile.jl @@ -6,7 +6,7 @@ import Compat: read, unsafe_string const TZFILE_MAX = unix2datetime(typemax(Int32)) -immutable TransitionTimeInfo +struct TransitionTimeInfo gmtoff::Int32 # tt_gmtoff isdst::Int8 # tt_isdst abbrindex::UInt8 # tt_abbrind diff --git a/src/utcoffset.jl b/src/utcoffset.jl index 7c06c153e..e91a80b66 100644 --- a/src/utcoffset.jl +++ b/src/utcoffset.jl @@ -9,7 +9,7 @@ import Base.Dates: AbstractTime, Second, value A `UTCOffset` is an amount of time subtracted from or added to UTC to get the current local time – whether it's standard time or daylight saving time. """ -immutable UTCOffset <: AbstractTime +struct UTCOffset <: AbstractTime std::Second # Standard time offset from UTC in seconds dst::Second # Daylight saving time offset in seconds diff --git a/test/local.jl b/test/local.jl index 2178c48ee..300d634e1 100644 --- a/test/local.jl +++ b/test/local.jl @@ -1,12 +1,12 @@ import TimeZones: TimeZone, localzone -import Compat: is_linux +import Compat: Sys # Ensure that the current system's local time zone is supported. If this test fails make # sure to report it as an issue. @test isa(localzone(), TimeZone) -if is_linux() +if Sys.islinux() # Bad TZ environmental variables withenv("TZ" => "") do @test_throws ErrorException localzone() diff --git a/test/local_mocking.jl b/test/local_mocking.jl index 69067734d..b7b7dac33 100644 --- a/test/local_mocking.jl +++ b/test/local_mocking.jl @@ -1,7 +1,7 @@ import TimeZones: TimeZone, localzone import Mocking: @patch, apply import Base: AbstractCmd -import Compat: is_apple, is_windows, is_linux, readstring +import Compat: Sys, readstring # For mocking make sure we are actually changing the time zone name = string(localzone()) == "Europe/Warsaw" ? "Pacific/Apia" : "Europe/Warsaw" @@ -11,7 +11,7 @@ tzfile_path = joinpath(TZFILE_DIR, split(name, '/')...) win_name = name == "Europe/Warsaw" ? "Central European Standard Time" : "Samoa Standard Time" timezone = TimeZone(name) -if is_apple() +if Sys.isapple() # Determine time zone via systemsetup. patch = @patch readstring(cmd::AbstractCmd) = "Time Zone: " * name * "\n" apply(patch) do @@ -27,7 +27,7 @@ if is_apple() @test localzone() == timezone end -elseif is_windows() +elseif Sys.iswindows() patch = @patch readstring(cmd::AbstractCmd) = "$win_name\r\n" apply(patch) do @test localzone() == timezone @@ -35,7 +35,7 @@ elseif is_windows() # Dateline Standard Time -> Etc/GMT+12 -> UTC-12:00 -elseif is_linux() +elseif Sys.islinux() # Test TZ environmental variable withenv("TZ" => ":$name") do @test localzone() == timezone