-
Notifications
You must be signed in to change notification settings - Fork 241
Deprecate Date::new_from_iso/Date::to_iso
#7287
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
Conversation
3e7b3b1 to
0887c4b
Compare
eecd247 to
940b36f
Compare
940b36f to
ebbac20
Compare
ebbac20 to
04d6906
Compare
| let roc_from_case = Date::new_from_iso(iso_from_case, Roc); | ||
| assert_eq!(iso_from_rd, iso_from_case, | ||
| "ISO from RD not equal to ISO generated from manually-input ymd\nCase: {case:?}\nRD: {iso_from_rd:?}\nManual: {iso_from_case:?}"); | ||
| let roc_from_case = Date::try_new_roc( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test, you removed the new_from_iso and now only create from the ROC dates and the RD.
Are we still satisfactorily covering the has_cheap_iso_conversion code path?
let inner = if c1.has_cheap_iso_conversion() && c2.has_cheap_iso_conversion() {
c2.from_iso(c1.to_iso(self.inner()))
} else {
// `from_rata_die` precondition is satified by `to_rata_die`
c2.from_rata_die(c1.to_rata_die(self.inner()))
};There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are a couple of tests that exercise this code, it's shared between all AbstractGregorian calendars, so we don't necessarily need to test it on Roc
it might make sense to add a few test specifically for this code in date.rs.
ef13d7c to
e2eae91
Compare
| fn test_to_calendar() { | ||
| let date = Date::try_new_gregorian(2025, 12, 9).unwrap(); | ||
| // These conversions use the AbstractGregorian fast path | ||
| let date2 = date.to_calendar(Buddhist).to_calendar(Gregorian); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: It seems better to test this for all calendars, not just Buddhist
Manishearth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally not a fan of churning the APIs here more but I guess it's fine.
We should stop treating the ISO calendar as special. Conversions are available through
to_calendar()like for all other calendars, and there shouldn't be two ways of doing things.This also cleans up old code in
AnyCalendarthat converts through ISO, which skips the optimisations in.to_calendar().