From 37d85ffd3b52b4b0e7e1d8f320e902e36e813434 Mon Sep 17 00:00:00 2001 From: klutzy Date: Sat, 13 Dec 2014 20:29:06 +0900 Subject: [PATCH] Update for upstream changes --- src/date.rs | 10 +++------- src/datetime.rs | 10 +++------- src/lib.rs | 6 ++---- src/naive/date.rs | 8 ++++---- src/naive/datetime.rs | 2 +- src/naive/time.rs | 2 +- src/offset.rs | 6 +++--- src/time.rs | 8 ++------ 8 files changed, 19 insertions(+), 33 deletions(-) diff --git a/src/date.rs b/src/date.rs index 358aaaa..c1561c7 100644 --- a/src/date.rs +++ b/src/date.rs @@ -239,15 +239,11 @@ impl Datelike for Date { } } -impl PartialEq for Date { - fn eq(&self, other: &Date) -> bool { self.date == other.date } +impl PartialEq> for Date { + fn eq(&self, other: &Date) -> bool { self.date == other.date } } -impl Eq for Date { -} - -impl Equiv> for Date { - fn equiv(&self, other: &Date) -> bool { self.date == other.date } +impl Eq> for Date { } impl PartialOrd for Date { diff --git a/src/datetime.rs b/src/datetime.rs index c495f79..24e9b7b 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -161,17 +161,13 @@ impl Timelike for DateTime { } } -impl PartialEq for DateTime { - fn eq(&self, other: &DateTime) -> bool { self.datetime == other.datetime } +impl PartialEq> for DateTime { + fn eq(&self, other: &DateTime) -> bool { self.datetime == other.datetime } } impl Eq for DateTime { } -impl Equiv> for DateTime { - fn equiv(&self, other: &DateTime) -> bool { self.datetime == other.datetime } -} - impl PartialOrd for DateTime { fn partial_cmp(&self, other: &DateTime) -> Option { self.datetime.partial_cmp(&other.datetime) @@ -229,7 +225,7 @@ mod tests { "2014-05-06T07:08:09Z".to_string()); assert_eq!(EDT.ymd(2014, 5, 6).and_hms(7, 8, 9).to_string(), "2014-05-06T07:08:09+04:00".to_string()); - assert!(UTC.ymd(2014, 5, 6).and_hms(7, 8, 9).equiv(&EDT.ymd(2014, 5, 6).and_hms(11, 8, 9))); + assert_eq!(UTC.ymd(2014, 5, 6).and_hms(7, 8, 9), EDT.ymd(2014, 5, 6).and_hms(11, 8, 9)); assert_eq!(UTC.ymd(2014, 5, 6).and_hms(7, 8, 9) + Duration::seconds(3600 + 60 + 1), UTC.ymd(2014, 5, 6).and_hms(8, 9, 10)); assert_eq!(UTC.ymd(2014, 5, 6).and_hms(7, 8, 9) - EDT.ymd(2014, 5, 6).and_hms(10, 11, 12), diff --git a/src/lib.rs b/src/lib.rs index 561719b..7ed9f40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,11 +160,9 @@ They are mostly useful for building blocks for higher-level types. */ -#![comment = "Date and time library for Rust"] -#![license = "MIT"] #![doc(html_root_url = "https://lifthrasiir.github.io/rust-chrono/")] -#![feature(macro_rules, associated_types)] +#![feature(macro_rules, associated_types, default_type_params)] #![deny(missing_docs)] extern crate "time" as stdtime; @@ -206,7 +204,7 @@ pub mod format; /// /// The order of the days of week depends on the context. /// One should prefer `*_from_monday` or `*_from_sunday` methods to get the correct result. -#[deriving(PartialEq, Eq, Clone, FromPrimitive, Show)] +#[deriving(PartialEq, Eq, Copy, Clone, FromPrimitive, Show)] pub enum Weekday { /// Monday. Mon = 0, diff --git a/src/naive/date.rs b/src/naive/date.rs index 7007e27..7482a4a 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -24,7 +24,7 @@ const MIN_YEAR: i32 = internals::MIN_YEAR as i32; /// ISO 8601 calendar date without timezone. /// Allows for every proleptic Gregorian date from Jan 1, 262145 BCE to Dec 31, 262143 CE. /// Also supports the conversion from ISO 8601 ordinal and week date. -#[deriving(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] +#[deriving(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash)] pub struct NaiveDate { ymdf: DateImpl, // (year << 13) | of } @@ -799,7 +799,7 @@ mod internals { /// where `a` is `1` for the common year (simplifies the `Of` validation) /// and `bbb` is a non-zero `Weekday` (mapping `Mon` to 7) of the last day in the past year /// (simplifies the day of week calculation from the 1-based ordinal). - #[deriving(PartialEq, Eq)] + #[deriving(PartialEq, Eq, Copy)] pub struct YearFlags(pub u8); pub const A: YearFlags = YearFlags(0o15); pub const AG: YearFlags = YearFlags(0o05); @@ -1039,7 +1039,7 @@ mod internals { /// /// The whole bits except for the least 3 bits are referred as `Ol` (ordinal and leap flag), /// which is an index to the `OL_TO_MDL` lookup table. - #[deriving(PartialEq, PartialOrd)] + #[deriving(PartialEq, PartialOrd, Copy)] pub struct Of(pub u32); impl Of { @@ -1140,7 +1140,7 @@ mod internals { /// The whole bits except for the least 3 bits are referred as `Mdl` /// (month, day of month and leap flag), /// which is an index to the `MDL_TO_OL` lookup table. - #[deriving(PartialEq, PartialOrd)] + #[deriving(PartialEq, PartialOrd, Copy)] pub struct Mdf(pub u32); impl Mdf { diff --git a/src/naive/datetime.rs b/src/naive/datetime.rs index 92e8d7f..1e22543 100644 --- a/src/naive/datetime.rs +++ b/src/naive/datetime.rs @@ -17,7 +17,7 @@ use naive::date::NaiveDate; use format::DelayedFormat; /// ISO 8601 combined date and time without timezone. -#[deriving(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] +#[deriving(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash)] pub struct NaiveDateTime { date: NaiveDate, time: NaiveTime, diff --git a/src/naive/time.rs b/src/naive/time.rs index a0dab9a..c9f64cd 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -17,7 +17,7 @@ use format::DelayedFormat; /// ISO 8601 time without timezone. /// Allows for the nanosecond precision and optional leap second representation. -#[deriving(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] +#[deriving(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash)] pub struct NaiveTime { secs: u32, frac: u32, diff --git a/src/offset.rs b/src/offset.rs index e760cdd..407f3f6 100644 --- a/src/offset.rs +++ b/src/offset.rs @@ -321,7 +321,7 @@ pub trait Offset: Clone + fmt::Show { } /// The UTC timescale. This is the most efficient offset when you don't need the local time. -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Copy, Clone, PartialEq, Eq)] pub struct UTC; impl UTC { @@ -360,7 +360,7 @@ impl fmt::Show for UTC { } /// The fixed offset, from UTC-23:59:59 to UTC+23:59:59. -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Copy, Clone, PartialEq, Eq)] pub struct FixedOffset { local_minus_utc: i32, } @@ -451,7 +451,7 @@ impl fmt::Show for FixedOffset { } /// The local timescale. This is implemented via the standard `time` crate. -#[deriving(Clone)] +#[deriving(Copy, Clone)] pub struct Local { cached: FixedOffset, } diff --git a/src/time.rs b/src/time.rs index 994ce05..7910387 100644 --- a/src/time.rs +++ b/src/time.rs @@ -89,17 +89,13 @@ impl Timelike for Time { fn num_seconds_from_midnight(&self) -> u32 { self.local().num_seconds_from_midnight() } } -impl PartialEq for Time { - fn eq(&self, other: &Time) -> bool { self.time == other.time } +impl PartialEq> for Time { + fn eq(&self, other: &Time) -> bool { self.time == other.time } } impl Eq for Time { } -impl Equiv> for Time { - fn equiv(&self, other: &Time) -> bool { self.time == other.time } -} - impl PartialOrd for Time { fn partial_cmp(&self, other: &Time) -> Option { self.time.partial_cmp(&other.time)