Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::cp437::FromCp437;
use crate::write::{FileOptionExtension, FileOptions};
use path::{Component, Path, PathBuf};
use std::cmp::Ordering;
use std::ffi::OsStr;
use std::fmt;
use std::fmt::{Debug, Formatter};
Expand Down Expand Up @@ -85,7 +84,7 @@ impl From<System> for u8 {
///
/// Modern zip files store more precise timestamps; see [`crate::extra_fields::ExtendedTimestamp`]
/// for details.
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DateTime {
datepart: u16,
timepart: u16,
Expand All @@ -108,33 +107,6 @@ impl Debug for DateTime {
}
}

impl Ord for DateTime {
fn cmp(&self, other: &Self) -> Ordering {
if let ord @ (Ordering::Less | Ordering::Greater) = self.year().cmp(&other.year()) {
return ord;
}
if let ord @ (Ordering::Less | Ordering::Greater) = self.month().cmp(&other.month()) {
return ord;
}
if let ord @ (Ordering::Less | Ordering::Greater) = self.day().cmp(&other.day()) {
return ord;
}
if let ord @ (Ordering::Less | Ordering::Greater) = self.hour().cmp(&other.hour()) {
return ord;
}
if let ord @ (Ordering::Less | Ordering::Greater) = self.minute().cmp(&other.minute()) {
return ord;
}
self.second().cmp(&other.second())
}
}

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

impl DateTime {
/// Constructs a default datetime of 1980-01-01 00:00:00.
pub const DEFAULT: Self = DateTime {
Expand Down
Loading