diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7cd6b1fc0..39fbc8b13 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,7 +16,7 @@ jobs: fail-fast: true matrix: version: - - "1.0" # LTS + - "1.3" # oldest supported version - "1" # Latest release - nightly os: @@ -94,7 +94,7 @@ jobs: fail-fast: true matrix: version: - - "1.0" + - "1.3" - nightly os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 4fbbf3f60..aa0486b5b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,10 +1,11 @@ name = "TimeZones" uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" authors = ["Curtis Vogt "] -version = "1.5.9" +version = "1.6.0" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" Future = "9fa8497b-333b-5362-9e8d-4d0656e87820" LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" Mocking = "78c3b35d-d492-501b-9361-3d52fe80e533" @@ -15,9 +16,10 @@ Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [compat] +Downloads = "1" Mocking = "0.7" RecipesBase = "0.7, 0.8, 1" -julia = "1" +julia = "1.3" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/types/timezone.jl b/src/types/timezone.jl index 7d198b936..8a381c137 100644 --- a/src/types/timezone.jl +++ b/src/types/timezone.jl @@ -135,11 +135,3 @@ function istimezone(str::AbstractString, mask::Class=Class(:DEFAULT)) return tz !== nothing && mask & class != Class(:NONE) end - -# After `broadcastable` was defined but before this was addressed in the `Dates` stdlib -# - Broadcastable introduction: https://github.com/JuliaLang/julia/pull/26601 -# - Fixed in Dates: https://github.com/JuliaLang/julia/pull/30159 -# Note: The change was backported to 1.1 as well. -if v"0.7.0-DEV.4743" <= VERSION < v"1.1.0-DEV.722" || v"1.2-" <= VERSION < v"1.2.0-DEV.114" - Base.broadcastable(tz::TimeZone) = Ref(tz) -end diff --git a/src/tzdata/TZData.jl b/src/tzdata/TZData.jl index 54843de0b..cc0a2209a 100644 --- a/src/tzdata/TZData.jl +++ b/src/tzdata/TZData.jl @@ -2,13 +2,11 @@ module TZData using Printf using ...TimeZones: DEPS_DIR +using ...TimeZones: @artifact_str import Pkg +using Pkg.Artifacts: artifact_hash -if VERSION >= v"1.3" - using ...TimeZones: @artifact_str - using Pkg.Artifacts: artifact_hash -end # Note: The tz database is made up of two parts: code and data. TimeZones.jl only requires # the "tzdata" archive or more specifically the "tz source" files within the archive diff --git a/src/tzdata/build.jl b/src/tzdata/build.jl index 7d261e071..9490bce01 100644 --- a/src/tzdata/build.jl +++ b/src/tzdata/build.jl @@ -1,10 +1,5 @@ using ...TimeZones: Class -if VERSION >= v"1.3" - # Artifacts introduced in Pkg v1.3 - # Using Pkg instead of using LazyArtifacts is deprecated on 1.6.0-beta1.15 and 1.7.0-DEV.302 - # LazyArtifacts.jl available for v1.3 and up - using LazyArtifacts -end +using LazyArtifacts # The default tz source files we care about. See "ftp://ftp.iana.org/tz/data/Makefile" # "PRIMARY_YDATA" for listing of tz source files to include. @@ -34,70 +29,36 @@ function build( compiled_dir::AbstractString=""; verbose::Bool=false, ) - @static if VERSION >= v"1.3" - # Determine the current "latest" version but limit how often we check with remote - # servers. - if version == "latest" - latest_version = latest_cached() - - # Retrieve the current latest version the cached latest has expired - if latest_version === nothing - latest_version = last(tzdata_versions()) - tzdata_hash = artifact_hash("tzdata$latest_version", ARTIFACT_TOML) - - if tzdata_hash === nothing - error("Latest tzdata is $latest_version which is not present in the Artifacts.toml") - end - - set_latest_cached(latest_version) - end - version = latest_version - end + # Determine the current "latest" version but limit how often we check with remote + # servers. + if version == "latest" + latest_version = latest_cached() - artifact_dir = @artifact_str "tzdata$version" + # Retrieve the current latest version the cached latest has expired + if latest_version === nothing + latest_version = last(tzdata_versions()) + tzdata_hash = artifact_hash("tzdata$latest_version", ARTIFACT_TOML) - if !isempty(tz_source_dir) - @info "Installing $version tzdata region data" - regions = union!(intersect(regions, readdir(artifact_dir)), CUSTOM_REGIONS) - for region in setdiff(regions, CUSTOM_REGIONS) - cp(joinpath(artifact_dir, region), joinpath(tz_source_dir, region), force=true) + if tzdata_hash === nothing + error("Latest tzdata is $latest_version which is not present in the Artifacts.toml") end - end - else - # Avoids spamming remote servers requesting the latest version - if version == "latest" - v = latest_cached() - - if v !== nothing - version = v - @info "Latest tzdata is $version" - end - end - archive = joinpath(archive_dir, "tzdata$version.tar.gz") + set_latest_cached(latest_version) + end - # Avoid downloading a tzdata archive if we already have a local copy - if version == "latest" || !isfile(archive) - @info "Downloading $version tzdata" - archive = tzdata_download(version, archive_dir) + version = latest_version + end - if version == "latest" - m = match(TZDATA_VERSION_REGEX, basename(archive)) - if m !== nothing - version = m.match - @info "Latest tzdata is $version" - end - end - end + artifact_dir = @artifact_str "tzdata$version" - if !isempty(tz_source_dir) - @info "Extracting $version tzdata archive" - regions = union!(intersect(regions, readarchive(archive)), CUSTOM_REGIONS) - extract(archive, tz_source_dir, setdiff(regions, CUSTOM_REGIONS), verbose=verbose) + if !isempty(tz_source_dir) + @info "Installing $version tzdata region data" + regions = union!(intersect(regions, readdir(artifact_dir)), CUSTOM_REGIONS) + for region in setdiff(regions, CUSTOM_REGIONS) + cp(joinpath(artifact_dir, region), joinpath(tz_source_dir, region), force=true) end end - if !isempty(compiled_dir) @info "Converting tz source files into TimeZone data" tz_source = TZSource(joinpath.(tz_source_dir, regions)) diff --git a/src/tzdata/download.jl b/src/tzdata/download.jl index 8bc3aa930..939c5bbe1 100644 --- a/src/tzdata/download.jl +++ b/src/tzdata/download.jl @@ -1,13 +1,7 @@ using Dates +using Downloads: download using TimeZones: DEPS_DIR -if VERSION >= v"1.6.0-DEV.923" - # Use Downloads.jl once TimeZones.jl drops support for Julia versions < 1.3 - download(args...) = Base.invokelatest(Base.Downloads().download, args...) -else - using Base: download -end - const LATEST_FILE = joinpath(DEPS_DIR, "latest") const LATEST_FORMAT = Dates.DateFormat("yyyy-mm-ddTHH:MM:SS") const LATEST_DELAY = Hour(1) # In 1996 a correction to a release was made an hour later diff --git a/src/winzone/WindowsTimeZoneIDs.jl b/src/winzone/WindowsTimeZoneIDs.jl index a989dc5e7..0de91189a 100644 --- a/src/winzone/WindowsTimeZoneIDs.jl +++ b/src/winzone/WindowsTimeZoneIDs.jl @@ -1,13 +1,9 @@ module WindowsTimeZoneIDs -using ...TimeZones: DEPS_DIR +using LazyArtifacts +using ...TimeZones: DEPS_DIR, @artifact_str using Future: copy! -if VERSION >= v"1.3" - using LazyArtifacts - using ...TimeZones: @artifact_str -end - const UNICODE_CLDR_VERSION = "release-39" # A mapping of Windows timezone names to Olson timezone names. @@ -53,12 +49,7 @@ end function build(xml_file::AbstractString=WINDOWS_XML_FILE; force::Bool=false) if !isfile(xml_file) || force @info "Downloading Windows to POSIX timezone ID XML version: $UNICODE_CLDR_VERSION" - @static if VERSION >= v"1.3" - artifact_dir = @artifact_str "unicode-cldr-$UNICODE_CLDR_VERSION" - cp(joinpath(artifact_dir, WINDOWS_ZONE_FILE), xml_file, force=true) - else - download(WINDOWS_ZONE_URL, xml_file) - end + download(WINDOWS_ZONE_URL, xml_file) end @info "Compiling Windows time zone name translation" diff --git a/test/runtests.jl b/test/runtests.jl index e758728af..0debc4779 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,11 +15,6 @@ const TZ_SOURCE_DIR = get(ENV, "TZ_SOURCE_DIR", joinpath(PKG_DIR, "test", "tzsou const TZFILE_DIR = joinpath(PKG_DIR, "test", "tzfile") const TEST_REGIONS = ["asia", "australasia", "europe", "northamerica"] -# https://github.com/JuliaLang/julia/pull/27900 -if VERSION < v"1.2.0-DEV.642" - const ProcessFailedException = ErrorException -end - isdir(ARCHIVE_DIR) || mkdir(ARCHIVE_DIR) isdir(TZ_SOURCE_DIR) || mkdir(TZ_SOURCE_DIR) @@ -72,7 +67,7 @@ include("helpers.jl") include("rounding.jl") include("parse.jl") include("plotting.jl") - VERSION >= v"1.3" && include("thread-safety.jl") + include("thread-safety.jl") # Note: Run the build tests last to ensure that re-compiling the time zones files # doesn't interfere with other tests. diff --git a/test/thread-safety.jl b/test/thread-safety.jl index b2028e590..cb123448c 100644 --- a/test/thread-safety.jl +++ b/test/thread-safety.jl @@ -63,5 +63,7 @@ end @info "Running Thread Safety tests" @testset "Multithreaded TimeZone construction" begin - run(`$(Base.julia_cmd()) -t8 --proj -E $(program)`) + withenv("JULIA_NUM_THREADS" => "8") do + run(`$(Base.julia_cmd()) --proj -E $(program)`) + end end diff --git a/test/tzdata/archive.jl b/test/tzdata/archive.jl index 2d78515a8..679645a78 100644 --- a/test/tzdata/archive.jl +++ b/test/tzdata/archive.jl @@ -1,16 +1,7 @@ using TimeZones.TZData: ARCHIVE_DIR, isarchive, readarchive, extract, tzdata_download -const ARCHIVE_PATH = let - if VERSION < v"1.3" - archives = filter(file -> endswith(file, "tar.gz"), readdir(ARCHIVE_DIR)) - isempty(archives) && error("Unable to run archive tests without first running Pkg.build(\"TimeZones\")") - joinpath(ARCHIVE_DIR, first(archives)) - else - # For Julia versions that use artifacts we'll need to retrieve an archive only for - # testing purposes. - tzdata_download(TZDATA_VERSION, ARCHIVE_DIR) - end -end +# Retrieve an archive only for testing purposes. +const ARCHIVE_PATH = tzdata_download(TZDATA_VERSION, ARCHIVE_DIR) @test isarchive(ARCHIVE_PATH) @test !isarchive(@__FILE__) diff --git a/test/tzdata/version.jl b/test/tzdata/version.jl index a6e58b7a2..313c4a443 100644 --- a/test/tzdata/version.jl +++ b/test/tzdata/version.jl @@ -1,12 +1,8 @@ +using TimeZones: @artifact_str using TimeZones.TZData: ARCHIVE_DIR, TZDATA_VERSION_REGEX, TZDATA_NEWS_REGEX using TimeZones.TZData: read_news, extract, tzdata_version_dir, tzdata_version_archive using TimeZones.TZData: active_version, active_archive -use_artifacts = VERSION >= v"1.3" - -if use_artifacts - using TimeZones: @artifact_str -end for year = ("12", "1234"), letter = ("", "z") version = year * letter @@ -34,20 +30,10 @@ end @test match(TZDATA_NEWS_REGEX, "Release 199") === nothing @test match(TZDATA_NEWS_REGEX, "Release 19999") === nothing - -@static if use_artifacts - artifact_dir = @artifact_str "tzdata$TZDATA_VERSION" -else - archive = joinpath(ARCHIVE_DIR, "tzdata$TZDATA_VERSION.tar.gz") -end - +artifact_dir = @artifact_str "tzdata$TZDATA_VERSION" mktempdir() do temp_dir # Read the first tzdata version - if use_artifacts - cp(joinpath(artifact_dir, "NEWS"), joinpath(temp_dir, "NEWS")) - else - extract(archive, temp_dir, "NEWS") - end + cp(joinpath(artifact_dir, "NEWS"), joinpath(temp_dir, "NEWS")) versions = read_news(joinpath(temp_dir, "NEWS"), 1) @test versions == [TZDATA_VERSION] @@ -66,19 +52,7 @@ mktempdir() do temp_dir @test_throws ErrorException tzdata_version_dir(dirname(@__FILE__)) end -if !use_artifacts - @test tzdata_version_archive(archive) == TZDATA_VERSION - @test_throws ProcessFailedException tzdata_version_archive(@__FILE__) == TZDATA_VERSION -end - # Active/built tzdata version version = active_version() @test version != "latest" # Could happen if the logic to resolve the version fails @test match(TZDATA_VERSION_REGEX, version) !== nothing - -if !use_artifacts - archive = active_archive() - @test isfile(archive) - @test dirname(archive) == ARCHIVE_DIR - @test basename(archive) == "tzdata$version.tar.gz" -end diff --git a/test/utcoffset.jl b/test/utcoffset.jl index 656da057a..81d5a1b73 100644 --- a/test/utcoffset.jl +++ b/test/utcoffset.jl @@ -54,7 +54,6 @@ end # - https://github.com/JuliaLang/julia/issues/30901 # - https://github.com/JuliaLang/julia/pull/33178 if ( - v"1.2.0-DEV.223" <= VERSION < v"1.2.0-pre.39" || v"1.3-DEV" <= VERSION < v"1.3.0-rc1.33" || v"1.4-DEV" <= VERSION < v"1.4.0-DEV.620" || v"1.5.0-DEV.163" <= VERSION