Skip to content

Commit b2cc238

Browse files
Remove HourCycle::H24 (#6426)
Fixes #6220
1 parent 0bd710b commit b2cc238

File tree

19 files changed

+35
-155
lines changed

19 files changed

+35
-155
lines changed

components/datetime/benches/fixtures/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub enum TestHourCycle {
7070
H11,
7171
H12,
7272
H23,
73-
H24,
7473
}
7574

7675
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]

components/datetime/benches/fixtures/tests/components.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@
495495
"length": "short",
496496
"timePrecision": "minute"
497497
},
498-
"hourCycle": "h24"
498+
"hourCycle": "h23"
499499
}
500500
},
501501
{
@@ -551,7 +551,7 @@
551551
"length": "short",
552552
"timePrecision": "minute"
553553
},
554-
"hourCycle": "h24"
554+
"hourCycle": "h23"
555555
}
556556
}
557557
],

components/datetime/src/dynamic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl TimeFieldSet {
480480
match hour_cycle {
481481
None => Self::ATTR_T,
482482
Some(H11 | H12) => Self::ATTR_T12,
483-
Some(H23 | H24) => Self::ATTR_T24,
483+
Some(H23) => Self::ATTR_T24,
484484
}
485485
}
486486
}

components/datetime/src/fieldsets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,14 +1118,14 @@ impl_time_marker!(
11181118
/// );
11191119
///
11201120
/// let formatter = NoCalendarFormatter::try_new(
1121-
/// locale!("und-u-hc-h24").into(),
1121+
/// locale!("und-u-hc-h23").into(),
11221122
/// T::short().hm(),
11231123
/// )
11241124
/// .unwrap();
11251125
///
11261126
/// assert_writeable_eq!(
11271127
/// formatter.format(&Time::try_new(0, 0, 0, 0).unwrap()),
1128-
/// "24:00"
1128+
/// "00:00"
11291129
/// );
11301130
/// ```
11311131
///

components/datetime/src/format/datetime.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,6 @@ where
342342
}
343343
}
344344
fields::Hour::H23 => h,
345-
fields::Hour::H24 => {
346-
if h == 0 {
347-
24
348-
} else {
349-
h
350-
}
351-
}
352345
};
353346
try_write_number(PART, w, decimal_formatter, h.into(), l)?
354347
}

