Skip to content

Commit

Permalink
Bring TimePrecision up to spec with latest CLDR proposal (#5979)
Browse files Browse the repository at this point in the history
Fixes #5883
  • Loading branch information
sffc authored Jan 15, 2025
1 parent 11945b4 commit e26824f
Show file tree
Hide file tree
Showing 19 changed files with 203 additions and 207 deletions.
6 changes: 2 additions & 4 deletions components/datetime/benches/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use icu_datetime::{
fieldsets::serde::CompositeFieldSetSerde, options, provider::fields::components,
};
use icu_datetime::{fieldsets::serde::CompositeFieldSetSerde, provider::fields::components};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -61,7 +59,7 @@ pub struct TestComponentsBag {
pub hour: Option<components::Numeric>,
pub minute: Option<components::Numeric>,
pub second: Option<components::Numeric>,
pub fractional_second: Option<options::FractionalSecondDigits>,
pub fractional_second: Option<u8>,

pub time_zone_name: Option<components::TimeZoneName>,
}
Expand Down
38 changes: 19 additions & 19 deletions components/datetime/benches/fixtures/tests/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"semantic": {
"fieldSet": ["weekday", "time"],
"length": "medium",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h12"
}
Expand All @@ -268,7 +268,7 @@
"semantic": {
"fieldSet": ["weekday", "time"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
},
"hourCycle": "h12"
}
Expand All @@ -284,7 +284,7 @@
"semantic": {
"fieldSet": ["weekday", "time"],
"length": "medium",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h23"
}
Expand All @@ -301,7 +301,7 @@
"semantic": {
"fieldSet": ["weekday", "time"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
},
"hourCycle": "h23"
}
Expand All @@ -315,7 +315,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "hourExact"
"timePrecision": "hour"
},
"hourCycle": "h12"
}
Expand All @@ -330,7 +330,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h12"
}
Expand All @@ -346,7 +346,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
},
"hourCycle": "h12"
}
Expand All @@ -360,7 +360,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "hourExact"
"timePrecision": "hour"
},
"hourCycle": "h23"
}
Expand All @@ -375,7 +375,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h23"
}
Expand All @@ -391,7 +391,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
},
"hourCycle": "h23"
}
Expand All @@ -406,7 +406,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "medium",
"timePrecision": "minuteExact"
"timePrecision": "minute"
}
}
},
Expand Down Expand Up @@ -452,7 +452,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "weekday", "time"],
"length": "medium",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h12"
}
Expand All @@ -472,7 +472,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "weekday", "time"],
"length": "long",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h12"
}
Expand All @@ -487,7 +487,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h11"
}
Expand All @@ -502,7 +502,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h24"
}
Expand All @@ -517,7 +517,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h11"
}
Expand All @@ -532,7 +532,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h12"
}
Expand All @@ -547,7 +547,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h23"
}
Expand All @@ -562,7 +562,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
},
"hourCycle": "h24"
}
Expand Down
12 changes: 6 additions & 6 deletions components/datetime/benches/fixtures/tests/lengths.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
},
Expand All @@ -77,7 +77,7 @@
"semantic": {
"fieldSet": ["time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
}
}
},
Expand All @@ -91,7 +91,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "weekday", "time"],
"length": "long",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
},
Expand All @@ -105,7 +105,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "time"],
"length": "long",
"timePrecision": "minuteExact"
"timePrecision": "minute"
}
}
},
Expand All @@ -119,7 +119,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "time"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
},
Expand All @@ -133,7 +133,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "time"],
"length": "short",
"timePrecision": "minuteExact"
"timePrecision": "minute"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"semantic": {
"fieldSet": ["time", "zoneSpecific"],
"length": "long",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
},
Expand All @@ -25,7 +25,7 @@
"semantic": {
"fieldSet": ["time", "zoneSpecific"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
},
Expand All @@ -39,7 +39,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "weekday", "time", "zoneSpecific"],
"length": "long",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
},
Expand All @@ -53,7 +53,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "time", "zoneSpecific"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "second"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/datetime/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
//! // Display time to the minute
//!
//! let static_field_set = fieldsets::ET::medium()
//! .with_time_precision(TimePrecision::MinuteExact);
//! .with_time_precision(TimePrecision::Minute);
//!
//! let mut builder = FieldSetBuilder::default();
//! builder.date_fields = Some(DateFields::E);
//! builder.time_precision = Some(TimePrecision::MinuteExact);
//! builder.time_precision = Some(TimePrecision::Minute);
//! let dynamic_field_set = builder.build_date_and_time().unwrap();
//!
//! assert_eq!(
Expand All @@ -65,13 +65,13 @@
//! // Render for column alignment
//!
//! let static_field_set = fieldsets::T::short()
//! .with_time_precision(TimePrecision::SecondExact(FractionalSecondDigits::F3))
//! .with_time_precision(TimePrecision::FractionalSecond(FractionalSecondDigits::F3))
//! .with_alignment(Alignment::Column)
//! .with_zone_specific_long();
//!
//! let mut builder = FieldSetBuilder::default();
//! builder.length = Some(Length::Short);
//! builder.time_precision = Some(TimePrecision::SecondExact(FractionalSecondDigits::F3));
//! builder.time_precision = Some(TimePrecision::FractionalSecond(FractionalSecondDigits::F3));
//! builder.alignment = Some(Alignment::Column);
//! builder.zone_style = Some(ZoneStyle::Z);
//! let dynamic_field_set = builder.build_composite().unwrap();
Expand Down
8 changes: 4 additions & 4 deletions components/datetime/src/fieldsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
//! let field_set_1 = YMDT::long()
//! .with_year_style(YearStyle::Full)
//! .with_alignment(Alignment::Column)
//! .with_time_precision(TimePrecision::MinuteExact);
//! .with_time_precision(TimePrecision::Minute);
//!
//! let mut field_set_2 = YMDT::long();
//! field_set_2.year_style = Some(YearStyle::Full);
//! field_set_2.alignment = Some(Alignment::Column);
//! field_set_2.time_precision = Some(TimePrecision::MinuteExact);
//! field_set_2.time_precision = Some(TimePrecision::Minute);
//!
//! assert_eq!(field_set_1, field_set_2);
//! ```
Expand Down Expand Up @@ -277,9 +277,9 @@ macro_rules! impl_marker_with_options {
self.time_precision = Some(yes_to!(time_precision, $timeprecision_yes));
self
}
/// Sets the time precision to [`TimePrecision::MinuteExact`]
/// Sets the time precision to [`TimePrecision::Minute`]
pub fn hm(mut self) -> Self {
self.time_precision = Some(TimePrecision::MinuteExact);
self.time_precision = Some(TimePrecision::Minute);
self
}
}
Expand Down
Loading

0 comments on commit e26824f

Please sign in to comment.