unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.38k stars 177 forks source link

Debug assertion: "Found year with more than one excess day!" with IslamicObservational #5068

Open anba opened 5 months ago

anba commented 5 months ago

The following test case asserts with:

thread 'main' panicked at /home/andre/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calendrical_calculations-0.1.1/src/islamic.rs:106:13:
assertion `left == right` failed: (ObservationalIslamic) Found year -6149 AH with more than one excess day!
  left: 2
 right: 1

Test case:

use icu::calendar::types::{Era, MonthCode};
use icu::calendar::Calendar;
use icu::calendar::islamic::IslamicObservational;

use std::str::FromStr;

fn main() {
  let cal = IslamicObservational::new_always_calculating();

  let era = Era::from_str("ah").unwrap();
  let month_code = MonthCode::from_str("M01").unwrap();

  let dt = cal.date_from_codes(era, -6149, month_code, 31);
}
sffc commented 3 months ago

The direction I want to move is to serve pre-computed Islamic years for all positive years from year 0 to something like 1000 years into the future, and then use an algorithmic approximation for years outside that range.

CC @roozbeh