Merge pull request #14 from klutzy/upstream
Update for upstream changes
This commit is contained in:
commit
b4c0cd3dd1
10
src/date.rs
10
src/date.rs
|
@ -239,15 +239,11 @@ impl<Off:Offset> Datelike for Date<Off> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Off:Offset> PartialEq for Date<Off> {
|
||||
fn eq(&self, other: &Date<Off>) -> bool { self.date == other.date }
|
||||
impl<Off:Offset, Off2:Offset> PartialEq<Date<Off2>> for Date<Off> {
|
||||
fn eq(&self, other: &Date<Off2>) -> bool { self.date == other.date }
|
||||
}
|
||||
|
||||
impl<Off:Offset> Eq 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, Off2:Offset> Eq<Date<Off2>> for Date<Off> {
|
||||
}
|
||||
|
||||
impl<Off:Offset> PartialOrd for Date<Off> {
|
||||
|
|
|
@ -161,17 +161,13 @@ impl<Off:Offset> Timelike for DateTime<Off> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Off:Offset> PartialEq for DateTime<Off> {
|
||||
fn eq(&self, other: &DateTime<Off>) -> bool { self.datetime == other.datetime }
|
||||
impl<Off:Offset, Off2:Offset> PartialEq<DateTime<Off2>> for DateTime<Off> {
|
||||
fn eq(&self, other: &DateTime<Off2>) -> bool { self.datetime == other.datetime }
|
||||
}
|
||||
|
||||
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> {
|
||||
fn partial_cmp(&self, other: &DateTime<Off>) -> Option<Ordering> {
|
||||
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),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -89,17 +89,13 @@ impl<Off:Offset> Timelike for Time<Off> {
|
|||
fn num_seconds_from_midnight(&self) -> u32 { self.local().num_seconds_from_midnight() }
|
||||
}
|
||||
|
||||
impl<Off:Offset> PartialEq for Time<Off> {
|
||||
fn eq(&self, other: &Time<Off>) -> bool { self.time == other.time }
|
||||
impl<Off:Offset, Off2:Offset> PartialEq<Time<Off2>> for Time<Off> {
|
||||
fn eq(&self, other: &Time<Off2>) -> bool { self.time == other.time }
|
||||
}
|
||||
|
||||
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> {
|
||||
fn partial_cmp(&self, other: &Time<Off>) -> Option<Ordering> {
|
||||
self.time.partial_cmp(&other.time)
|
||||
|
|
Loading…
Reference in New Issue