Add support for non-ISO yearmonths and monthdays#490
Merged
Manishearth merged 11 commits intoboa-dev:mainfrom Aug 5, 2025
Merged
Add support for non-ISO yearmonths and monthdays#490Manishearth merged 11 commits intoboa-dev:mainfrom
Manishearth merged 11 commits intoboa-dev:mainfrom
Conversation
e069247 to
ce9abdc
Compare
Contributor
Author
|
I used a little search script to generate the dates here: use icu_calendar::Date;
use icu_calendar::Ref;
use icu_calendar::cal::HijriTabularEpoch;
use icu_calendar::cal::HijriTabularLeapYears;
use icu_calendar::types::MonthCode;
fn main() {
let iso = Date::try_new_iso(1972, 12, 31).unwrap();
let calendar = icu_calendar::cal::HijriSimulated::new_mecca();
let calendar = Ref(&calendar);
let iso_converted = iso.to_calendar(calendar);
println!("{:?}", iso_converted);
'outer: for i in 1..=12 {
let month = MonthCode::new_normal(i).unwrap();
let day = 30;
let mut year = iso_converted.extended_year();
if i >= iso_converted.month().month_number() {
year -= 1;
}
while (iso_converted.extended_year() - year) < 1000 {
let attempted_date = Date::try_new_from_codes(None, year, month, day, calendar);
if let Ok(date) = attempted_date {
println!("Found {:?} (ISO: {:?})", date, date.to_iso());
continue 'outer;
}
year -= 1;
}
println!("No workable year found!");
}
} |
Contributor
Author
|
I think we should try and fix Chinese after unicode-org/icu4x#6800 or unicode-org/icu4x#6762 lands. |
nekevss
approved these changes
Aug 5, 2025
Member
nekevss
left a comment
There was a problem hiding this comment.
In general, looks good to me. Have a couple doc specific misspellings / nits, but nothing blocking.
| } | ||
| } | ||
| // For simple calendars with a single leap day. | ||
| // This needs the date of 1972-12-31 represented in that calendar, the month-day of th eleap day, |
Co-authored-by: Kevin Ness <46825870+nekevss@users.noreply.github.com>
Co-authored-by: Kevin Ness <46825870+nekevss@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for non-ISO yearmonths, as well as some non-ISO monthdays.
It currently does not support this for Ethiopic or Chinese/Dangi, since it needs working extended years.
Progress on #412, fixes #450