From c17814e0f29d52f6bd2a5057ee105e75850c2e0a Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Sun, 10 Jul 2022 00:45:03 -0500 Subject: [PATCH] Build at package initialization time if required --- src/TimeZones.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/TimeZones.jl b/src/TimeZones.jl index 98f6b4710..ad1320540 100644 --- a/src/TimeZones.jl +++ b/src/TimeZones.jl @@ -44,12 +44,17 @@ const _COMPILED_DIR = Ref{String}() abstract type Local <: TimeZone end function __init__() - # Write out our compiled tzdata representations into a scratchspace - _COMPILED_DIR[] = _compiled_dir(tzdata_version()) - # Initialize the thread-local TimeZone cache (issue #342) _reset_tz_cache() + # Write out our compiled tzdata representations into a scratchspace + version = tzdata_version() + _COMPILED_DIR[] = _compiled_dir(version) + + # Build the time zone data if required. Should only occur when `JULIA_TZ_VERSION` is + # specified we to a version not previously built. + isdir(_COMPILED_DIR[]) || build(version) + # Base extension needs to happen everytime the module is loaded (issue #24) Dates.CONVERSION_SPECIFIERS['z'] = TimeZone Dates.CONVERSION_SPECIFIERS['Z'] = TimeZone