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

Implement PartialOrd for DateTime #10

Closed
wants to merge 1 commit into from
Closed

Implement PartialOrd for DateTime #10

wants to merge 1 commit into from

Conversation

Kijewski
Copy link
Contributor

No description provided.

src/lib.rs Outdated
@@ -794,7 +794,7 @@ impl UtcDateTime {
}

/// Date time associated to a local time type, exprimed in the [proleptic gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar)
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eq cannot be derived and must be implemented manually since it is not applicable to all fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eq is more of a marker, having an empty body, but I made the implementation explicit.

@x-hgg-x
Copy link
Owner

x-hgg-x commented Feb 20, 2022

Create a new function used in tests for comparing DateTime objects since the PartialEq implementation has changed :

fn check_equal_date_time(x: &DateTime, y: &DateTime) {
    assert_eq!(x.second, y.second);
    assert_eq!(x.minute, y.minute);
    assert_eq!(x.hour, y.hour);
    assert_eq!(x.month_day, y.month_day);
    assert_eq!(x.month, y.month);
    assert_eq!(x.year, y.year);
    assert_eq!(x.week_day, y.week_day);
    assert_eq!(x.year_day, y.year_day);
    assert_eq!(x.local_time_type, y.local_time_type);
    assert_eq!(x.unix_time, y.unix_time);
}

@Kijewski
Copy link
Contributor Author

Create a new function used in tests for comparing DateTime objects since the PartialEq implementation has changed

Done.

@x-hgg-x
Copy link
Owner

x-hgg-x commented Feb 20, 2022

A better implementation is to remove the Eq implementation for Datetime and compare only the Unix times for the PartialEq and PartialOrd implementations.

@x-hgg-x
Copy link
Owner

x-hgg-x commented Feb 20, 2022

Closed in c4d7db5.

@x-hgg-x x-hgg-x closed this Feb 20, 2022
@Kijewski Kijewski deleted the pr-ord-2 branch February 20, 2022 18:03
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.

2 participants