Skip to content

Commit

Permalink
Add workaround for unicode-org#5387
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Aug 16, 2024
1 parent de3a6b5 commit 86e3560
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/datetime/src/raw/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ impl DateTimeZonePatternSelectionData {
Ok(Self::Zone(selection))
}
NeoComponents::DateTime(day_components, time_components) => {
if let Some(marker_attrs) = components.id_str() {
// TODO(#5387): load the patterns for custom hour cycles here
if let (Some(marker_attrs), None) = (components.id_str(), hour_cycle) {
// Try loading an overlap pattern.
let length = length.get::<Self>();
let date_skeleton = NeoDateSkeleton {
Expand Down
28 changes: 28 additions & 0 deletions components/datetime/tests/simple_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,31 @@ fn hebrew_months() {

assert_try_writeable_eq!(formatted_datetime, "28 Adar II 5771");
}

#[test]
fn test_5387() {
let datetime = DateTime::try_new_gregorian_datetime(2024, 8, 16, 14, 15, 16).unwrap();
let formatter_auto = TypedNeoFormatter::try_new_with_components(
&locale!("en").into(),
NeoDateTimeComponents::DateTime(NeoDayComponents::Weekday, NeoTimeComponents::HourMinute),
NeoSkeletonLength::Medium.into(),
)
.unwrap();
let formatter_h12 = TypedNeoFormatter::try_new_with_components(
&locale!("en-u-hc-h12").into(),
NeoDateTimeComponents::DateTime(NeoDayComponents::Weekday, NeoTimeComponents::HourMinute),
NeoSkeletonLength::Medium.into(),
)
.unwrap();
let formatter_h24 = TypedNeoFormatter::try_new_with_components(
&locale!("en-u-hc-h23").into(),
NeoDateTimeComponents::DateTime(NeoDayComponents::Weekday, NeoTimeComponents::HourMinute),
NeoSkeletonLength::Medium.into(),
)
.unwrap();

// TODO(#5387): All of these should resolve to a pattern without a comma
assert_try_writeable_eq!(formatter_auto.format(&datetime), "Fri 2:15\u{202f}PM");
assert_try_writeable_eq!(formatter_h12.format(&datetime), "Fri, 2:15\u{202f}PM");
assert_try_writeable_eq!(formatter_h24.format(&datetime), "Fri, 14:15");
}

0 comments on commit 86e3560

Please sign in to comment.