Skip to content

Commit

Permalink
Merge pull request #11 from japanese-law-analysis/ord-date
Browse files Browse the repository at this point in the history
add ord trait for date
  • Loading branch information
puripuri2100 authored May 9, 2024
2 parents bb9a714 + 63f32ab commit dae2252
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions jplaw_data_types/src/law.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ impl Date {
}
}

impl PartialOrd for Date {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl Ord for Date {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let s = self.get_ad() * 10000 + self.month.unwrap_or(0) * 100 + self.day.unwrap_or(0);
let o = other.get_ad() * 10000 + other.month.unwrap_or(0) * 100 + other.day.unwrap_or(0);
s.cmp(&o)
}
}

/// 法律の立法の種類
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum RippouType {
Expand Down

0 comments on commit dae2252

Please sign in to comment.