Skip to content

Commit 834eac9

Browse files
MonthInfo::to_input (#7756)
Fixes #7693 ## Changelog: TBD
1 parent 0f9ba47 commit 834eac9

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

components/calendar/src/any_calendar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ mod tests {
14061406

14071407
assert_eq!(
14081408
(month, day),
1409-
(date.month().as_input(), date.day_of_month().0),
1409+
(date.month().to_input(), date.day_of_month().0),
14101410
"Failed to roundtrip for calendar {}",
14111411
calendar.debug_name()
14121412
);

components/calendar/src/cal/east_asian_traditional.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl Date<KoreanTraditional> {
459459
/// .expect("Failed to initialize Date instance.");
460460
///
461461
/// assert_eq!(date.cyclic_year().related_iso, 2025);
462-
/// assert_eq!(date.month().as_input(), Month::new(5));
462+
/// assert_eq!(date.month().to_input(), Month::new(5));
463463
/// assert_eq!(date.day_of_month().0, 25);
464464
/// ```
465465
pub fn try_new_korean_traditional(
@@ -808,7 +808,7 @@ impl Date<ChineseTraditional> {
808808
/// .expect("Failed to initialize Date instance.");
809809
///
810810
/// assert_eq!(date.cyclic_year().related_iso, 2025);
811-
/// assert_eq!(date.month().as_input(), Month::new(5));
811+
/// assert_eq!(date.month().to_input(), Month::new(5));
812812
/// assert_eq!(date.day_of_month().0, 25);
813813
/// ```
814814
pub fn try_new_chinese_traditional(
@@ -1376,7 +1376,7 @@ mod test {
13761376

13771377
assert_eq!(chinese.cyclic_year().related_iso, -2636);
13781378
assert_eq!(chinese.month().ordinal, 1);
1379-
assert_eq!(chinese.month().as_input(), Month::new(1));
1379+
assert_eq!(chinese.month().to_input(), Month::new(1));
13801380
assert_eq!(chinese.day_of_month().0, 1);
13811381
assert_eq!(chinese.cyclic_year().year, 1);
13821382
assert_eq!(chinese.cyclic_year().related_iso, -2636);
@@ -1569,7 +1569,7 @@ mod test {
15691569
let iso = Date::try_new_iso(case.iso_year, case.iso_month, case.iso_day).unwrap();
15701570
let chinese = iso.to_calendar(ChineseTraditional::new());
15711571
assert_eq!(
1572-
chinese.month().as_input(),
1572+
chinese.month().to_input(),
15731573
case.month,
15741574
"Month codes did not match for test case: {case:?}"
15751575
);
@@ -1732,7 +1732,7 @@ mod test {
17321732
};
17331733
let date = Date::try_from_fields(fields, options, cal).unwrap();
17341734
assert_eq!(
1735-
date.month().as_input(),
1735+
date.month().to_input(),
17361736
Month::new(1),
17371737
"Month was successfully constrained"
17381738
);

components/calendar/src/cal/hebrew.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ mod tests {
529529
Date::try_new_from_codes(
530530
Some(&date.era_year().era),
531531
date.era_year().year,
532-
date.month().as_input().code(),
532+
date.month().to_input().code(),
533533
date.day_of_month().0,
534534
Hebrew
535535
),
@@ -539,7 +539,7 @@ mod tests {
539539
assert_eq!(
540540
Date::try_new_hebrew_v2(
541541
date.era_year().year,
542-
date.month().as_input(),
542+
date.month().to_input(),
543543
date.day_of_month().0,
544544
),
545545
Ok(date)

components/calendar/src/tests/arithmetic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ where
2020
fn from(value: Date<C>) -> Self {
2121
Self {
2222
year: value.year().extended_year(),
23-
month: value.month().as_input(),
23+
month: value.month().to_input(),
2424
day: value.day_of_month().0,
2525
}
2626
}

components/calendar/src/types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,8 @@ pub struct MonthInfo {
648648

649649
pub(crate) leap_status: LeapStatus,
650650

651-
/// The [`Month::code()`] of [`Self::as_input`].
652-
#[deprecated(since = "2.2.0", note = "use `as_input().code()")]
651+
/// The [`Month::code()`] of [`Self::to_input`].
652+
#[deprecated(since = "2.2.0", note = "use `to_input().code()")]
653653
pub standard_code: MonthCode,
654654

655655
/// Deprecated
@@ -716,14 +716,14 @@ impl MonthInfo {
716716
///
717717
/// [`Date::try_new_from_codes`]: crate::Date::try_new_from_codes
718718
/// [`Date::try_from_fields`]: crate::Date::try_from_fields
719-
pub fn as_input(&self) -> Month {
719+
pub fn to_input(&self) -> Month {
720720
Month::new_unchecked(self.number, self.leap_status == LeapStatus::Leap)
721721
}
722722

723-
/// Equivalent to `.as_input().is_leap()`
724-
#[deprecated(since = "2.2.0", note = "use `.as_input().is_leap()`")]
723+
/// Equivalent to `.to_input().is_leap()`
724+
#[deprecated(since = "2.2.0", note = "use `.to_input().is_leap()`")]
725725
pub fn is_leap(self) -> bool {
726-
self.as_input().is_leap()
726+
self.to_input().is_leap()
727727
}
728728

729729
/// Gets the month number. A month number N is not necessarily the Nth month in the year

components/calendar/tests/reference_year.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ where
2525
let mut rd = Date::try_new_iso(1972, 12, 31).unwrap().to_rata_die();
2626
for _ in 1..2000 {
2727
let date = Date::from_rata_die(rd, cal);
28-
let month_day = (date.month().as_input(), date.day_of_month().0);
28+
let month_day = (date.month().to_input(), date.day_of_month().0);
2929
let mut fields = DateFields::default();
30-
fields.month = Some(date.month().as_input());
30+
fields.month = Some(date.month().to_input());
3131
fields.day = Some(month_day.1);
3232
let mut options = DateFromFieldsOptions::default();
3333
options.missing_fields_strategy = Some(MissingFieldsStrategy::Ecma);
@@ -84,7 +84,7 @@ where
8484
// Test round-trip (to valid day number)
8585
if md_validity == ValidityState::ChineseConstrain {
8686
let input_month = fields.month.unwrap();
87-
let output_month = reference_date.month().as_input();
87+
let output_month = reference_date.month().to_input();
8888
// When constraining in the Chinese calendar the month
8989
// stays the same but loses leapiness.
9090
assert_eq!(
@@ -100,7 +100,7 @@ where
100100
} else {
101101
assert_eq!(
102102
fields.month.unwrap(),
103-
reference_date.month().as_input(),
103+
reference_date.month().to_input(),
104104
"{fields:?} {cal:?}"
105105
);
106106
assert_eq!(

components/datetime/src/format/datetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ where
292292
}
293293
Err(e) => {
294294
w.with_part(PART, |w| {
295-
w.with_part(Part::ERROR, |w| w.write_str(&month.as_input().code().0))
295+
w.with_part(Part::ERROR, |w| w.write_str(&month.to_input().code().0))
296296
})?;
297297
Err(match e {
298298
GetNameForMonthError::InvalidMonthCode => {
299-
FormattedDateTimePatternError::InvalidMonthCode(month.as_input().code())
299+
FormattedDateTimePatternError::InvalidMonthCode(month.to_input().code())
300300
}
301301
GetNameForMonthError::InvalidFieldLength => {
302302
FormattedDateTimePatternError::UnsupportedLength(ErrorField(field))

ffi/capi/src/date.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,10 @@ pub mod ffi {
524524
)]
525525
#[diplomat::rust_link(icu::calendar::types::Month, Struct, hidden)]
526526
#[diplomat::rust_link(icu::calendar::types::MonthInfo, Struct, hidden)]
527-
#[diplomat::rust_link(icu::calendar::types::MonthInfo::as_input, FnInStruct, hidden)]
527+
#[diplomat::rust_link(icu::calendar::types::MonthInfo::to_input, FnInStruct, hidden)]
528528
#[diplomat::attr(auto, getter)]
529529
pub fn month_code(&self, write: &mut diplomat_runtime::DiplomatWrite) {
530-
let code = self.0.month().as_input().code();
530+
let code = self.0.month().to_input().code();
531531
let _infallible = write.write_str(&code.0);
532532
}
533533

@@ -551,7 +551,7 @@ pub mod ffi {
551551
)]
552552
#[diplomat::attr(auto, getter)]
553553
pub fn month_is_leap(&self) -> bool {
554-
self.0.month().as_input().is_leap()
554+
self.0.month().to_input().is_leap()
555555
}
556556

557557
/// Returns the year number in the current era for this date

provider/source/src/calendar/eras.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ fn test_calendar_eras() {
215215
Date::try_new_from_codes(
216216
Some(era),
217217
in_era.year().era().unwrap().year,
218-
in_era.month().as_input().code(),
218+
in_era.month().to_input().code(),
219219
in_era.day_of_month().0,
220220
cal,
221221
),

0 commit comments

Comments
 (0)