From d70b2b75a957e1639a029f45ada309f13316d10a Mon Sep 17 00:00:00 2001
From: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Date: Wed, 11 Feb 2026 23:12:45 +0100
Subject: [PATCH] test
---
Cargo.lock | 66 ++--
Cargo.toml | 2 -
provider/Cargo.toml | 3 +-
provider/src/tzdb/cldr-timezone.xml | 484 ----------------------------
provider/src/tzdb/cldr_test.rs | 93 ++----
5 files changed, 58 insertions(+), 590 deletions(-)
delete mode 100644 provider/src/tzdb/cldr-timezone.xml
diff --git a/Cargo.lock b/Cargo.lock
index 2b98dda26..d63a3f117 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -441,6 +441,7 @@ dependencies = [
"icu_locale",
"icu_locale_core",
"icu_provider",
+ "ixdtf",
"tinystr",
"zerovec",
]
@@ -516,6 +517,29 @@ dependencies = [
"zerovec",
]
+[[package]]
+name = "icu_time"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ed0e4cff0e300a0eb97a2962c03425de34a1aba9857ac283794104c46790856"
+dependencies = [
+ "calendrical_calculations",
+ "displaydoc",
+ "icu_calendar",
+ "icu_locale_core",
+ "icu_provider",
+ "icu_time_data",
+ "ixdtf",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_time_data"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e10b0e5e87a2c84bd5fa407705732052edebe69291d347d0c3033785470edbf"
+
[[package]]
name = "indenter"
version = "0.3.3"
@@ -730,18 +754,6 @@ dependencies = [
"serde_derive",
]
-[[package]]
-name = "serde-xml-rs"
-version = "0.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53630160a98edebde0123eb4dfd0fce6adff091b2305db3154a9e920206eb510"
-dependencies = [
- "log",
- "serde",
- "thiserror",
- "xml-rs",
-]
-
[[package]]
name = "serde_core"
version = "1.0.225"
@@ -883,35 +895,15 @@ dependencies = [
"zoneinfo64",
]
-[[package]]
-name = "thiserror"
-version = "1.0.69"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
-dependencies = [
- "thiserror-impl",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "1.0.69"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
[[package]]
name = "timezone_provider"
version = "0.1.2"
dependencies = [
"combine",
"databake",
+ "icu_time",
"jiff-tzdb",
"serde",
- "serde-xml-rs",
"serde_json",
"tinystr",
"tzif",
@@ -1234,12 +1226,6 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
-[[package]]
-name = "xml-rs"
-version = "0.8.28"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f"
-
[[package]]
name = "yoke"
version = "0.8.0"
@@ -1295,6 +1281,8 @@ dependencies = [
"displaydoc",
"litemap",
"serde_core",
+ "yoke",
+ "zerofrom",
"zerovec",
]
diff --git a/Cargo.toml b/Cargo.toml
index 073653d54..8f99ae5af 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,8 +25,6 @@ exclude = [
"CONTRIBUTING.md",
"cliff.toml",
"tests/data/zoneinfo64.res",
- # Under a different license
- "provider/src/tzdb/cldr-timezone.xml",
]
[workspace.dependencies]
diff --git a/provider/Cargo.toml b/provider/Cargo.toml
index f0bb50165..6623e4a3b 100644
--- a/provider/Cargo.toml
+++ b/provider/Cargo.toml
@@ -75,8 +75,7 @@ yoke = { version = "0.8.0", features = ["derive"], optional = true }
serde_json = { version = "1.0.145", optional = true }
[dev-dependencies]
-serde-xml-rs = "0.8.1"
-serde = { version = "1.0.225" , features = ["derive"] }
+icu_time = { version = "2", features = ["compiled_data"] }
[package.metadata.docs.rs]
all-features = true
diff --git a/provider/src/tzdb/cldr-timezone.xml b/provider/src/tzdb/cldr-timezone.xml
deleted file mode 100644
index 6990632e1..000000000
--- a/provider/src/tzdb/cldr-timezone.xml
+++ /dev/null
@@ -1,484 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/provider/src/tzdb/cldr_test.rs b/provider/src/tzdb/cldr_test.rs
index 8d7e52a6e..4918ea422 100644
--- a/provider/src/tzdb/cldr_test.rs
+++ b/provider/src/tzdb/cldr_test.rs
@@ -1,74 +1,41 @@
+use icu_time::zone::iana::{IanaParserExtended, TimeZoneAndCanonicalAndNormalized};
+
use super::CompiledNormalizer;
use crate::provider::TimeZoneNormalizer;
-use alloc::string::String;
-use alloc::vec::Vec;
-use serde::{self, Deserialize};
-
-const CLDR_TIMEZONES: &str = include_str!("cldr-timezone.xml");
-
-#[derive(Deserialize, Debug)]
-struct Document {
- keyword: Keyword,
-}
-#[derive(Deserialize, Debug)]
-struct Keyword {
- key: Key,
-}
-
-#[derive(Deserialize, Debug)]
-struct Key {
- #[serde(rename = "type")]
- tzs: Vec,
-}
-
-#[derive(Deserialize, Debug)]
-struct TimeZone {
- #[serde(rename = "@alias")]
- aliases: Option,
- #[serde(rename = "@iana")]
- iana: Option,
-}
-
-/// This tests against CLDR's timezones.xml
-/// which is known to be closer to the spec for
-///
+/// This tests against CLDR through ICU4X.
#[test]
fn test_cldr_timezones() {
- let doc: Document = serde_xml_rs::from_str(CLDR_TIMEZONES).unwrap();
+ for TimeZoneAndCanonicalAndNormalized {
+ canonical,
+ normalized,
+ ..
+ } in IanaParserExtended::new().iter_all()
+ {
+ if canonical.starts_with("Etc") {
+ // These are handled elsewhere
+ continue;
+ }
+ if matches!(normalized, "Canada/East-Saskatchewan" | "US/Pacific-New") {
+ // These are present in CLDR but not tzdb. Special case as known exceptions.
+ continue;
+ }
- for tz in doc.keyword.key.tzs {
- if let Some(aliases) = tz.aliases {
- let aliases: Vec<_> = aliases.split(" ").collect();
+ let primary_id = CompiledNormalizer
+ .normalized(canonical.as_bytes())
+ .expect(canonical);
- // The primary string is either the first timezone, or the `iana` field if present
- let primary_str = if let Some(iana) = tz.iana.as_ref() {
- iana
- } else {
- aliases[0]
- };
- if primary_str.starts_with("Etc") {
- // These are handled elsewhere
- continue;
- }
- let primary = CompiledNormalizer
- .normalized(primary_str.as_bytes())
- .expect(primary_str);
+ let normalized_id = CompiledNormalizer
+ .normalized(normalized.as_bytes())
+ .expect(normalized);
- // We want to ensure they all canonicalize
- for alias in aliases {
- if alias == "Canada/East-Saskatchewan" || alias == "US/Pacific-New" {
- // These are present in CLDR but not tzdb. Special case as known exceptions.
- continue;
- }
- let normalized = CompiledNormalizer.normalized(alias.as_bytes()).unwrap();
- let canonicalized = CompiledNormalizer.canonicalized(normalized).unwrap();
+ let canonicalized_id = CompiledNormalizer
+ .canonicalized(normalized_id)
+ .expect(normalized);
- assert_eq!(
- canonicalized, primary,
- "{alias} should canonicalize to the same thing as {primary_str}"
- );
- }
- }
+ assert_eq!(
+ canonicalized_id, primary_id,
+ "{normalized} should canonicalize to the same thing as {canonical}"
+ );
}
}