Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect week day for Hebrew calendar when ISO year is negative #4893

Closed
anba opened this issue May 13, 2024 · 1 comment · Fixed by #4894
Closed

Incorrect week day for Hebrew calendar when ISO year is negative #4893

anba opened this issue May 13, 2024 · 1 comment · Fixed by #4894
Assignees
Labels
C-calendar Component: Calendars T-bug Type: Bad behavior, security, privacy U-ecma402 User: ECMA-402 compatibility

Comments

@anba
Copy link

anba commented May 13, 2024

Week days are incorrect for the Hebrew calendar as soon as the corresponding ISO date has a negative year.

(Tested with release 1.4.)

use icu::calendar::Date;
use icu::calendar::types::{Era, MonthCode};
use icu::calendar::Calendar;
use icu::calendar::hebrew::Hebrew;

use std::str::FromStr;

fn main() {
  let cal = Hebrew::new_always_calculating();
  let era = Era::from_str("am").unwrap();
  let monthCode = MonthCode::from_str("M01").unwrap();

  let dt = cal.date_from_codes(era, 3760, monthCode, 1).unwrap();
  dbg!(dt);

  // Sunday, but should be Saturday per:
  // https://www.hebcal.com/converter?hd=1&hm=Tishrei&hy=3760&h2g=1
  dbg!(cal.day_of_week(&dt));

  let date_iso = cal.date_to_iso(&dt);

  dbg!(date_iso.year().number);
}
@sffc sffc added T-bug Type: Bad behavior, security, privacy C-calendar Component: Calendars labels May 13, 2024
@sffc
Copy link
Member

sffc commented May 13, 2024

In Hebrew, day_of_week just calls self.date_to_iso(date).day_of_week()

The conversion to ISO returns -1-8-28, which agrees with the web site you linked. That date also returns Sunday.

I'm writing a continuity test for weekdays in ISO and am finding problems. I'll put up a PR soon.

@sffc sffc self-assigned this May 13, 2024
@sffc sffc added the U-ecma402 User: ECMA-402 compatibility label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-calendar Component: Calendars T-bug Type: Bad behavior, security, privacy U-ecma402 User: ECMA-402 compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants