• Home
  • Raw
  • Download

Lines Matching full:date

4 //! ISO 8601 calendar date with time zone.
22 /// ISO 8601 calendar date with time zone.
27 /// There are some guarantees on the usage of `Date<Tz>`:
30 /// the corresponding local date should exist for at least a moment.
33 /// - The `TimeZone` is free to assign *any* `Offset` to the local date,
40 /// `DateTime::date` and other associated methods should return those for the original `Date`.
41 /// For example, if `dt = tz.ymd(y,m,d).hms(h,n,s)` were valid, `dt.date() == tz.ymd(y,m,d)`.
43 /// - The date is timezone-agnostic up to one day (i.e. practically always),
44 /// so the local date and UTC date should be equal for most cases
47 pub struct Date<Tz: TimeZone> { struct
48 date: NaiveDate, field
52 /// The minimum possible `Date`. argument
53 pub const MIN_DATE: Date<Utc> = Date { date: naive::MIN_DATE, offset: Utc };
54 /// The maximum possible `Date`.
55 pub const MAX_DATE: Date<Utc> = Date { date: naive::MAX_DATE, offset: Utc };
57 impl<Tz: TimeZone> Date<Tz> { impl
58 /// Makes a new `Date` with given *UTC* date and offset.
59 /// The local date should be constructed via the `TimeZone` trait.
63 pub fn from_utc(date: NaiveDate, offset: Tz::Offset) -> Date<Tz> { in from_utc()
64 Date { date: date, offset: offset } in from_utc()
67 /// Makes a new `DateTime` from the current date and given `NaiveTime`.
68 /// The offset in the current date is preserved.
77 /// Makes a new `DateTime` from the current date, hour, minute and second.
78 /// The offset in the current date is preserved.
86 /// Makes a new `DateTime` from the current date, hour, minute and second.
87 /// The offset in the current date is preserved.
95 /// Makes a new `DateTime` from the current date, hour, minute, second and millisecond.
97 /// The offset in the current date is preserved.
105 /// Makes a new `DateTime` from the current date, hour, minute, second and millisecond.
107 /// The offset in the current date is preserved.
121 /// Makes a new `DateTime` from the current date, hour, minute, second and microsecond.
123 /// The offset in the current date is preserved.
131 /// Makes a new `DateTime` from the current date, hour, minute, second and microsecond.
133 /// The offset in the current date is preserved.
147 /// Makes a new `DateTime` from the current date, hour, minute, second and nanosecond.
149 /// The offset in the current date is preserved.
157 /// Makes a new `DateTime` from the current date, hour, minute, second and nanosecond.
159 /// The offset in the current date is preserved.
173 /// Makes a new `Date` for the next date.
175 /// Panics when `self` is the last representable date.
177 pub fn succ(&self) -> Date<Tz> { in succ()
181 /// Makes a new `Date` for the next date.
183 /// Returns `None` when `self` is the last representable date.
185 pub fn succ_opt(&self) -> Option<Date<Tz>> { in succ_opt()
186 self.date.succ_opt().map(|date| Date::from_utc(date, self.offset.clone())) in succ_opt()
189 /// Makes a new `Date` for the prior date.
191 /// Panics when `self` is the first representable date.
193 pub fn pred(&self) -> Date<Tz> { in pred()
197 /// Makes a new `Date` for the prior date.
199 /// Returns `None` when `self` is the first representable date.
201 pub fn pred_opt(&self) -> Option<Date<Tz>> { in pred_opt()
202 self.date.pred_opt().map(|date| Date::from_utc(date, self.offset.clone())) in pred_opt()
218 /// This does not change the actual `Date` (but will change the string representation).
220 pub fn with_timezone<Tz2: TimeZone>(&self, tz: &Tz2) -> Date<Tz2> { in with_timezone()
221 tz.from_utc_date(&self.date) in with_timezone()
224 /// Adds given `Duration` to the current date.
228 pub fn checked_add_signed(self, rhs: OldDuration) -> Option<Date<Tz>> { in checked_add_signed()
229 let date = try_opt!(self.date.checked_add_signed(rhs)); in checked_add_signed() localVariable
230 Some(Date { date: date, offset: self.offset }) in checked_add_signed()
233 /// Subtracts given `Duration` from the current date.
237 pub fn checked_sub_signed(self, rhs: OldDuration) -> Option<Date<Tz>> { in checked_sub_signed()
238 let date = try_opt!(self.date.checked_sub_signed(rhs)); in checked_sub_signed() localVariable
239 Some(Date { date: date, offset: self.offset }) in checked_sub_signed()
242 /// Subtracts another `Date` from the current date.
248 pub fn signed_duration_since<Tz2: TimeZone>(self, rhs: Date<Tz2>) -> OldDuration { in signed_duration_since()
249 self.date.signed_duration_since(rhs.date) in signed_duration_since()
252 /// Returns a view to the naive UTC date.
255 self.date in naive_utc()
258 /// Returns a view to the naive local date.
265 self.date in naive_local()
269 /// Maps the local date to other date with given conversion function.
270 fn map_local<Tz: TimeZone, F>(d: &Date<Tz>, mut f: F) -> Option<Date<Tz>> in map_local()
274 f(d.naive_local()).and_then(|date| d.timezone().from_local_date(&date).single()) in map_local()
277 impl<Tz: TimeZone> Date<Tz> implementation
281 /// Formats the date with the specified formatting items.
292 /// Formats the date with the specified format string.
301 /// Formats the date with the specified formatting items and locale.
322 /// Formats the date with the specified format string and locale.
336 impl<Tz: TimeZone> Datelike for Date<Tz> { implementation
375 fn with_year(&self, year: i32) -> Option<Date<Tz>> { in with_year()
376 map_local(self, |date| date.with_year(year)) in with_year()
380 fn with_month(&self, month: u32) -> Option<Date<Tz>> { in with_month()
381 map_local(self, |date| date.with_month(month)) in with_month()
385 fn with_month0(&self, month0: u32) -> Option<Date<Tz>> { in with_month0()
386 map_local(self, |date| date.with_month0(month0)) in with_month0()
390 fn with_day(&self, day: u32) -> Option<Date<Tz>> { in with_day()
391 map_local(self, |date| date.with_day(day)) in with_day()
395 fn with_day0(&self, day0: u32) -> Option<Date<Tz>> { in with_day0()
396 map_local(self, |date| date.with_day0(day0)) in with_day0()
400 fn with_ordinal(&self, ordinal: u32) -> Option<Date<Tz>> { in with_ordinal()
401 map_local(self, |date| date.with_ordinal(ordinal)) in with_ordinal()
405 fn with_ordinal0(&self, ordinal0: u32) -> Option<Date<Tz>> { in with_ordinal0()
406 map_local(self, |date| date.with_ordinal0(ordinal0)) in with_ordinal0()
411 impl<Tz: TimeZone> Copy for Date<Tz> where <Tz as TimeZone>::Offset: Copy {} implementation
412 unsafe impl<Tz: TimeZone> Send for Date<Tz> where <Tz as TimeZone>::Offset: Send {} implementation
414 impl<Tz: TimeZone, Tz2: TimeZone> PartialEq<Date<Tz2>> for Date<Tz> { implementation
415 fn eq(&self, other: &Date<Tz2>) -> bool { in eq()
416 self.date == other.date in eq()
420 impl<Tz: TimeZone> Eq for Date<Tz> {} implementation
422 impl<Tz: TimeZone> PartialOrd for Date<Tz> { implementation
423 fn partial_cmp(&self, other: &Date<Tz>) -> Option<Ordering> { in partial_cmp()
424 self.date.partial_cmp(&other.date) in partial_cmp()
428 impl<Tz: TimeZone> Ord for Date<Tz> { implementation
429 fn cmp(&self, other: &Date<Tz>) -> Ordering { in cmp()
430 self.date.cmp(&other.date) in cmp()
434 impl<Tz: TimeZone> hash::Hash for Date<Tz> { implementation
436 self.date.hash(state) in hash()
440 impl<Tz: TimeZone> Add<OldDuration> for Date<Tz> { implementation
441 type Output = Date<Tz>;
444 fn add(self, rhs: OldDuration) -> Date<Tz> { in add()
445 self.checked_add_signed(rhs).expect("`Date + Duration` overflowed") in add()
449 impl<Tz: TimeZone> Sub<OldDuration> for Date<Tz> { implementation
450 type Output = Date<Tz>;
453 fn sub(self, rhs: OldDuration) -> Date<Tz> { in sub()
454 self.checked_sub_signed(rhs).expect("`Date - Duration` overflowed") in sub()
458 impl<Tz: TimeZone> Sub<Date<Tz>> for Date<Tz> { implementation
462 fn sub(self, rhs: Date<Tz>) -> OldDuration { in sub()
467 impl<Tz: TimeZone> fmt::Debug for Date<Tz> { implementation
473 impl<Tz: TimeZone> fmt::Display for Date<Tz> implementation