Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes v0.7 warnings #85

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ os:
- osx
- linux
julia:
- "0.4"
- "0.5"
- "0.6"
- nightly
notifications:
Expand Down
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.4
Compat 0.25
julia 0.6
Compat 0.27
Mocking 0.2
@windows LightXML 0.2
6 changes: 0 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/exceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/local.jl
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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: ", ""))
Expand All @@ -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()

Expand Down Expand Up @@ -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"`))

Expand Down
8 changes: 4 additions & 4 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/tzdata/archive.jl
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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`
Expand All @@ -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`)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/tzdata/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/tzdata/timeoffset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tzfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/utcoffset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/local.jl
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
8 changes: 4 additions & 4 deletions test/local_mocking.jl
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -27,15 +27,15 @@ 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
end

# 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
Expand Down