Merge pull request #14 from klutzy/upstream

Update for upstream changes
This commit is contained in:
Kang Seonghoon 2014-12-13 20:38:38 +09:00
commit b4c0cd3dd1
8 changed files with 19 additions and 33 deletions

View File

@ -239,15 +239,11 @@ impl<Off:Offset> Datelike for Date<Off> {
} }
} }
impl<Off:Offset> PartialEq for Date<Off> { impl<Off:Offset, Off2:Offset> PartialEq<Date<Off2>> for Date<Off> {
fn eq(&self, other: &Date<Off>) -> bool { self.date == other.date } fn eq(&self, other: &Date<Off2>) -> bool { self.date == other.date }
} }
impl<Off:Offset> Eq for Date<Off> { impl<Off:Offset, Off2:Offset> Eq<Date<Off2>> for Date<Off> {
}
impl<Off:Offset, Off2:Offset> Equiv<Date<Off2>> for Date<Off> {
fn equiv(&self, other: &Date<Off2>) -> bool { self.date == other.date }
} }
impl<Off:Offset> PartialOrd for Date<Off> { impl<Off:Offset> PartialOrd for Date<Off> {

View File

@ -161,17 +161,13 @@ impl<Off:Offset> Timelike for DateTime<Off> {
} }
} }
impl<Off:Offset> PartialEq for DateTime<Off> { impl<Off:Offset, Off2:Offset> PartialEq<DateTime<Off2>> for DateTime<Off> {
fn eq(&self, other: &DateTime<Off>) -> bool { self.datetime == other.datetime } fn eq(&self, other: &DateTime<Off2>) -> bool { self.datetime == other.datetime }
} }
impl<Off:Offset> Eq for DateTime<Off> { impl<Off:Offset> Eq for DateTime<Off> {
} }
impl<Off:Offset, Off2:Offset> Equiv<DateTime<Off2>> for DateTime<Off> {
fn equiv(&self, other: &DateTime<Off2>) -> bool { self.datetime == other.datetime }
}
impl<Off:Offset> PartialOrd for DateTime<Off> { impl<Off:Offset> PartialOrd for DateTime<Off> {
fn partial_cmp(&self, other: &DateTime<Off>) -> Option<Ordering> { fn partial_cmp(&self, other: &DateTime<Off>) -> Option<Ordering> {
self.datetime.partial_cmp(&other.datetime) self.datetime.partial_cmp(&other.datetime)
@ -229,7 +225,7 @@ mod tests {
"2014-05-06T07:08:09Z".to_string()); "2014-05-06T07:08:09Z".to_string());
assert_eq!(EDT.ymd(2014, 5, 6).and_hms(7, 8, 9).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()); "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), 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)); 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), assert_eq!(UTC.ymd(2014, 5, 6).and_hms(7, 8, 9) - EDT.ymd(2014, 5, 6).and_hms(10, 11, 12),

View File

@ -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/")] #![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)] #![deny(missing_docs)]
extern crate "time" as stdtime; extern crate "time" as stdtime;
@ -206,7 +204,7 @@ pub mod format;
/// ///
/// The order of the days of week depends on the context. /// 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. /// 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 { pub enum Weekday {
/// Monday. /// Monday.
Mon = 0, Mon = 0,

View File

@ -24,7 +24,7 @@ const MIN_YEAR: i32 = internals::MIN_YEAR as i32;
/// ISO 8601 calendar date without timezone. /// ISO 8601 calendar date without timezone.
/// Allows for every proleptic Gregorian date from Jan 1, 262145 BCE to Dec 31, 262143 CE. /// 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. /// 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 { pub struct NaiveDate {
ymdf: DateImpl, // (year << 13) | of ymdf: DateImpl, // (year << 13) | of
} }
@ -799,7 +799,7 @@ mod internals {
/// where `a` is `1` for the common year (simplifies the `Of` validation) /// 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 /// 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). /// (simplifies the day of week calculation from the 1-based ordinal).
#[deriving(PartialEq, Eq)] #[deriving(PartialEq, Eq, Copy)]
pub struct YearFlags(pub u8); pub struct YearFlags(pub u8);
pub const A: YearFlags = YearFlags(0o15); pub const AG: YearFlags = YearFlags(0o05); 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), /// 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. /// which is an index to the `OL_TO_MDL` lookup table.
#[deriving(PartialEq, PartialOrd)] #[deriving(PartialEq, PartialOrd, Copy)]
pub struct Of(pub u32); pub struct Of(pub u32);
impl Of { impl Of {
@ -1140,7 +1140,7 @@ mod internals {
/// The whole bits except for the least 3 bits are referred as `Mdl` /// The whole bits except for the least 3 bits are referred as `Mdl`
/// (month, day of month and leap flag), /// (month, day of month and leap flag),
/// which is an index to the `MDL_TO_OL` lookup table. /// which is an index to the `MDL_TO_OL` lookup table.
#[deriving(PartialEq, PartialOrd)] #[deriving(PartialEq, PartialOrd, Copy)]
pub struct Mdf(pub u32); pub struct Mdf(pub u32);
impl Mdf { impl Mdf {

View File

@ -17,7 +17,7 @@ use naive::date::NaiveDate;
use format::DelayedFormat; use format::DelayedFormat;
/// ISO 8601 combined date and time without timezone. /// 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 { pub struct NaiveDateTime {
date: NaiveDate, date: NaiveDate,
time: NaiveTime, time: NaiveTime,

View File

@ -17,7 +17,7 @@ use format::DelayedFormat;
/// ISO 8601 time without timezone. /// ISO 8601 time without timezone.
/// Allows for the nanosecond precision and optional leap second representation. /// 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 { pub struct NaiveTime {
secs: u32, secs: u32,
frac: u32, frac: u32,

View File

@ -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. /// 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; pub struct UTC;
impl 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. /// 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 { pub struct FixedOffset {
local_minus_utc: i32, local_minus_utc: i32,
} }
@ -451,7 +451,7 @@ impl fmt::Show for FixedOffset {
} }
/// The local timescale. This is implemented via the standard `time` crate. /// The local timescale. This is implemented via the standard `time` crate.
#[deriving(Clone)] #[deriving(Copy, Clone)]
pub struct Local { pub struct Local {
cached: FixedOffset, cached: FixedOffset,
} }

View File

@ -89,17 +89,13 @@ impl<Off:Offset> Timelike for Time<Off> {
fn num_seconds_from_midnight(&self) -> u32 { self.local().num_seconds_from_midnight() } fn num_seconds_from_midnight(&self) -> u32 { self.local().num_seconds_from_midnight() }
} }
impl<Off:Offset> PartialEq for Time<Off> { impl<Off:Offset, Off2:Offset> PartialEq<Time<Off2>> for Time<Off> {
fn eq(&self, other: &Time<Off>) -> bool { self.time == other.time } fn eq(&self, other: &Time<Off2>) -> bool { self.time == other.time }
} }
impl<Off:Offset> Eq for Time<Off> { impl<Off:Offset> Eq for Time<Off> {
} }
impl<Off:Offset, Off2:Offset> Equiv<Time<Off2>> for Time<Off> {
fn equiv(&self, other: &Time<Off2>) -> bool { self.time == other.time }
}
impl<Off:Offset> PartialOrd for Time<Off> { impl<Off:Offset> PartialOrd for Time<Off> {
fn partial_cmp(&self, other: &Time<Off>) -> Option<Ordering> { fn partial_cmp(&self, other: &Time<Off>) -> Option<Ordering> {
self.time.partial_cmp(&other.time) self.time.partial_cmp(&other.time)