-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add Ord and PartialOrd to icu_calendar types #3468
Conversation
@@ -92,7 +92,7 @@ pub enum AnyCalendar { | |||
} | |||
|
|||
/// The inner date type for [`AnyCalendar`] | |||
#[derive(Clone, PartialEq, Eq, Debug)] | |||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] |
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.
I guess this does Self::Gregorian(x)
< Self::Buddhist(y)
? This will make Date<AnyCalendar>
ordered non-chronologically.
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.
Hmm, yeah I guess it will put all Gregorian before all Buddhist. I can leave this out for now. I'll make a follow-up.
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.
It should be fairly straightforward to implement this manually, as all calendars can convert to ISO.
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.
I'll include this in my follow-up
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.
So this is not as straightforward as it initially seems, because the calendars have different ranges. We can't convert them to fixed_date
(number of days since 0000-1-1) because fixed_date
is an i32, but the calendar objects support dates outside that range; a calendar with a year field of i32::MAX
can't necessarily be converted to another one. (@sotam1069 is working on finding these edge cases and making sure they are at least covered in unit tests)
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.
Do we need Ord
?
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.
@@ -7,7 +7,7 @@ use core::convert::TryInto; | |||
use core::marker::PhantomData; | |||
use tinystr::tinystr; | |||
|
|||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] | |||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] |
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.
I would ask you not to make this require C: PartialOrd + Ord
, but I guess that ship has sailed with Hash, Eq, PartialEq
.
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.
Agree on both counts.
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.
LGTM
Needed for #2703