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 TimeZoneIdMapper to icu_timezone #4774

Merged
merged 35 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1532c70
Add baked data for IanaToBcp47MapV2Marker
sffc Apr 4, 2024
f4845a9
Add new TimeZoneIdMapper type
sffc Apr 4, 2024
4f3bbb4
Add test in datagen
sffc Apr 4, 2024
1dfdc26
fmt
sffc Apr 4, 2024
4ea5be8
features
sffc Apr 4, 2024
60316b3
Merge branch 'main' into iana-canon-2
sffc Apr 4, 2024
90824c9
Update ids.rs
sffc Apr 4, 2024
107173c
Update ids.rs
sffc Apr 4, 2024
4b2516a
Reduce allocations and DRY
sffc Apr 15, 2024
bf11327
Update utils/zerotrie/src/cursor.rs
sffc Apr 15, 2024
8886642
Update components/timezone/src/ids.rs
sffc Apr 15, 2024
b9bc044
Improve examples; rename function
sffc Apr 15, 2024
87f339c
impl Deref for TimeZoneBcp47Id
sffc Apr 15, 2024
66355bb
Safety
sffc Apr 15, 2024
3da0592
Apply bf1132716ebf349f8bfad3c75d0cd2619caa7961 to call site
sffc Apr 15, 2024
8fab067
Return NormalizedIana
sffc Apr 15, 2024
28ee49b
Add TimeZoneIdMapperWithFastCanonicalization
sffc Apr 15, 2024
2d879c3
Deprecate and add FFI
sffc Apr 15, 2024
8629048
FFI fixes
sffc Apr 16, 2024
4310f68
Update public docs and things
sffc Apr 16, 2024
7a59526
features
sffc Apr 16, 2024
8985f9f
clippy, fmt
sffc Apr 16, 2024
69f337d
Merge branch 'main' into iana-canon-2
sffc Apr 18, 2024
92f4e7e
Add constructor Diplomat attr
sffc Apr 18, 2024
fe60770
impl Default
sffc Apr 18, 2024
c817256
Document Normalization vs Canonicalization
sffc Apr 18, 2024
4692100
Line length
sffc Apr 18, 2024
2647dcd
rm NormalizedIana
sffc Apr 18, 2024
4e9d5ee
fmt
sffc Apr 18, 2024
0a5c746
Merge branch 'main' into iana-canon-2
sffc Apr 23, 2024
33015b8
Clippy
sffc Apr 23, 2024
50f5b1e
Review feedback
sffc Apr 24, 2024
63d5b8b
fmt
sffc Apr 24, 2024
ef3f8b0
Merge branch 'main' into iana-canon-2
sffc May 17, 2024
c74ce44
datagen
sffc May 17, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- Implement Hangul_Syllable_Type property (https://github.com/unicode-org/icu4x/pull/4885)
- `icu_segmenter`
- Fix Unicode 15.0 line breaking (https://github.com/unicode-org/icu4x/pull/4389)
- `icu_timezone`
- Added `TimeZoneIdMapper` to replace `IanaToBcp47Mapper` (https://github.com/unicode-org/icu4x/pull/4774)
- Data model and providers
- `icu_datagen`
- Datagen shows elapsed time for keys that are slow to generate (https://github.com/unicode-org/icu4x/pull/4469)
Expand Down
6 changes: 3 additions & 3 deletions components/datetime/src/time_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
///
/// ```
/// use icu::calendar::DateTime;
/// use icu::timezone::{CustomTimeZone, MetazoneCalculator, IanaToBcp47Mapper};
/// use icu::timezone::{CustomTimeZone, MetazoneCalculator, TimeZoneIdMapper};
/// use icu::datetime::{DateTimeError, time_zone::TimeZoneFormatter};
/// use icu::locid::locale;
/// use tinystr::tinystr;
Expand All @@ -87,7 +87,7 @@ where
/// // 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 mapper = TimeZoneIdMapper::new();
/// let datetime = DateTime::try_new_iso_datetime(2022, 8, 29, 0, 0, 0)
/// .unwrap();
///
Expand All @@ -102,7 +102,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 = mapper.as_borrowed().get("America/Chicago");
/// time_zone.time_zone_id = mapper.as_borrowed().iana_to_bcp47("America/Chicago");
/// time_zone.maybe_calculate_metazone(&mzc, &datetime);
/// assert_writeable_eq!(
/// tzf.format(&time_zone),
Expand Down
2 changes: 1 addition & 1 deletion components/timezone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ displaydoc = { workspace = true }
icu_calendar = { workspace = true }
icu_provider = { workspace = true, features = ["macros"] }
tinystr = { workspace = true, features = ["alloc", "zerovec"] }
zerotrie = { workspace = true, features = ["yoke", "zerofrom"] }
zerotrie = { workspace = true, features = ["alloc", "yoke", "zerofrom"] }
zerovec = { workspace = true, features = ["derive", "yoke"] }

databake = { workspace = true, optional = true, features = ["derive"] }
Expand Down
8 changes: 4 additions & 4 deletions components/timezone/README.md

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

6 changes: 6 additions & 0 deletions components/timezone/src/iana_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

#![allow(deprecated)] // all APIS in here are deprecated

use crate::error::TimeZoneError;
use crate::provider::names::*;
use crate::TimeZoneBcp47Id;
Expand Down Expand Up @@ -36,6 +38,7 @@ use icu_provider::prelude::*;
/// );
/// ```
#[derive(Debug)]
#[deprecated(since = "1.5.0", note = "use `TimeZoneIdMapper` instead")]
pub struct IanaToBcp47Mapper {
data: DataPayload<IanaToBcp47MapV1Marker>,
}
Expand Down Expand Up @@ -98,6 +101,7 @@ impl IanaToBcp47Mapper {
/// A borrowed wrapper around IANA-to-BCP47 time zone data, returned by
/// [`IanaToBcp47Mapper::as_borrowed()`]. More efficient to query.
#[derive(Debug)]
#[deprecated(since = "1.5.0", note = "use `TimeZoneIdMapper` instead")]
pub struct IanaToBcp47MapperBorrowed<'a> {
data: &'a IanaToBcp47MapV1<'a>,
}
Expand Down Expand Up @@ -167,6 +171,7 @@ impl<'a> IanaToBcp47MapperBorrowed<'a> {
/// assert_eq!(iana_id, Some("Asia/Kolkata"))
/// ```
#[derive(Debug)]
#[deprecated(since = "1.5.0", note = "use `TimeZoneIdMapper` instead")]
pub struct IanaBcp47RoundTripMapper {
data1: DataPayload<IanaToBcp47MapV1Marker>,
data2: DataPayload<Bcp47ToIanaMapV1Marker>,
Expand Down Expand Up @@ -243,6 +248,7 @@ impl IanaBcp47RoundTripMapper {
/// A borrowed wrapper around IANA-BCP47 time zone data, returned by
/// [`IanaBcp47RoundTripMapper::as_borrowed()`]. More efficient to query.
#[derive(Debug)]
#[deprecated(since = "1.5.0", note = "use `TimeZoneIdMapper` instead")]
pub struct IanaBcp47RoundTripMapperBorrowed<'a> {
data1: &'a IanaToBcp47MapV1<'a>,
data2: &'a Bcp47ToIanaMapV1<'a>,
Expand Down
Loading
Loading