From adad8ca3d843d455d71a0433a51fbd9117211a03 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Wed, 25 Oct 2023 00:50:18 +0200 Subject: [PATCH 01/10] move from CLDR artifact to code generation --- dev/Manifest.toml | 167 +++++++---------------------- dev/Project.toml | 13 +-- dev/generate_artifacts.jl | 89 --------------- dev/generate_windows_zones.jl | 68 ++++++++++++ src/TimeZones.jl | 2 +- src/build.jl | 4 - src/local.jl | 4 - src/windows_zones.jl | 145 +++++++++++++++++++++++++ src/winzone/WindowsTimeZoneIDs.jl | 64 ----------- test/runtests.jl | 2 +- test/windows_zones.jl | 3 + test/winzone/WindowsTimeZoneIDs.jl | 20 ---- 12 files changed, 255 insertions(+), 326 deletions(-) delete mode 100644 dev/generate_artifacts.jl create mode 100644 dev/generate_windows_zones.jl create mode 100644 src/windows_zones.jl delete mode 100644 src/winzone/WindowsTimeZoneIDs.jl create mode 100644 test/windows_zones.jl delete mode 100644 test/winzone/WindowsTimeZoneIDs.jl diff --git a/dev/Manifest.toml b/dev/Manifest.toml index 0e529800b..baf24e7aa 100644 --- a/dev/Manifest.toml +++ b/dev/Manifest.toml @@ -1,12 +1,8 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.1" +julia_version = "1.9.3" manifest_format = "2.0" -project_hash = "b01971d38151b463d98e1f373278d7dad753ef71" - -[[deps.ArgTools]] -uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" +project_hash = "26b2187be7743c6ac46f50f5788f9b2373dbd216" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -21,22 +17,9 @@ version = "0.1.7" [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] -git-tree-sha1 = "02aa26a4cf76381be7f66e020a3eddeb27b0a092" +git-tree-sha1 = "cd67fc487743b2f0fd4380d4cbd3a24660d0eec8" uuid = "944b1d66-785c-5afd-91f1-9de20f533193" -version = "0.7.2" - -[[deps.Compat]] -deps = ["UUIDs"] -git-tree-sha1 = "e460f044ca8b99be31d35fe54fc33a5c33dd8ed7" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.9.0" - - [deps.Compat.extensions] - CompatLinearAlgebraExt = "LinearAlgebra" - - [deps.Compat.weakdeps] - Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" - LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "0.7.3" [[deps.ConcurrentUtilities]] deps = ["Serialization", "Sockets"] @@ -48,46 +31,27 @@ version = "2.2.1" deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -[[deps.Downloads]] -deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] -uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" -version = "1.6.0" - [[deps.ExceptionUnwrapping]] deps = ["Test"] git-tree-sha1 = "e90caa41f5a86296e014e148ee061bd6c3edec96" uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4" version = "0.1.9" -[[deps.ExprTools]] -git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec" -uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" -version = "0.1.10" - -[[deps.FileWatching]] -uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" - [[deps.HTTP]] deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "cb56ccdd481c0dd7f975ad2b3b62d9eda088f7e2" +git-tree-sha1 = "5eab648309e2e060198b45820af1a37182de3cce" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.9.14" - -[[deps.InlineStrings]] -deps = ["Parsers"] -git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461" -uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" -version = "1.4.0" +version = "1.10.0" [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[deps.JLLWrappers]] -deps = ["Preferences"] -git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.4.1" +version = "1.5.0" [[deps.JSON3]] deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"] @@ -95,25 +59,6 @@ git-tree-sha1 = "95220473901735a0f4df9d1ca5b171b568b2daa3" uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" version = "1.13.2" -[[deps.LibCURL]] -deps = ["LibCURL_jll", "MozillaCACerts_jll"] -uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" - -[[deps.LibCURL_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] -uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" - -[[deps.LibGit2]] -deps = ["Base64", "NetworkOptions", "Printf", "SHA"] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" - -[[deps.LibSSH2_jll]] -deps = ["Artifacts", "Libdl", "MbedTLS_jll"] -uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" - [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -122,9 +67,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] -git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e" +git-tree-sha1 = "c1dd6d7978c12545b4179fb6153b9250c96b0075" uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" -version = "1.0.0" +version = "1.0.3" [[deps.Markdown]] deps = ["Base64"] @@ -144,12 +89,6 @@ version = "2.28.2+0" [[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" -[[deps.Mocking]] -deps = ["Compat", "ExprTools"] -git-tree-sha1 = "4cc0c5a83933648b615c36c2b956d94fda70641e" -uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" -version = "0.7.7" - [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" version = "2022.10.11" @@ -166,9 +105,14 @@ version = "1.4.1" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "e78db7bd5c26fc5a6911b50a47ee302219157ea8" +git-tree-sha1 = "ceeda72c9fd6bbebc4f4f598560789145a8b6c4c" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.0.10+0" +version = "3.0.11+0" + +[[deps.OrderedCollections]] +git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.6.2" [[deps.Parsers]] deps = ["Dates", "PrecompileTools", "UUIDs"] @@ -176,51 +120,30 @@ git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" version = "2.7.2" -[[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.9.0" - [[deps.PrecompileTools]] deps = ["Preferences"] -git-tree-sha1 = "9673d39decc5feece56ef3940e5dafba15ba0f81" +git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -version = "1.1.2" +version = "1.2.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" +git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.0" +version = "1.4.1" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" -[[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - [[deps.Random]] deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -[[deps.RecipesBase]] -deps = ["PrecompileTools"] -git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff" -uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.3.4" - [[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" version = "0.7.0" -[[deps.Scratch]] -deps = ["Dates"] -git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a" -uuid = "6c6a2e73-6563-6170-7368-637461726353" -version = "1.2.0" - [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -243,37 +166,23 @@ deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" version = "1.0.3" -[[deps.TZJData]] -deps = ["Artifacts"] -git-tree-sha1 = "b32799596731e3d712cdf085b18a26f271ce110c" -uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7" -version = "0.0.1+2023c" - -[[deps.Tar]] -deps = ["ArgTools", "SHA"] -uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" -version = "1.10.0" - [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -[[deps.TimeZones]] -deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "RecipesBase", "Scratch", "TZJData", "Unicode"] -path = ".." -uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" -version = "1.11.0" - [[deps.TranscodingStreams]] -deps = ["Random", "Test"] -git-tree-sha1 = "9a6ae7ed916312b41236fcef7e0af564ef934769" +git-tree-sha1 = "49cbf7c74fafaed4c529d47d48c8f7da6a19eb75" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.9.13" +version = "0.10.1" +weakdeps = ["Random", "Test"] + + [deps.TranscodingStreams.extensions] + TestExt = ["Test", "Random"] [[deps.URIs]] -git-tree-sha1 = "b7a5e99f24892b6824a954199a45e9ffcc1c70f0" +git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.5.0" +version = "1.5.1" [[deps.UUIDs]] deps = ["Random", "SHA"] @@ -282,17 +191,13 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +[[deps.XML]] +deps = ["Mmap", "OrderedCollections"] +git-tree-sha1 = "a08437e8fc5729a47258bc8f6d846d167516bf69" +uuid = "72c71f33-b9b6-44de-8c94-c961784809e2" +version = "0.3.1" + [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" version = "1.2.13+0" - -[[deps.nghttp2_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" - -[[deps.p7zip_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.4.0+0" diff --git a/dev/Project.toml b/dev/Project.toml index 9172f93e2..6062968ea 100644 --- a/dev/Project.toml +++ b/dev/Project.toml @@ -1,20 +1,9 @@ [deps] -CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" -Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" -Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" -TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" +XML = "72c71f33-b9b6-44de-8c94-c961784809e2" [compat] -CodecZlib = "0.7" -Downloads = "1.6" HTTP = "1" JSON3 = "1" -Pkg = "1.6" -SHA = "0.7" -Tar = "1" -TimeZones = "1" julia = "1.8" diff --git a/dev/generate_artifacts.jl b/dev/generate_artifacts.jl deleted file mode 100644 index 97226216a..000000000 --- a/dev/generate_artifacts.jl +++ /dev/null @@ -1,89 +0,0 @@ -using Base: SHA1 -using Base.BinaryPlatforms: Platform -using CodecZlib: GzipDecompressorStream -using Downloads: download -using JSON3: JSON3 -using HTTP: HTTP -using Pkg.Artifacts: bind_artifact!, load_artifacts_toml, unbind_artifact! -using SHA: SHA -using Tar: Tar -using TimeZones.TZData: tzdata_versions - -function update_uncode_cldr_artifacts!(artifacts_toml::AbstractString) - @info "Checking for latest Unicode CLDR release..." - response = HTTP.get("https://api.github.com/repos/unicode-org/cldr/releases/latest") - json = JSON3.read(response.body) - latest_unicode_cldr = json.tag_name # latest release - - @info "Latest Unicode CLDR release: $latest_unicode_cldr" - url = "https://github.com/unicode-org/cldr/archive/$latest_unicode_cldr.tar.gz" - - artifact_dict = load_artifacts_toml(artifacts_toml) - unicode_artifacts = filter(startswith("unicode-cldr-"), keys(artifact_dict)) - - # Determine the checksum information from the artifacts or the download. - name = "unicode-cldr-$latest_unicode_cldr" - if name in unicode_artifacts - # Assumes that the same artifact is used across various platforms. That is true - # for our use of the unicode-cldr artifact. - info = first(artifact_dict[name]) - git_tree_sha1 = SHA1(info["git-tree-sha1"]) - sha256 = only(info["download"])["sha256"] - else - @info "Processing new artifact: $name" - tarball = download(tarball_url, IOBuffer()) - - # Compute the Artifact.toml `sha256` from the compressed archive. - sha256 = bytes2hex(SHA.sha256(seekstart(tarball))) - - # Compute the Artifact.toml `git-tree-sha1`. Usually this is computed via - # `Artifacts.create_artifact` but we want to avoid actually storing this data as an - # artifact. - git_tree_sha1 = SHA1(Tar.tree_hash(GzipDecompressorStream(seekstart(tarball)))) - end - - download_info = [(url, sha256)] - platforms = [ - Platform("x86_64", "windows"), - Platform("i686", "windows"), - ] - - # Clear out old unicode-cldr versions by unbinding all of the relevant artifacts and - # only binding the latest version. - unbind_artifact!.(artifacts_toml, unicode_artifacts) - for platform in platforms - bind_artifact!(artifacts_toml, name, git_tree_sha1; platform, download_info) - end - - return latest_unicode_cldr -end - - -function update_artifacts!(artifacts_toml::String) - @info "Determining latest tzdata version..." - versions = tzdata_versions() - latest_tzdata = last(versions) - - latest_unicode_cldr = update_uncode_cldr_artifacts!(artifacts_toml) - - # Display the information on the latest releases which is useful for updating the - # TimeZones package defaults. - println(""" - - Latest releases: - tzdata: $latest_tzdata - unicode-cldr: $latest_unicode_cldr - """ - ) -end - -# Execute with: `julia --project=dev/ dev/generate_artifacts.jl` -if abspath(PROGRAM_FILE) == @__FILE__ - artifact_toml = if length(ARGS) >= 1 - ARGS[1] - else - joinpath(@__DIR__, "..", "Artifacts.toml") - end - - @time update_artifacts!(artifact_toml) -end diff --git a/dev/generate_windows_zones.jl b/dev/generate_windows_zones.jl new file mode 100644 index 000000000..894f58d4c --- /dev/null +++ b/dev/generate_windows_zones.jl @@ -0,0 +1,68 @@ +import HTTP +import JSON3 +using XML + +"Load the windowsZones.xml from the latest Unicode CLDR release" +function get_xml_doc()::Tuple{Node,String} + @info "Checking for latest Unicode CLDR release..." + response = HTTP.get("https://api.github.com/repos/unicode-org/cldr/releases/latest") + json = JSON3.read(response.body) + latest_cldr_version = json.tag_name # latest release + + @info "Latest Unicode CLDR release: $latest_cldr_version" + win_zones_url = "https://raw.githubusercontent.com/unicode-org/cldr/$latest_cldr_version/common/supplemental/windowsZones.xml" + + response = HTTP.get(win_zones_url) + doc = parse(Node, String(response.body)) + return doc, latest_cldr_version +end + +"Extract the mapping from Windows tzid to Olsen zone ID" +function create_mapping(doc::Node)::Vector{Pair{String,String}} + timezones = doc[end][end][end] + mapping = Pair{String,String}[] + + for node in children(timezones) + if tag(node) == "mapZone" + attr = attributes(node) + if attr["territory"] == "001" + zone_windows = attr["other"] + zone_olson = attr["type"] + push!(mapping, zone_windows => zone_olson) + end + end + end + @info "Mapped $(length(mapping)) zones" + return mapping +end + +"Write the mapping to a Dict literal" +function write_code(mapping::Vector{Pair{String,String}}, latest_cldr_version::String)::Nothing + path = normpath(@__DIR__, "../src/windows_zones.jl") + open(path; write=true) do io + println(io, "# This file is generated by generate_windows_zones.jl, do not edit.\n") + println(io, "const UNICODE_CLDR_VERSION = ", repr(latest_cldr_version), '\n') + println(io, "const WINDOWS_TRANSLATION = Dict{String, String}(") + for zone_pair in mapping + println(io, " ", zone_pair, ',') + end + println(io, ')') + end + @info "Wrote $path" + return nothing +end + +""" +Generate code mapping the Windows tzid to the Olsen zone ID. +The mapping is defined by the Unicode Common Locale Data Repository (CLDR). + +Details on the mapping can be found at: +https://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping +""" +function main(ARGS) + doc, latest_cldr_version = get_xml_doc() + mapping = create_mapping(doc) + write_code(mapping, latest_cldr_version) +end + +main(ARGS) diff --git a/src/TimeZones.jl b/src/TimeZones.jl index 4b704d840..113554d72 100644 --- a/src/TimeZones.jl +++ b/src/TimeZones.jl @@ -78,7 +78,7 @@ include(joinpath("tzfile", "TZFile.jl")) include(joinpath("tzjfile", "TZJFile.jl")) include("exceptions.jl") include(joinpath("tzdata", "TZData.jl")) -Sys.iswindows() && include(joinpath("winzone", "WindowsTimeZoneIDs.jl")) +include("windows_zones.jl") include("build.jl") include("interpret.jl") include("accessors.jl") diff --git a/src/build.jl b/src/build.jl index 5c0df80fc..259de39d0 100644 --- a/src/build.jl +++ b/src/build.jl @@ -11,10 +11,6 @@ Builds the TimeZones package with the specified tzdata `version` and `regions`. function build(version::AbstractString; force::Bool=false) compiled_dir = TimeZones.TZData.build(version, _scratch_dir()) - if Sys.iswindows() - TimeZones.WindowsTimeZoneIDs.build(force=force) - end - # Set the compiled directory to the new location _COMPILED_DIR[] = compiled_dir _reload_cache(compiled_dir) diff --git a/src/local.jl b/src/local.jl index 64f0ebad0..a4c4dddb9 100644 --- a/src/local.jl +++ b/src/local.jl @@ -2,10 +2,6 @@ # Based upon Python's tzlocal https://pypi.python.org/pypi/tzlocal using Mocking: Mocking, @mock -if Sys.iswindows() - import TimeZones.WindowsTimeZoneIDs: WINDOWS_TRANSLATION -end - """ localzone() -> TimeZone diff --git a/src/windows_zones.jl b/src/windows_zones.jl new file mode 100644 index 000000000..fc73f294f --- /dev/null +++ b/src/windows_zones.jl @@ -0,0 +1,145 @@ +# This file is generated by generate_windows_zones.jl, do not edit. + +const UNICODE_CLDR_VERSION = "release-43-1" + +const WINDOWS_TRANSLATION = Dict{String, String}( + "Dateline Standard Time" => "Etc/GMT+12", + "UTC-11" => "Etc/GMT+11", + "Aleutian Standard Time" => "America/Adak", + "Hawaiian Standard Time" => "Pacific/Honolulu", + "Marquesas Standard Time" => "Pacific/Marquesas", + "Alaskan Standard Time" => "America/Anchorage", + "UTC-09" => "Etc/GMT+9", + "Pacific Standard Time (Mexico)" => "America/Tijuana", + "UTC-08" => "Etc/GMT+8", + "Pacific Standard Time" => "America/Los_Angeles", + "US Mountain Standard Time" => "America/Phoenix", + "Mountain Standard Time (Mexico)" => "America/Mazatlan", + "Mountain Standard Time" => "America/Denver", + "Yukon Standard Time" => "America/Whitehorse", + "Central America Standard Time" => "America/Guatemala", + "Central Standard Time" => "America/Chicago", + "Easter Island Standard Time" => "Pacific/Easter", + "Central Standard Time (Mexico)" => "America/Mexico_City", + "Canada Central Standard Time" => "America/Regina", + "SA Pacific Standard Time" => "America/Bogota", + "Eastern Standard Time (Mexico)" => "America/Cancun", + "Eastern Standard Time" => "America/New_York", + "Haiti Standard Time" => "America/Port-au-Prince", + "Cuba Standard Time" => "America/Havana", + "US Eastern Standard Time" => "America/Indianapolis", + "Turks And Caicos Standard Time" => "America/Grand_Turk", + "Paraguay Standard Time" => "America/Asuncion", + "Atlantic Standard Time" => "America/Halifax", + "Venezuela Standard Time" => "America/Caracas", + "Central Brazilian Standard Time" => "America/Cuiaba", + "SA Western Standard Time" => "America/La_Paz", + "Pacific SA Standard Time" => "America/Santiago", + "Newfoundland Standard Time" => "America/St_Johns", + "Tocantins Standard Time" => "America/Araguaina", + "E. South America Standard Time" => "America/Sao_Paulo", + "SA Eastern Standard Time" => "America/Cayenne", + "Argentina Standard Time" => "America/Buenos_Aires", + "Greenland Standard Time" => "America/Godthab", + "Montevideo Standard Time" => "America/Montevideo", + "Magallanes Standard Time" => "America/Punta_Arenas", + "Saint Pierre Standard Time" => "America/Miquelon", + "Bahia Standard Time" => "America/Bahia", + "UTC-02" => "Etc/GMT+2", + "Azores Standard Time" => "Atlantic/Azores", + "Cape Verde Standard Time" => "Atlantic/Cape_Verde", + "UTC" => "Etc/UTC", + "GMT Standard Time" => "Europe/London", + "Greenwich Standard Time" => "Atlantic/Reykjavik", + "Sao Tome Standard Time" => "Africa/Sao_Tome", + "Morocco Standard Time" => "Africa/Casablanca", + "W. Europe Standard Time" => "Europe/Berlin", + "Central Europe Standard Time" => "Europe/Budapest", + "Romance Standard Time" => "Europe/Paris", + "Central European Standard Time" => "Europe/Warsaw", + "W. Central Africa Standard Time" => "Africa/Lagos", + "Jordan Standard Time" => "Asia/Amman", + "GTB Standard Time" => "Europe/Bucharest", + "Middle East Standard Time" => "Asia/Beirut", + "Egypt Standard Time" => "Africa/Cairo", + "E. Europe Standard Time" => "Europe/Chisinau", + "Syria Standard Time" => "Asia/Damascus", + "West Bank Standard Time" => "Asia/Hebron", + "South Africa Standard Time" => "Africa/Johannesburg", + "FLE Standard Time" => "Europe/Kiev", + "Israel Standard Time" => "Asia/Jerusalem", + "South Sudan Standard Time" => "Africa/Juba", + "Kaliningrad Standard Time" => "Europe/Kaliningrad", + "Sudan Standard Time" => "Africa/Khartoum", + "Libya Standard Time" => "Africa/Tripoli", + "Namibia Standard Time" => "Africa/Windhoek", + "Arabic Standard Time" => "Asia/Baghdad", + "Turkey Standard Time" => "Europe/Istanbul", + "Arab Standard Time" => "Asia/Riyadh", + "Belarus Standard Time" => "Europe/Minsk", + "Russian Standard Time" => "Europe/Moscow", + "E. Africa Standard Time" => "Africa/Nairobi", + "Iran Standard Time" => "Asia/Tehran", + "Arabian Standard Time" => "Asia/Dubai", + "Astrakhan Standard Time" => "Europe/Astrakhan", + "Azerbaijan Standard Time" => "Asia/Baku", + "Russia Time Zone 3" => "Europe/Samara", + "Mauritius Standard Time" => "Indian/Mauritius", + "Saratov Standard Time" => "Europe/Saratov", + "Georgian Standard Time" => "Asia/Tbilisi", + "Volgograd Standard Time" => "Europe/Volgograd", + "Caucasus Standard Time" => "Asia/Yerevan", + "Afghanistan Standard Time" => "Asia/Kabul", + "West Asia Standard Time" => "Asia/Tashkent", + "Ekaterinburg Standard Time" => "Asia/Yekaterinburg", + "Pakistan Standard Time" => "Asia/Karachi", + "Qyzylorda Standard Time" => "Asia/Qyzylorda", + "India Standard Time" => "Asia/Calcutta", + "Sri Lanka Standard Time" => "Asia/Colombo", + "Nepal Standard Time" => "Asia/Katmandu", + "Central Asia Standard Time" => "Asia/Almaty", + "Bangladesh Standard Time" => "Asia/Dhaka", + "Omsk Standard Time" => "Asia/Omsk", + "Myanmar Standard Time" => "Asia/Rangoon", + "SE Asia Standard Time" => "Asia/Bangkok", + "Altai Standard Time" => "Asia/Barnaul", + "W. Mongolia Standard Time" => "Asia/Hovd", + "North Asia Standard Time" => "Asia/Krasnoyarsk", + "N. Central Asia Standard Time" => "Asia/Novosibirsk", + "Tomsk Standard Time" => "Asia/Tomsk", + "China Standard Time" => "Asia/Shanghai", + "North Asia East Standard Time" => "Asia/Irkutsk", + "Singapore Standard Time" => "Asia/Singapore", + "W. Australia Standard Time" => "Australia/Perth", + "Taipei Standard Time" => "Asia/Taipei", + "Ulaanbaatar Standard Time" => "Asia/Ulaanbaatar", + "Aus Central W. Standard Time" => "Australia/Eucla", + "Transbaikal Standard Time" => "Asia/Chita", + "Tokyo Standard Time" => "Asia/Tokyo", + "North Korea Standard Time" => "Asia/Pyongyang", + "Korea Standard Time" => "Asia/Seoul", + "Yakutsk Standard Time" => "Asia/Yakutsk", + "Cen. Australia Standard Time" => "Australia/Adelaide", + "AUS Central Standard Time" => "Australia/Darwin", + "E. Australia Standard Time" => "Australia/Brisbane", + "AUS Eastern Standard Time" => "Australia/Sydney", + "West Pacific Standard Time" => "Pacific/Port_Moresby", + "Tasmania Standard Time" => "Australia/Hobart", + "Vladivostok Standard Time" => "Asia/Vladivostok", + "Lord Howe Standard Time" => "Australia/Lord_Howe", + "Bougainville Standard Time" => "Pacific/Bougainville", + "Russia Time Zone 10" => "Asia/Srednekolymsk", + "Magadan Standard Time" => "Asia/Magadan", + "Norfolk Standard Time" => "Pacific/Norfolk", + "Sakhalin Standard Time" => "Asia/Sakhalin", + "Central Pacific Standard Time" => "Pacific/Guadalcanal", + "Russia Time Zone 11" => "Asia/Kamchatka", + "New Zealand Standard Time" => "Pacific/Auckland", + "UTC+12" => "Etc/GMT-12", + "Fiji Standard Time" => "Pacific/Fiji", + "Chatham Islands Standard Time" => "Pacific/Chatham", + "UTC+13" => "Etc/GMT-13", + "Tonga Standard Time" => "Pacific/Tongatapu", + "Samoa Standard Time" => "Pacific/Apia", + "Line Islands Standard Time" => "Pacific/Kiritimati", +) diff --git a/src/winzone/WindowsTimeZoneIDs.jl b/src/winzone/WindowsTimeZoneIDs.jl deleted file mode 100644 index 50bf22a8d..000000000 --- a/src/winzone/WindowsTimeZoneIDs.jl +++ /dev/null @@ -1,64 +0,0 @@ -module WindowsTimeZoneIDs - -using Artifacts: @artifact_str -using ...TimeZones: _scratch_dir - -const UNICODE_CLDR_VERSION = "release-43-1" - -# A mapping of Windows timezone names to Olson timezone names. -# Details on the contents of this file can be found at: -# http://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping -const WINDOWS_ZONE_FILE = joinpath("cldr-$UNICODE_CLDR_VERSION", "common", "supplemental", "windowsZones.xml") -const _WINDOWS_XML_FILE_PATH = Ref{String}() - -const WINDOWS_TRANSLATION = Dict{String, String}() - -function __init__() - _WINDOWS_XML_FILE_PATH[] = joinpath(_scratch_dir(), "local", "windowsZones.xml") - if isfile(_WINDOWS_XML_FILE_PATH[]) - copy!(WINDOWS_TRANSLATION, compile(_WINDOWS_XML_FILE_PATH[])) - else - build() - end -end - -function compile(xml_file::AbstractString) - translation = Dict{String,String}() - - # Get the timezone conversions from the file - # - # Note: Since the XML file is simplistic enough that we can parse what we need via a - # regex we can avoid having an XML package dependency. Additionally, since this XML file - # is included as part of the this package we can correct any parsing issues before a - # TimeZones.jl release occurs. - for line in readlines(xml_file) - # Territory "001" is the global default - occursin("territory=\"001\"", line) || continue - win_name = match(r"other=\"(.*?)\"", line)[1] - posix_name = match(r"type=\"(.*?)\"", line)[1] - translation[win_name] = posix_name - end - - return translation -end - -function build(xml_file::AbstractString; force::Bool=false) - if !isfile(xml_file) || force - @info "Downloading Windows to POSIX timezone ID XML version: $UNICODE_CLDR_VERSION" - artifact_dir = @artifact_str "unicode-cldr-$UNICODE_CLDR_VERSION" - cp(joinpath(artifact_dir, WINDOWS_ZONE_FILE), xml_file, force=true) - end - - @info "Compiling Windows time zone name translation" - copy!(WINDOWS_TRANSLATION, compile(xml_file)) -end - -function build(; kwargs...) - # Note: Directory creation during package initialization can cause failures when using - # PackageCompiler.jl: https://github.com/JuliaTime/TimeZones.jl/issues/371 - windows_xml_dir = dirname(_WINDOWS_XML_FILE_PATH[]) - isdir(windows_xml_dir) || mkdir(windows_xml_dir) - return build(_WINDOWS_XML_FILE_PATH[]; kwargs...) -end - -end diff --git a/test/runtests.jl b/test/runtests.jl index 9773f8366..d4d3311af 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -47,7 +47,7 @@ include("helpers.jl") include(joinpath("tzdata", "download.jl")) include(joinpath("tzdata", "compile.jl")) include(joinpath("tzdata", "build.jl")) - Sys.iswindows() && include(joinpath("winzone", "WindowsTimeZoneIDs.jl")) + include("windows_zones.jl") include("utcoffset.jl") include(joinpath("types", "timezone.jl")) include(joinpath("types", "fixedtimezone.jl")) diff --git a/test/windows_zones.jl b/test/windows_zones.jl new file mode 100644 index 000000000..19d2daac6 --- /dev/null +++ b/test/windows_zones.jl @@ -0,0 +1,3 @@ +using TimeZones: WINDOWS_TRANSLATION + +@test WINDOWS_TRANSLATION["Central European Standard Time"] == "Europe/Warsaw" diff --git a/test/winzone/WindowsTimeZoneIDs.jl b/test/winzone/WindowsTimeZoneIDs.jl deleted file mode 100644 index 942bc1223..000000000 --- a/test/winzone/WindowsTimeZoneIDs.jl +++ /dev/null @@ -1,20 +0,0 @@ -using TimeZones.WindowsTimeZoneIDs - -xml_file = TimeZones.WindowsTimeZoneIDs._WINDOWS_XML_FILE_PATH[] -!isfile(xml_file) && error("Missing required XML file. Run Pkg.build(\"TimeZones\").") - -trans = TimeZones.WindowsTimeZoneIDs.compile(xml_file) -@test trans["Central European Standard Time"] == "Europe/Warsaw" - -mktempdir() do temp_dir - xml_file = joinpath(temp_dir, "windowZones.xml") - @test !isfile(xml_file) - - empty!(TimeZones.WindowsTimeZoneIDs.WINDOWS_TRANSLATION) - @test isempty(TimeZones.WindowsTimeZoneIDs.WINDOWS_TRANSLATION) - - # Does not perform download - TimeZones.WindowsTimeZoneIDs.build(xml_file) - @test isfile(xml_file) - @test !isempty(TimeZones.WindowsTimeZoneIDs.WINDOWS_TRANSLATION) -end From f24af992a71e5fdce0379b8670b4cb0dd2b6cc2f Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Wed, 25 Oct 2023 01:25:46 +0200 Subject: [PATCH 02/10] remove Artifacts.toml and LazyArtifacts dependency --- Artifacts.toml | 16 ---------------- Project.toml | 13 ++++++------- test/artifacts.jl | 21 --------------------- test/runtests.jl | 1 - 4 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 Artifacts.toml delete mode 100644 test/artifacts.jl diff --git a/Artifacts.toml b/Artifacts.toml deleted file mode 100644 index cffa2b127..000000000 --- a/Artifacts.toml +++ /dev/null @@ -1,16 +0,0 @@ -[[unicode-cldr-release-43-1]] -arch = "x86_64" -git-tree-sha1 = "40b35727ea0aff9a9f28b7454004b68849caf67b" -os = "windows" - - [[unicode-cldr-release-43-1.download]] - sha256 = "0b063164ec434c150ff5f41699081ab0e4d9bf85c15a74f81f4b972b67d26bdb" - url = "https://github.com/unicode-org/cldr/archive/release-43-1.tar.gz" -[[unicode-cldr-release-43-1]] -arch = "i686" -git-tree-sha1 = "40b35727ea0aff9a9f28b7454004b68849caf67b" -os = "windows" - - [[unicode-cldr-release-43-1.download]] - sha256 = "0b063164ec434c150ff5f41699081ab0e4d9bf85c15a74f81f4b972b67d26bdb" - url = "https://github.com/unicode-org/cldr/archive/release-43-1.tar.gz" diff --git a/Project.toml b/Project.toml index 0b469c9ef..462182076 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,6 @@ Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" -LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" Mocking = "78c3b35d-d492-501b-9361-3d52fe80e533" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" @@ -17,6 +16,12 @@ TZJData = "dc5dba14-91b3-4cab-a142-028a31da12f7" Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +[weakdeps] +RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" + +[extensions] +TimeZonesRecipesBaseExt = "RecipesBase" + [compat] InlineStrings = "1" Mocking = "0.7" @@ -26,15 +31,9 @@ TZJData = "1" julia = "1.6" p7zip_jll = "17.4" -[extensions] -TimeZonesRecipesBaseExt = "RecipesBase" - [extras] RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test", "RecipesBase"] - -[weakdeps] -RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" diff --git a/test/artifacts.jl b/test/artifacts.jl deleted file mode 100644 index 33e09be1e..000000000 --- a/test/artifacts.jl +++ /dev/null @@ -1,21 +0,0 @@ -@testset "Artifacts" begin - @testset "unicode-cldr" begin - platforms = [ - Platform("x86_64", "windows"), - Platform("i686", "windows"), - ] - - for platform in platforms - dict = select_downloadable_artifacts( - joinpath(@__DIR__, "..", "Artifacts.toml"); - platform, - include_lazy=true, - ) - @test length(dict) == 1 - - name, info = first(dict) - @test startswith(name, "unicode-cldr") - @test get(info, "lazy", false) == false - end - end -end diff --git a/test/runtests.jl b/test/runtests.jl index d4d3311af..b01c352a3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -39,7 +39,6 @@ include("helpers.jl") @testset "TimeZones" begin include("utils.jl") include("indexable_generator.jl") - include("artifacts.jl") include("class.jl") include(joinpath("tzdata", "timeoffset.jl")) From 8f7e1142009c9276a4ccb775be75a82aa0d46a5e Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 1 Dec 2023 05:21:54 +0100 Subject: [PATCH 03/10] Add comment on 001 Co-authored-by: Curtis Vogt --- dev/generate_windows_zones.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/generate_windows_zones.jl b/dev/generate_windows_zones.jl index 894f58d4c..b79aecfee 100644 --- a/dev/generate_windows_zones.jl +++ b/dev/generate_windows_zones.jl @@ -25,6 +25,7 @@ function create_mapping(doc::Node)::Vector{Pair{String,String}} for node in children(timezones) if tag(node) == "mapZone" attr = attributes(node) + # Territory "001" is the global default if attr["territory"] == "001" zone_windows = attr["other"] zone_olson = attr["type"] From 8a11fb3a77805a6e8aed3dfe9a2c09e4aea7cd78 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Thu, 11 Apr 2024 18:24:03 +0200 Subject: [PATCH 04/10] Remove Artifacts dependency --- Project.toml | 1 - src/tzdata/TZData.jl | 1 - test/runtests.jl | 1 - 3 files changed, 3 deletions(-) diff --git a/Project.toml b/Project.toml index 23f7f70bb..aa4279523 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,6 @@ authors = ["Curtis Vogt "] version = "1.14.0" [deps] -Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" diff --git a/src/tzdata/TZData.jl b/src/tzdata/TZData.jl index b2ef1d7db..835b73d6f 100644 --- a/src/tzdata/TZData.jl +++ b/src/tzdata/TZData.jl @@ -1,6 +1,5 @@ module TZData -using Artifacts: @artifact_str using Dates: Dates, DateTime using Printf using ...TimeZones: TZJFile, _scratch_dir diff --git a/test/runtests.jl b/test/runtests.jl index b01c352a3..2c5fe6f41 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,5 @@ using Mocking -using Artifacts: select_downloadable_artifacts using Base.BinaryPlatforms: Platform using RecipesBase using Test From 0556cb2528ec6b9321f93370f1257c40a36a49c8 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 26 Apr 2024 10:17:08 +0200 Subject: [PATCH 05/10] Apply suggestions from code review Co-authored-by: Curtis Vogt --- dev/generate_windows_zones.jl | 55 ++++++++++++++++++++--------------- test/windows_zones.jl | 3 +- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/dev/generate_windows_zones.jl b/dev/generate_windows_zones.jl index b79aecfee..ac95dcac0 100644 --- a/dev/generate_windows_zones.jl +++ b/dev/generate_windows_zones.jl @@ -2,24 +2,26 @@ import HTTP import JSON3 using XML -"Load the windowsZones.xml from the latest Unicode CLDR release" -function get_xml_doc()::Tuple{Node,String} - @info "Checking for latest Unicode CLDR release..." +"Determine the latest Unicode CLDR release" +function unicode_cldr_latest_release()::String response = HTTP.get("https://api.github.com/repos/unicode-org/cldr/releases/latest") json = JSON3.read(response.body) - latest_cldr_version = json.tag_name # latest release - - @info "Latest Unicode CLDR release: $latest_cldr_version" - win_zones_url = "https://raw.githubusercontent.com/unicode-org/cldr/$latest_cldr_version/common/supplemental/windowsZones.xml" + return = json.tag_name +end +"Download the `windowsZones.xml` from the Unicode CLDR release" +function download_windows_zones_xml(unicode_cldr_release::String)::String + win_zones_url = "https://raw.githubusercontent.com/unicode-org/cldr/$unicode_cldr_release/common/supplemental/windowsZones.xml" response = HTTP.get(win_zones_url) - doc = parse(Node, String(response.body)) - return doc, latest_cldr_version + return String(response.body) end "Extract the mapping from Windows tzid to Olsen zone ID" -function create_mapping(doc::Node)::Vector{Pair{String,String}} - timezones = doc[end][end][end] +function create_mapping(windows_zone_xml::AbstractString)::Vector{Pair{String,String}} + doc = parse(Node, windows_zone_xml) + supplemental_data = only(filter(node -> tag(node) == "supplementalData", children(doc))) + windows_zones = only(filter(node -> tag(node) == "windowsZones", children(supplemental_data))) + timezones = only(filter(node -> tag(node) == "mapTimezones", children(windows_zones))) mapping = Pair{String,String}[] for node in children(timezones) @@ -27,29 +29,27 @@ function create_mapping(doc::Node)::Vector{Pair{String,String}} attr = attributes(node) # Territory "001" is the global default if attr["territory"] == "001" - zone_windows = attr["other"] - zone_olson = attr["type"] - push!(mapping, zone_windows => zone_olson) + windows_zone_name = attr["other"] + tzdata_name = attr["type"] + push!(mapping, windows_zone_name => tzdata_name) end end end - @info "Mapped $(length(mapping)) zones" return mapping end "Write the mapping to a Dict literal" -function write_code(mapping::Vector{Pair{String,String}}, latest_cldr_version::String)::Nothing +function generate_code(io::IO, mapping::Vector{Pair{String,String}}, latest_cldr_version::String)::Nothing path = normpath(@__DIR__, "../src/windows_zones.jl") open(path; write=true) do io - println(io, "# This file is generated by generate_windows_zones.jl, do not edit.\n") + println(io, "# This file is generated by `dev/generate_windows_zones.jl`, do not edit.\n") println(io, "const UNICODE_CLDR_VERSION = ", repr(latest_cldr_version), '\n') println(io, "const WINDOWS_TRANSLATION = Dict{String, String}(") for zone_pair in mapping - println(io, " ", zone_pair, ',') + println(io, " ", repr(zone_pair), ',') end println(io, ')') end - @info "Wrote $path" return nothing end @@ -61,9 +61,18 @@ Details on the mapping can be found at: https://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping """ function main(ARGS) - doc, latest_cldr_version = get_xml_doc() - mapping = create_mapping(doc) - write_code(mapping, latest_cldr_version) + release = unicode_cldr_latest_release() + @info "Latest Unicode CLDR release: $latest_cldr_version" + + xml_str = download_windows_zones_xml(release) + mapping = create_mapping(xml_str) + @info "Mapped $(length(mapping)) zones" + + open(joinpath(@__DIR__, "..", "src", "windows_zones.jl"), "w") do io + write_code(io, mapping, release) + end end -main(ARGS) +if abspath(PROGRAM_FILE) == @__FILE__ + main(ARGS) +end diff --git a/test/windows_zones.jl b/test/windows_zones.jl index 19d2daac6..0015add6d 100644 --- a/test/windows_zones.jl +++ b/test/windows_zones.jl @@ -1,3 +1,4 @@ -using TimeZones: WINDOWS_TRANSLATION +using TimeZones: UNICODE_CLDR_VERSION, WINDOWS_TRANSLATION +@test occursin(r"^release-\d+(-\d+)$", UNICODE_CLDR_VERSION) @test WINDOWS_TRANSLATION["Central European Standard Time"] == "Europe/Warsaw" From 4483e6b82c64e5230e70c44fad162f530071ab6a Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 26 Apr 2024 10:35:08 +0200 Subject: [PATCH 06/10] Fix tests --- dev/generate_windows_zones.jl | 12 ++++++------ test/windows_zones.jl | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/generate_windows_zones.jl b/dev/generate_windows_zones.jl index ac95dcac0..9bdad03ac 100644 --- a/dev/generate_windows_zones.jl +++ b/dev/generate_windows_zones.jl @@ -6,7 +6,7 @@ using XML function unicode_cldr_latest_release()::String response = HTTP.get("https://api.github.com/repos/unicode-org/cldr/releases/latest") json = JSON3.read(response.body) - return = json.tag_name + return json.tag_name end "Download the `windowsZones.xml` from the Unicode CLDR release" @@ -61,15 +61,15 @@ Details on the mapping can be found at: https://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping """ function main(ARGS) - release = unicode_cldr_latest_release() + latest_cldr_version = unicode_cldr_latest_release() @info "Latest Unicode CLDR release: $latest_cldr_version" - - xml_str = download_windows_zones_xml(release) + + xml_str = download_windows_zones_xml(latest_cldr_version) mapping = create_mapping(xml_str) @info "Mapped $(length(mapping)) zones" - + open(joinpath(@__DIR__, "..", "src", "windows_zones.jl"), "w") do io - write_code(io, mapping, release) + generate_code(io, mapping, latest_cldr_version) end end diff --git a/test/windows_zones.jl b/test/windows_zones.jl index 0015add6d..d1f91d499 100644 --- a/test/windows_zones.jl +++ b/test/windows_zones.jl @@ -1,4 +1,4 @@ using TimeZones: UNICODE_CLDR_VERSION, WINDOWS_TRANSLATION -@test occursin(r"^release-\d+(-\d+)$", UNICODE_CLDR_VERSION) +@test occursin(r"^release-\d+(-\d+)?$", UNICODE_CLDR_VERSION) @test WINDOWS_TRANSLATION["Central European Standard Time"] == "Europe/Warsaw" From 933e0149c5a4e4d9caeec0f7dcbc91cde3bdc483 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 26 Apr 2024 10:35:37 +0200 Subject: [PATCH 07/10] Generate release-45 --- src/windows_zones.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/windows_zones.jl b/src/windows_zones.jl index fc73f294f..941c39ca5 100644 --- a/src/windows_zones.jl +++ b/src/windows_zones.jl @@ -1,6 +1,6 @@ -# This file is generated by generate_windows_zones.jl, do not edit. +# This file is generated by `dev/generate_windows_zones.jl`, do not edit. -const UNICODE_CLDR_VERSION = "release-43-1" +const UNICODE_CLDR_VERSION = "release-45" const WINDOWS_TRANSLATION = Dict{String, String}( "Dateline Standard Time" => "Etc/GMT+12", @@ -97,7 +97,7 @@ const WINDOWS_TRANSLATION = Dict{String, String}( "India Standard Time" => "Asia/Calcutta", "Sri Lanka Standard Time" => "Asia/Colombo", "Nepal Standard Time" => "Asia/Katmandu", - "Central Asia Standard Time" => "Asia/Almaty", + "Central Asia Standard Time" => "Asia/Bishkek", "Bangladesh Standard Time" => "Asia/Dhaka", "Omsk Standard Time" => "Asia/Omsk", "Myanmar Standard Time" => "Asia/Rangoon", From deb86052e6d2a9db8ee2cbf05af50d621cc4a0fc Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 26 Apr 2024 16:01:37 +0200 Subject: [PATCH 08/10] Apply suggestions from code review Co-authored-by: Curtis Vogt --- dev/generate_windows_zones.jl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dev/generate_windows_zones.jl b/dev/generate_windows_zones.jl index 9bdad03ac..4f5deff9b 100644 --- a/dev/generate_windows_zones.jl +++ b/dev/generate_windows_zones.jl @@ -40,16 +40,13 @@ end "Write the mapping to a Dict literal" function generate_code(io::IO, mapping::Vector{Pair{String,String}}, latest_cldr_version::String)::Nothing - path = normpath(@__DIR__, "../src/windows_zones.jl") - open(path; write=true) do io - println(io, "# This file is generated by `dev/generate_windows_zones.jl`, do not edit.\n") - println(io, "const UNICODE_CLDR_VERSION = ", repr(latest_cldr_version), '\n') - println(io, "const WINDOWS_TRANSLATION = Dict{String, String}(") - for zone_pair in mapping - println(io, " ", repr(zone_pair), ',') - end - println(io, ')') + println(io, "# This file is generated by `dev/generate_windows_zones.jl`, do not edit.\n") + println(io, "const UNICODE_CLDR_VERSION = ", repr(latest_cldr_version), '\n') + println(io, "const WINDOWS_TRANSLATION = Dict{String, String}(") + for zone_pair in mapping + println(io, " ", repr(zone_pair), ',') end + println(io, ')') return nothing end @@ -60,7 +57,7 @@ The mapping is defined by the Unicode Common Locale Data Repository (CLDR). Details on the mapping can be found at: https://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping """ -function main(ARGS) +function main() latest_cldr_version = unicode_cldr_latest_release() @info "Latest Unicode CLDR release: $latest_cldr_version" From 070696eb91e25d4ab2276c46caad54271f3e5ce4 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 26 Apr 2024 16:12:00 +0200 Subject: [PATCH 09/10] Update manifests to avoid TZJData compat issues --- dev/Manifest.toml | 70 +++++++++++++++++++++++++--------------------- docs/Manifest.toml | 56 ++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/dev/Manifest.toml b/dev/Manifest.toml index baf24e7aa..a5eaa47e6 100644 --- a/dev/Manifest.toml +++ b/dev/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.3" +julia_version = "1.9.4" manifest_format = "2.0" project_hash = "26b2187be7743c6ac46f50f5788f9b2373dbd216" @@ -11,21 +11,21 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[deps.BitFlags]] -git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d" +git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" -version = "0.1.7" +version = "0.1.8" [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] -git-tree-sha1 = "cd67fc487743b2f0fd4380d4cbd3a24660d0eec8" +git-tree-sha1 = "59939d8a997469ee05c4b4944560a820f9ba0d73" uuid = "944b1d66-785c-5afd-91f1-9de20f533193" -version = "0.7.3" +version = "0.7.4" [[deps.ConcurrentUtilities]] deps = ["Serialization", "Sockets"] -git-tree-sha1 = "5372dbbf8f0bdb8c700db5367132925c0771ef7e" +git-tree-sha1 = "6cbbd4d241d7e6579ab354737f4dd95ca43946e1" uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb" -version = "2.2.1" +version = "2.4.1" [[deps.Dates]] deps = ["Printf"] @@ -33,15 +33,15 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" [[deps.ExceptionUnwrapping]] deps = ["Test"] -git-tree-sha1 = "e90caa41f5a86296e014e148ee061bd6c3edec96" +git-tree-sha1 = "dcb08a0d93ec0b1cdc4af184b26b591e9695423a" uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4" -version = "0.1.9" +version = "0.1.10" [[deps.HTTP]] deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "5eab648309e2e060198b45820af1a37182de3cce" +git-tree-sha1 = "2c3ec1f90bb4a8f7beafb0cffea8a4c3f4e636ab" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.10.0" +version = "1.10.6" [[deps.InteractiveUtils]] deps = ["Markdown"] @@ -55,9 +55,15 @@ version = "1.5.0" [[deps.JSON3]] deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"] -git-tree-sha1 = "95220473901735a0f4df9d1ca5b171b568b2daa3" +git-tree-sha1 = "eb3edce0ed4fa32f75a0a11217433c31d56bd48b" uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" -version = "1.13.2" +version = "1.14.0" + + [deps.JSON3.extensions] + JSON3ArrowExt = ["ArrowTypes"] + + [deps.JSON3.weakdeps] + ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -76,10 +82,10 @@ deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" [[deps.MbedTLS]] -deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "Random", "Sockets"] -git-tree-sha1 = "03a9b9718f5682ecb107ac9f7308991db4ce395b" +deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "NetworkOptions", "Random", "Sockets"] +git-tree-sha1 = "c067a280ddc25f196b5e7df3877c6b226d390aaf" uuid = "739be429-bea8-5141-9913-cc70e7f3736d" -version = "1.1.7" +version = "1.1.9" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] @@ -99,38 +105,38 @@ version = "1.2.0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] -git-tree-sha1 = "51901a49222b09e3743c65b8847687ae5fc78eb2" +git-tree-sha1 = "38cb508d080d21dc1128f7fb04f20387ed4c0af4" uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" -version = "1.4.1" +version = "1.4.3" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "ceeda72c9fd6bbebc4f4f598560789145a8b6c4c" +git-tree-sha1 = "3da7367955dcc5c54c1ba4d402ccdc09a1a3e046" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.0.11+0" +version = "3.0.13+1" [[deps.OrderedCollections]] -git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" +git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.6.2" +version = "1.6.3" [[deps.Parsers]] deps = ["Dates", "PrecompileTools", "UUIDs"] -git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" +git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.7.2" +version = "2.8.1" [[deps.PrecompileTools]] deps = ["Preferences"] -git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" +git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -version = "1.2.0" +version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" +git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.1" +version = "1.4.3" [[deps.Printf]] deps = ["Unicode"] @@ -171,9 +177,9 @@ deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[deps.TranscodingStreams]] -git-tree-sha1 = "49cbf7c74fafaed4c529d47d48c8f7da6a19eb75" +git-tree-sha1 = "71509f04d045ec714c4748c785a59045c3736349" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.10.1" +version = "0.10.7" weakdeps = ["Random", "Test"] [deps.TranscodingStreams.extensions] @@ -193,9 +199,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[deps.XML]] deps = ["Mmap", "OrderedCollections"] -git-tree-sha1 = "a08437e8fc5729a47258bc8f6d846d167516bf69" +git-tree-sha1 = "04935ec358bd655bfe135a19f6d905fb2d7c330d" uuid = "72c71f33-b9b6-44de-8c94-c961784809e2" -version = "0.3.1" +version = "0.3.2" [[deps.Zlib_jll]] deps = ["Libdl"] diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 9738f5ac7..4be30318b 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.1" +julia_version = "1.9.4" manifest_format = "2.0" project_hash = "b0e0fdd6d2084cf873bc7d6040a84520736d76d6" @@ -20,10 +20,10 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[deps.Compat]] -deps = ["UUIDs"] -git-tree-sha1 = "e460f044ca8b99be31d35fe54fc33a5c33dd8ed7" +deps = ["TOML", "UUIDs"] +git-tree-sha1 = "c955881e3c981181362ae4088b35995446298b80" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.9.0" +version = "4.14.0" [deps.Compat.extensions] CompatLinearAlgebraExt = "LinearAlgebra" @@ -63,9 +63,9 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[deps.IOCapture]] deps = ["Logging", "Random"] -git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6" +git-tree-sha1 = "8b72179abc660bfab5e28472e019392b97d0985c" uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" -version = "0.2.3" +version = "0.2.4" [[deps.InlineStrings]] deps = ["Parsers"] @@ -86,12 +86,12 @@ version = "0.21.4" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" +version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" +version = "8.4.0+0" [[deps.LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] @@ -100,7 +100,7 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" +version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -136,21 +136,21 @@ version = "1.2.0" [[deps.Parsers]] deps = ["Dates", "PrecompileTools", "UUIDs"] -git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" +git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.7.2" +version = "2.8.1" [[deps.PrecompileTools]] deps = ["Preferences"] -git-tree-sha1 = "9673d39decc5feece56ef3940e5dafba15ba0f81" +git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -version = "1.1.2" +version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" +git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.0" +version = "1.4.3" [[deps.Printf]] deps = ["Unicode"] @@ -164,21 +164,15 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -[[deps.RecipesBase]] -deps = ["PrecompileTools"] -git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff" -uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.3.4" - [[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" version = "0.7.0" [[deps.Scratch]] deps = ["Dates"] -git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a" +git-tree-sha1 = "3bac05bc7e74a75fd9cba4295cde4045d9fe2386" uuid = "6c6a2e73-6563-6170-7368-637461726353" -version = "1.2.0" +version = "1.2.1" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -193,19 +187,25 @@ version = "1.0.3" [[deps.TZJData]] deps = ["Artifacts"] -git-tree-sha1 = "b32799596731e3d712cdf085b18a26f271ce110c" +git-tree-sha1 = "1607ad46cf8d642aa779a1d45af1c8620dbf6915" uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7" -version = "0.0.1+2023c" +version = "1.2.0+2024a" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[deps.TimeZones]] -deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "RecipesBase", "Scratch", "TZJData", "Unicode", "p7zip_jll"] +deps = ["Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"] path = ".." uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" -version = "1.11.0" +version = "1.14.0" + + [deps.TimeZones.extensions] + TimeZonesRecipesBaseExt = "RecipesBase" + + [deps.TimeZones.weakdeps] + RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" [[deps.UUIDs]] deps = ["Random", "SHA"] @@ -222,7 +222,7 @@ version = "1.2.13+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" +version = "1.52.0+1" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] From d27bd944e3160cc0da730cbf8fe4d1f576bc67ba Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 26 Apr 2024 16:16:53 +0200 Subject: [PATCH 10/10] Call main without args --- dev/generate_windows_zones.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/generate_windows_zones.jl b/dev/generate_windows_zones.jl index 4f5deff9b..802798432 100644 --- a/dev/generate_windows_zones.jl +++ b/dev/generate_windows_zones.jl @@ -71,5 +71,5 @@ function main() end if abspath(PROGRAM_FILE) == @__FILE__ - main(ARGS) + main() end