Skip to content

Commit

Permalink
TimePrecision WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Jan 15, 2025
1 parent fc8240b commit 746c049
Show file tree
Hide file tree
Showing 17 changed files with 171 additions and 174 deletions.
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": "auto"
},
"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": "auto"
},
"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": "auto"
},
"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": "auto"
},
"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": "auto"
}
}
},
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": "auto"
}
}
},
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": "auto"
}
}
},
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": "auto"
}
}
},
Expand All @@ -25,7 +25,7 @@
"semantic": {
"fieldSet": ["time", "zoneSpecific"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "auto"
}
}
},
Expand All @@ -39,7 +39,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "weekday", "time", "zoneSpecific"],
"length": "long",
"timePrecision": "secondPlus"
"timePrecision": "auto"
}
}
},
Expand All @@ -53,7 +53,7 @@
"semantic": {
"fieldSet": ["year", "month", "day", "time", "zoneSpecific"],
"length": "medium",
"timePrecision": "secondPlus"
"timePrecision": "auto"
}
}
}
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::Second(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::Second(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 746c049

Please sign in to comment.