components/datetime/src/provider/fields/components.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ impl Bag {
249249
// fields::Hour::H11
250250
// fields::Hour::H12
251251
// fields::Hour::H23
252-
// fields::Hour::H24
253252

254253
let hour_cycle = self.hour_cycle.unwrap_or(default_hour_cycle);
255254

@@ -266,7 +265,7 @@ impl Bag {
266265
}
267266
// Skeletons only contain the h23, not h24. The pattern that is matched
268267
// is free to use h23 or h24.
269-
HourCycle::H24 | HourCycle::H23 => {
268+
HourCycle::H23 => {
270269
// H - symbol
271270
fields::Hour::H23
272271
}
@@ -714,7 +713,6 @@ impl Bag {
714713
fields::Hour::H11 => HourCycle::H11,
715714
fields::Hour::H12 => HourCycle::H12,
716715
fields::Hour::H23 => HourCycle::H23,
717-
fields::Hour::H24 => HourCycle::H24,
718716
});
719717
}
720718
FieldSymbol::Minute => {

components/datetime/src/provider/fields/symbols.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl core::error::Error for SymbolError {}
3333
/// Field symbols are a more granular distinction
3434
/// for a pattern field within the category of a field type. Examples of field types are:
3535
/// `Year`, `Month`, `Hour`. Within the [`Hour`] field type, examples of field symbols are: [`Hour::H12`],
36-
/// [`Hour::H24`]. Each field symbol is represented within the date formatting pattern string
36+
/// [`Hour::H23`]. Each field symbol is represented within the date formatting pattern string
3737
/// by a distinct character from the set of `A..Z` and `a..z`.
3838
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
3939
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
@@ -297,7 +297,6 @@ impl FieldSymbol {
297297
Self::Hour(Hour::H11) => 18,
298298
Self::Hour(Hour::H12) => 19,
299299
Self::Hour(Hour::H23) => 20,
300-
Self::Hour(Hour::H24) => 21,
301300
Self::Minute => 22,
302301
Self::Second(Second::Second) => 23,
303302
Self::Second(Second::MillisInDay) => 24,
@@ -583,8 +582,6 @@ field_type!(
583582
'h' => H12 = 1,
584583
/// Field symbol for numeric hour [0-23].
585584
'H' => H23 = 2,
586-
/// Field symbol for numeric hour [1-24].
587-
'k' => H24 = 3,
588585
};
589586
Numeric;
590587
HourULE
@@ -596,7 +593,6 @@ impl Hour {
596593
HourCycle::H11 => Self::H11,
597594
HourCycle::H12 => Self::H12,
598595
HourCycle::H23 => Self::H23,
599-
HourCycle::H24 => Self::H24,
600596
_ => unreachable!(),
601597
}
602598
}

components/datetime/src/provider/pattern/hour_cycle.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::provider::{self, skeleton};
1212
use icu_locale_core::preferences::extensions::unicode::keywords::HourCycle;
1313
use icu_provider::prelude::*;
1414

15-
/// Used to represent either H11/H12, or H23/H24. Skeletons only store these
15+
/// Used to represent either H11/H12, or H23. Skeletons only store these
1616
/// hour cycles as H12 or H23.
1717
#[derive(Debug, PartialEq, Clone, Copy, yoke::Yokeable, zerofrom::ZeroFrom)]
1818
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
@@ -22,15 +22,15 @@ use icu_provider::prelude::*;
2222
pub enum CoarseHourCycle {
2323
/// Can either be fields::Hour::H11 or fields::Hour::H12
2424
H11H12,
25-
/// Can either be fields::Hour::H23 or fields::Hour::H24
26-
H23H24,
25+
/// fields::Hour::H23
26+
H23,
2727
}
2828

29-
/// Default is required for serialization. H23H24 is the more locale-agnostic choice, as it's
29+
/// Default is required for serialization. H23 is the more locale-agnostic choice, as it's
3030
/// less likely to have a day period in it.
3131
impl Default for CoarseHourCycle {
3232
fn default() -> Self {
33-
CoarseHourCycle::H23H24
33+
CoarseHourCycle::H23
3434
}
3535
}
3636

@@ -46,7 +46,7 @@ impl CoarseHourCycle {
4646
{
4747
return Some(match pattern_hour {
4848
fields::Hour::H11 | fields::Hour::H12 => CoarseHourCycle::H11H12,
49-
fields::Hour::H23 | fields::Hour::H24 => CoarseHourCycle::H23H24,
49+
fields::Hour::H23 => CoarseHourCycle::H23,
5050
});
5151
}
5252
}
@@ -71,11 +71,11 @@ impl CoarseHourCycle {
7171
if match self {
7272
CoarseHourCycle::H11H12 => match pattern_hour {
7373
fields::Hour::H11 | fields::Hour::H12 => true,
74-
fields::Hour::H23 | fields::Hour::H24 => false,
74+
fields::Hour::H23 => false,
7575
},
76-
CoarseHourCycle::H23H24 => match pattern_hour {
76+
CoarseHourCycle::H23 => match pattern_hour {
7777
fields::Hour::H11 | fields::Hour::H12 => false,
78-
fields::Hour::H23 | fields::Hour::H24 => true,
78+
fields::Hour::H23 => true,
7979
},
8080
} {
8181
// The preference hour cycle matches the pattern, bail out early and
@@ -85,7 +85,7 @@ impl CoarseHourCycle {
8585
// Mutate the pattern with the new symbol, so that it can be matched against.
8686
*symbol = fields::FieldSymbol::Hour(match self {
8787
CoarseHourCycle::H11H12 => fields::Hour::H12,
88-
CoarseHourCycle::H23H24 => fields::Hour::H23,
88+
CoarseHourCycle::H23 => fields::Hour::H23,
8989
});
9090
break;
9191
}
@@ -117,8 +117,8 @@ impl CoarseHourCycle {
117117
/// Get the other coarse hour cycle (map h11/h12 to h23/h24, and vice versa)
118118
pub fn invert(self) -> Self {
119119
match self {
120-
CoarseHourCycle::H11H12 => CoarseHourCycle::H23H24,
121-
CoarseHourCycle::H23H24 => CoarseHourCycle::H11H12,
120+
CoarseHourCycle::H11H12 => CoarseHourCycle::H23,
121+
CoarseHourCycle::H23 => CoarseHourCycle::H11H12,
122122
}
123123
}
124124
}

components/datetime/src/provider/skeleton/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl components::Bag {
534534

535535
let default_hour_cycle = match preferred_hour_cycle {
536536
CoarseHourCycle::H11H12 => HourCycle::H12,
537-
CoarseHourCycle::H23H24 => HourCycle::H23,
537+
CoarseHourCycle::H23 => HourCycle::H23,
538538
};
539539
let fields = self.to_vec_fields(default_hour_cycle);
540540
match create_best_pattern_for_fields(skeletons, length_patterns, &fields, &self, false) {

components/datetime/src/provider/skeleton/reference.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ impl From<&Pattern> for Skeleton {
9898
FieldSymbol::Hour(fields::Hour::H11) | FieldSymbol::Hour(fields::Hour::H12) => {
9999
FieldSymbol::Hour(fields::Hour::H12)
100100
}
101-
FieldSymbol::Hour(fields::Hour::H23) | FieldSymbol::Hour(fields::Hour::H24) => {
102-
FieldSymbol::Hour(fields::Hour::H23)
103-
}
101+
FieldSymbol::Hour(fields::Hour::H23) => FieldSymbol::Hour(fields::Hour::H23),
104102

105103
// Pass through all of the following preferences unchanged.
106104
FieldSymbol::Minute

0 commit comments

Comments
 (0)