Skip to content

Commit

Permalink
Use specific version for TimeZones.build
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Nov 4, 2019
1 parent f186be5 commit eb1881a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
7 changes: 2 additions & 5 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -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()
10 changes: 6 additions & 4 deletions src/build.jl
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/tzdata/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/tzdata/version.jl
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -24,6 +31,7 @@ const TZDATA_NEWS_REGEX = r"""

const ACTIVE_VERSION_FILE = joinpath(DEPS_DIR, "active_version")


"""
read_news(news, [limit]) -> Vector{AbstractString}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit eb1881a

Please sign in to comment.