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

Make (Utc)DateTimes sortable #4

Merged
merged 1 commit into from
Feb 20, 2022
Merged

Make (Utc)DateTimes sortable #4

merged 1 commit into from
Feb 20, 2022

Conversation

Kijewski
Copy link
Contributor

No description provided.

@x-hgg-x
Copy link
Owner

x-hgg-x commented Feb 20, 2022

DateTime cannot implement PartialOrd by comparing Unix times since it won't be consistent with its PartialEq implementation.

@x-hgg-x x-hgg-x merged commit 9f31de7 into x-hgg-x:master Feb 20, 2022
@Kijewski Kijewski deleted the pr-ord branch February 20, 2022 13:43
x-hgg-x added a commit that referenced this pull request Feb 20, 2022
@Kijewski
Copy link
Contributor Author

Do you think a custom implementation of PartialEq for DateTime would be OK if it only compares the Unix times and time zones? The other fields are derived data, aren't they? (I guess I missing some finer parts like the handling of leap seconds or such.)

@x-hgg-x
Copy link
Owner

x-hgg-x commented Feb 20, 2022

Yes, this PartialEq implementation is ok since the leap seconds are normalized and not preserved. But then we need to also compare the Unix times and time zones for the PartialOrd implementation (not just the Unix times) in order to have consistent implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants