diff --git a/deps/build.jl b/deps/build.jl index c1f83ca43..17cfff643 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,6 +1,3 @@ -import TimeZones: build +using TimeZones: build -# ENV variable allows users to modify the default to be "latest". Do NOT use "latest" -# as the default here as can make it difficult to debug to past versions of working code. -# Note: Also allows us to only download a single tzdata version during CI jobs. -build(get(ENV, "JULIA_TZ_VERSION", "2019c")) +build() diff --git a/src/build.jl b/src/build.jl index 39691d69d..e3dadfbd8 100644 --- a/src/build.jl +++ b/src/build.jl @@ -1,11 +1,13 @@ +using TimeZones.TZData: DEFAULT_TZDATA_VERSION, tzdata_version + """ - build(version="latest"; force=false) -> Nothing + build(version="$DEFAULT_TZDATA_VERSION"; force=false) -> Nothing Builds the TimeZones package with the specified tzdata `version` and `regions`. The -`version` is typically a 4-digit year followed by a lowercase ASCII letter (e.g. "2016j"). -The `force` flag is used to re-download tzdata archives. +`version` is typically a 4-digit year followed by a lowercase ASCII letter +(e.g. "$DEFAULT_TZDATA_VERSION"). The `force` flag is used to re-download tzdata archives. """ -function build(version::AbstractString="latest"; force::Bool=false) +function build(version::AbstractString=tzdata_version(); force::Bool=false) TimeZones.TZData.build(version) if Sys.iswindows() diff --git a/src/tzdata/build.jl b/src/tzdata/build.jl index 15f716326..226f04776 100644 --- a/src/tzdata/build.jl +++ b/src/tzdata/build.jl @@ -68,7 +68,7 @@ function build( return version end -function build(version::AbstractString="latest") +function build(version::AbstractString=tzdata_version()) isdir(ARCHIVE_DIR) || mkdir(ARCHIVE_DIR) isdir(TZ_SOURCE_DIR) || mkdir(TZ_SOURCE_DIR) isdir(COMPILED_DIR) || mkdir(COMPILED_DIR) diff --git a/src/tzdata/version.jl b/src/tzdata/version.jl index d0c679e29..c4f542dac 100644 --- a/src/tzdata/version.jl +++ b/src/tzdata/version.jl @@ -1,3 +1,10 @@ +# Default tzdata version to use if the environmental variable "JULIA_TZ_VERSION" is not set. +# We want to use a specific version here to ensure that specific revisions of the +# TimeZones.jl package always use the same revision of tzdata. Doing so ensure that we can +# always use older revisions of this package and always reproduce the same results. +const DEFAULT_TZDATA_VERSION = "2019c" # Do not use floating revision "latest" here + + # Note: A tz code or data version consists of a year and letter while a release consists of # a pair of tz code and data versions. In recent releases the tz code and data use the same # version. @@ -24,6 +31,7 @@ const TZDATA_NEWS_REGEX = r""" const ACTIVE_VERSION_FILE = joinpath(DEPS_DIR, "active_version") + """ read_news(news, [limit]) -> Vector{AbstractString} @@ -89,6 +97,8 @@ function tzdata_version_archive(archive::AbstractString) end end +tzdata_version() = get(ENV, "JULIA_TZ_VERSION", DEFAULT_TZDATA_VERSION) + function active_version() if !isfile(ACTIVE_VERSION_FILE) error("No active tzdata version. Try re-building TimeZones")