icu4x
icu4x copied to clipboard
Indian calendar can return ISO-date with zero day_of_month
The computed ISO date should be 2000-12-31, but instead it returns 2001-01-00.
Not a regression from release 1.5, also reproducible with release 1.4.
Test case:
use icu::calendar::Date;
use icu::calendar::Calendar;
use icu::calendar::indian::Indian;
fn main() {
let cal = Indian;
let iso = Date::try_new_iso_date(2000, 12, 31).unwrap();
let date = cal.date_from_iso(iso);
println!("year = {}", cal.year(&date).number);
println!("month = {}", cal.month(&date).ordinal);
println!("day = {}", cal.day_of_month(&date).0);
let iso = cal.date_to_iso(&date);
println!("iso.year = {}", iso.year().number);
println!("iso.month = {}", iso.month().ordinal);
println!("iso.day = {}", iso.day_of_month().0);
}
Possibly caused by this line: https://github.com/unicode-org/icu4x/blob/6d65cb511267b5f7b91fd18db120a37f44ddf615/components/calendar/src/indian.rs#L153
Changing the test condition from >= days_in_year to > days_in_year could fix this bug.
cc @sffc
This issue was fixed in #5726.