Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IANA-to-BCP47 and reverse mappings #4024

Merged
merged 42 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7176117
Add data structs for time zone names, based on properties name structs
sffc Sep 11, 2023
2b1d2b1
Add datagen code (not wired in yet)
sffc Sep 11, 2023
af7b806
Add public-facing APIs
sffc Sep 11, 2023
4c15a57
FFI for the IANA name mappers
sffc Sep 11, 2023
61c7a37
Add to datagen registry
sffc Sep 11, 2023
1f2b33b
cargo make testdata
sffc Sep 11, 2023
eb90683
Change data model for IANA-to-BCP47 to use ZeroTrie
sffc Sep 11, 2023
7eb8e67
lockfile
sffc Sep 11, 2023
8e1aa22
cargo make testdata
sffc Sep 11, 2023
57762fd
Use new function name
sffc Sep 12, 2023
c4cc8da
Initial work for new Bcp47ToIanaMapper
sffc Sep 13, 2023
5c23615
Renames and TODOs
sffc Sep 13, 2023
0d40da5
Remove the list and retain only the checksum. Validate in constructor.
sffc Sep 13, 2023
3444868
cargo make testdata
sffc Sep 13, 2023
50667eb
Add the two new keys to bakeddata
sffc Sep 13, 2023
94393f2
Wire the baked data into the APIs
sffc Sep 13, 2023
4b57cf9
Change to all case insensitive lookup
sffc Sep 13, 2023
88c0666
Update diplomat bindings
sffc Sep 13, 2023
49c9783
diplomat-gen
sffc Sep 13, 2023
89205c5
generate-readmes
sffc Sep 13, 2023
ddd3658
lockfiles and gn-gen
sffc Sep 13, 2023
11d3b3f
fmt, doc
sffc Sep 13, 2023
8c81149
diplomat-gen
sffc Sep 13, 2023
57999db
fmt
sffc Sep 13, 2023
495a30b
Delete NormalizedTimeZoneIdStr (dead code!)
sffc Sep 13, 2023
08c3076
Fix datetime docs test
sffc Sep 13, 2023
05d925f
Review feedback
sffc Sep 13, 2023
4bd2e81
gn gen
sffc Sep 13, 2023
ad024fa
doc
sffc Sep 13, 2023
4e603eb
Update components/timezone/src/iana_ids.rs
sffc Sep 13, 2023
1032c7d
Better checksum computation with test
sffc Sep 13, 2023
0a33032
Fix checksum assertion
sffc Sep 13, 2023
5c62ec8
Add zerotrie to testdata deps
sffc Sep 13, 2023
6bcd8ea
generate-readmes
sffc Sep 13, 2023
057dd0e
Switch XxHash to SipHash
sffc Sep 14, 2023
dd54fe3
More testing
sffc Sep 14, 2023
5fea5f3
Delete the unused dependency
sffc Sep 14, 2023
44af79f
add zerotrie to depcheck
sffc Sep 14, 2023
b33aed9
Switch SipHash to XxHash
sffc Sep 14, 2023
6b8690b
twox-hash deps
sffc Sep 15, 2023
01cd5f2
Merge branch 'main' into new-iana
sffc Sep 19, 2023
4a6cb1b
datagen
robertbastian Sep 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions components/datetime/src/time_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,22 @@ where
///
/// ```
/// use icu::calendar::DateTime;
/// use icu::timezone::{CustomTimeZone, MetazoneCalculator};
/// use icu::timezone::{CustomTimeZone, MetazoneCalculator, IanaToBcp47Mapper};
/// use icu::datetime::{DateTimeError, time_zone::TimeZoneFormatter};
/// use icu::locid::locale;
/// use tinystr::tinystr;
/// use writeable::assert_writeable_eq;
///
/// // Set up the time zone. Note: the inputs here are
/// // 1. The GMT offset
/// // 2. The BCP-47 time zone ID
/// // 2. The IANA time zone ID
/// // 3. A datetime (for metazone resolution)
/// // 4. Note: we do not need the zone variant because of `load_generic_*()`
///
/// // Set up the Metazone calculator and the DateTime to use in calculation
/// // Set up the Metazone calculator, time zone ID mapper,
/// // and the DateTime to use in calculation
/// let mzc = MetazoneCalculator::new();
/// let mapper = IanaToBcp47Mapper::new();
/// let datetime = DateTime::try_new_iso_datetime(2022, 8, 29, 0, 0, 0)
/// .unwrap();
///
Expand All @@ -102,7 +104,7 @@ where
///
/// // "uschi" - has metazone symbol data for generic_non_location_short
/// let mut time_zone = "-0600".parse::<CustomTimeZone>().unwrap();
/// time_zone.time_zone_id = Some(tinystr!(8, "uschi").into());
/// time_zone.time_zone_id = mapper.as_borrowed().get("America/Chicago");
/// time_zone.maybe_calculate_metazone(&mzc, &datetime);
/// assert_writeable_eq!(
/// tzf.format(&time_zone),
Expand Down
5 changes: 3 additions & 2 deletions components/timezone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ icu_calendar = { workspace = true }
icu_locid = { workspace = true }
icu_provider = { workspace = true, features = ["macros"] }
tinystr = { workspace = true, features = ["alloc", "zerovec"] }
zerotrie = { workspace = true, features = ["yoke", "zerofrom"] }
zerovec = { workspace = true, features = ["derive", "yoke"] }

databake = { workspace = true, optional = true, features = ["derive"] }
Expand All @@ -38,6 +39,6 @@ icu = { workspace = true }
[features]
default = ["compiled_data"]
std = ["icu_calendar/std", "icu_locid/std", "icu_provider/std"]
serde = ["dep:serde", "zerovec/serde", "tinystr/serde", "icu_provider/serde"]
datagen = ["serde", "dep:databake", "zerovec/databake", "tinystr/databake"]
serde = ["dep:serde", "zerovec/serde", "zerotrie/serde", "tinystr/serde", "icu_provider/serde"]
datagen = ["serde", "dep:databake", "zerovec/databake", "zerotrie/databake", "tinystr/databake"]
compiled_data = ["dep:icu_timezone_data"]
21 changes: 13 additions & 8 deletions components/timezone/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion components/timezone/data/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"keys": {
"explicit": [
"time_zone/metazone_period@1"
"time_zone/metazone_period@1",
"time_zone/iana_to_bcp47@1",
"time_zone/bcp47_to_iana@1"
]
},
"fallback": "runtime",
Expand Down
10 changes: 10 additions & 0 deletions components/timezone/data/data/macros.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components/timezone/data/data/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions components/timezone/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub enum TimeZoneError {
/// The time zone offset was invalid.
#[displaydoc("Failed to parse time-zone offset")]
InvalidOffset,
/// The data name checksums do not match (data from different sources?)
#[displaydoc("Data checksums to not match (mismatched data sources?)")]
MismatchedChecksums,
/// An error originating inside of the [data provider](icu_provider).
#[displaydoc("{0}")]
Data(DataError),
Expand Down
Loading