Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ mod tests {

assert_eq!(
(month, day),
(date.month().as_input(), date.day_of_month().0),
(date.month().to_input(), date.day_of_month().0),
"Failed to roundtrip for calendar {}",
calendar.debug_name()
);
Expand Down
10 changes: 5 additions & 5 deletions components/calendar/src/cal/east_asian_traditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ impl Date<KoreanTraditional> {
/// .expect("Failed to initialize Date instance.");
///
/// assert_eq!(date.cyclic_year().related_iso, 2025);
/// assert_eq!(date.month().as_input(), Month::new(5));
/// assert_eq!(date.month().to_input(), Month::new(5));
/// assert_eq!(date.day_of_month().0, 25);
/// ```
pub fn try_new_korean_traditional(
Expand Down Expand Up @@ -808,7 +808,7 @@ impl Date<ChineseTraditional> {
/// .expect("Failed to initialize Date instance.");
///
/// assert_eq!(date.cyclic_year().related_iso, 2025);
/// assert_eq!(date.month().as_input(), Month::new(5));
/// assert_eq!(date.month().to_input(), Month::new(5));
/// assert_eq!(date.day_of_month().0, 25);
/// ```
pub fn try_new_chinese_traditional(
Expand Down Expand Up @@ -1376,7 +1376,7 @@ mod test {

assert_eq!(chinese.cyclic_year().related_iso, -2636);
assert_eq!(chinese.month().ordinal, 1);
assert_eq!(chinese.month().as_input(), Month::new(1));
assert_eq!(chinese.month().to_input(), Month::new(1));
assert_eq!(chinese.day_of_month().0, 1);
assert_eq!(chinese.cyclic_year().year, 1);
assert_eq!(chinese.cyclic_year().related_iso, -2636);
Expand Down Expand Up @@ -1569,7 +1569,7 @@ mod test {
let iso = Date::try_new_iso(case.iso_year, case.iso_month, case.iso_day).unwrap();
let chinese = iso.to_calendar(ChineseTraditional::new());
assert_eq!(
chinese.month().as_input(),
chinese.month().to_input(),
case.month,
"Month codes did not match for test case: {case:?}"
);
Expand Down Expand Up @@ -1732,7 +1732,7 @@ mod test {
};
let date = Date::try_from_fields(fields, options, cal).unwrap();
assert_eq!(
date.month().as_input(),
date.month().to_input(),
Month::new(1),
"Month was successfully constrained"
);
Expand Down
4 changes: 2 additions & 2 deletions components/calendar/src/cal/hebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ mod tests {
Date::try_new_from_codes(
Some(&date.era_year().era),
date.era_year().year,
date.month().as_input().code(),
date.month().to_input().code(),
date.day_of_month().0,
Hebrew
),
Expand All @@ -539,7 +539,7 @@ mod tests {
assert_eq!(
Date::try_new_hebrew_v2(
date.era_year().year,
date.month().as_input(),
date.month().to_input(),
date.day_of_month().0,
),
Ok(date)
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/src/tests/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ where
fn from(value: Date<C>) -> Self {
Self {
year: value.year().extended_year(),
month: value.month().as_input(),
month: value.month().to_input(),
day: value.day_of_month().0,
}
}
Expand Down
12 changes: 6 additions & 6 deletions components/calendar/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ pub struct MonthInfo {

pub(crate) leap_status: LeapStatus,

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

/// Deprecated
Expand Down Expand Up @@ -716,14 +716,14 @@ impl MonthInfo {
///
/// [`Date::try_new_from_codes`]: crate::Date::try_new_from_codes
/// [`Date::try_from_fields`]: crate::Date::try_from_fields
pub fn as_input(&self) -> Month {
pub fn to_input(&self) -> Month {
Month::new_unchecked(self.number, self.leap_status == LeapStatus::Leap)
}

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

/// Gets the month number. A month number N is not necessarily the Nth month in the year
Expand Down
8 changes: 4 additions & 4 deletions components/calendar/tests/reference_year.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ where
let mut rd = Date::try_new_iso(1972, 12, 31).unwrap().to_rata_die();
for _ in 1..2000 {
let date = Date::from_rata_die(rd, cal);
let month_day = (date.month().as_input(), date.day_of_month().0);
let month_day = (date.month().to_input(), date.day_of_month().0);
let mut fields = DateFields::default();
fields.month = Some(date.month().as_input());
fields.month = Some(date.month().to_input());
fields.day = Some(month_day.1);
let mut options = DateFromFieldsOptions::default();
options.missing_fields_strategy = Some(MissingFieldsStrategy::Ecma);
Expand Down Expand Up @@ -84,7 +84,7 @@ where
// Test round-trip (to valid day number)
if md_validity == ValidityState::ChineseConstrain {
let input_month = fields.month.unwrap();
let output_month = reference_date.month().as_input();
let output_month = reference_date.month().to_input();
// When constraining in the Chinese calendar the month
// stays the same but loses leapiness.
assert_eq!(
Expand All @@ -100,7 +100,7 @@ where
} else {
assert_eq!(
fields.month.unwrap(),
reference_date.month().as_input(),
reference_date.month().to_input(),
"{fields:?} {cal:?}"
);
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions components/datetime/src/format/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ where
}
Err(e) => {
w.with_part(PART, |w| {
w.with_part(Part::ERROR, |w| w.write_str(&month.as_input().code().0))
w.with_part(Part::ERROR, |w| w.write_str(&month.to_input().code().0))
})?;
Err(match e {
GetNameForMonthError::InvalidMonthCode => {
FormattedDateTimePatternError::InvalidMonthCode(month.as_input().code())
FormattedDateTimePatternError::InvalidMonthCode(month.to_input().code())
}
GetNameForMonthError::InvalidFieldLength => {
FormattedDateTimePatternError::UnsupportedLength(ErrorField(field))
Expand Down
4 changes: 2 additions & 2 deletions ffi/capi/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ pub mod ffi {
#[diplomat::rust_link(icu::calendar::types::MonthInfo::as_input, FnInStruct, hidden)]
#[diplomat::attr(auto, getter)]
pub fn month_code(&self, write: &mut diplomat_runtime::DiplomatWrite) {
let code = self.0.month().as_input().code();
let code = self.0.month().to_input().code();
let _infallible = write.write_str(&code.0);
}

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

/// Returns the year number in the current era for this date
Expand Down
2 changes: 1 addition & 1 deletion provider/source/src/calendar/eras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn test_calendar_eras() {
Date::try_new_from_codes(
Some(era),
in_era.year().era().unwrap().year,
in_era.month().as_input().code(),
in_era.month().to_input().code(),
in_era.day_of_month().0,
cal,
),
Expand Down
Loading