Skip to content

Commit 89303a6

Browse files
authored
Use 32-bit arithmetic for days (#7796)
Fixes #7771 ## Changelog: N/A Unreleased API, internal change.
1 parent 2e9f90e commit 89303a6

File tree

21 files changed

+195
-187
lines changed

21 files changed

+195
-187
lines changed

components/calendar/fuzz/fuzz_targets/add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct DateDuration {
2626
pub years: u32,
2727
pub months: u32,
2828
pub weeks: u32,
29-
pub days: u64,
29+
pub days: u32,
3030
}
3131

3232
impl From<DateDuration> for icu_calendar::types::DateDuration {

components/calendar/src/cal/coptic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl DateFieldsResolver for Coptic {
6767
}
6868

6969
#[inline]
70-
fn min_months_from(_start: Self::YearInfo, years: i64) -> i64 {
70+
fn min_months_from(_start: Self::YearInfo, years: i32) -> i32 {
7171
13 * years
7272
}
7373

components/calendar/src/cal/east_asian_traditional.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ impl<R: Rules> DateFieldsResolver for EastAsianTraditional<R> {
615615
}
616616

617617
#[inline]
618-
fn min_months_from(_start: Self::YearInfo, years: i64) -> i64 {
618+
fn min_months_from(_start: Self::YearInfo, years: i32) -> i32 {
619619
// By Rules invariant
620620
12 * years + (years / 3)
621621
}
@@ -1220,8 +1220,8 @@ mod test {
12201220
(largest.to_extended_year() - smallest.to_extended_year() + 1) * 12 + num_leap;
12211221
let approximated = EastAsianTraditional::<R>::min_months_from(
12221222
smallest,
1223-
(largest.to_extended_year() - smallest.to_extended_year()) as i64 + 1,
1224-
) as i32;
1223+
(largest.to_extended_year() - smallest.to_extended_year()) + 1,
1224+
);
12251225

12261226
println!(
12271227
"absolute error {}: {}",

components/calendar/src/cal/ethiopian.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl DateFieldsResolver for Ethiopian {
9595
}
9696

9797
#[inline]
98-
fn min_months_from(start: Self::YearInfo, years: i64) -> i64 {
98+
fn min_months_from(start: Self::YearInfo, years: i32) -> i32 {
9999
Coptic::min_months_from(start, years)
100100
}
101101

components/calendar/src/cal/hebrew.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl DateFieldsResolver for Hebrew {
135135
}
136136

137137
#[inline]
138-
fn min_months_from(_start: HebrewYear, years: i64) -> i64 {
138+
fn min_months_from(_start: HebrewYear, years: i32) -> i32 {
139139
// The Hebrew Metonic cycle is 7 leap years every 19 years,
140140
// which comes out to 235 months per 19 years.
141141
//

0 commit comments

Comments
 (0)