Struct prayers::Date[][src]

pub struct Date<Tz> where
    Tz: TimeZone
{ /* fields omitted */ }

ISO 8601 calendar date with time zone.

This type should be considered ambiguous at best, due to the inherent lack of precision required for the time zone resolution. For serialization and deserialization uses, it is best to use NaiveDate instead. There are some guarantees on the usage of Date<Tz>:

  • If properly constructed via TimeZone::ymd and others without an error, the corresponding local date should exist for at least a moment. (It may still have a gap from the offset changes.)

  • The TimeZone is free to assign any Offset to the local date, as long as that offset did occur in given day. For example, if 2015-03-08T01:59-08:00 is followed by 2015-03-08T03:00-07:00, it may produce either 2015-03-08-08:00 or 2015-03-08-07:00 but not 2015-03-08+00:00 and others.

  • Once constructed as a full DateTime, DateTime::date and other associated methods should return those for the original Date. For example, if dt = tz.ymd(y,m,d).hms(h,n,s) were valid, dt.date() == tz.ymd(y,m,d).

  • The date is timezone-agnostic up to one day (i.e. practically always), so the local date and UTC date should be equal for most cases even though the raw calculation between NaiveDate and Duration may not.

Implementations

impl<Tz> Date<Tz> where
    Tz: TimeZone
[src]

pub fn from_utc(date: NaiveDate, offset: <Tz as TimeZone>::Offset) -> Date<Tz>[src]

Makes a new Date with given UTC date and offset. The local date should be constructed via the TimeZone trait.

pub fn and_time(&self, time: NaiveTime) -> Option<DateTime<Tz>>[src]

Makes a new DateTime from the current date and given NaiveTime. The offset in the current date is preserved.

Panics on invalid datetime.

pub fn and_hms(&self, hour: u32, min: u32, sec: u32) -> DateTime<Tz>[src]

Makes a new DateTime from the current date, hour, minute and second. The offset in the current date is preserved.

Panics on invalid hour, minute and/or second.

pub fn and_hms_opt(&self, hour: u32, min: u32, sec: u32) -> Option<DateTime<Tz>>[src]

Makes a new DateTime from the current date, hour, minute and second. The offset in the current date is preserved.

Returns None on invalid hour, minute and/or second.

pub fn and_hms_milli(
    &self,
    hour: u32,
    min: u32,
    sec: u32,
    milli: u32
) -> DateTime<Tz>
[src]

Makes a new DateTime from the current date, hour, minute, second and millisecond. The millisecond part can exceed 1,000 in order to represent the leap second. The offset in the current date is preserved.

Panics on invalid hour, minute, second and/or millisecond.

pub fn and_hms_milli_opt(
    &self,
    hour: u32,
    min: u32,
    sec: u32,
    milli: u32
) -> Option<DateTime<Tz>>
[src]

Makes a new DateTime from the current date, hour, minute, second and millisecond. The millisecond part can exceed 1,000 in order to represent the leap second. The offset in the current date is preserved.

Returns None on invalid hour, minute, second and/or millisecond.

pub fn and_hms_micro(
    &self,
    hour: u32,
    min: u32,
    sec: u32,
    micro: u32
) -> DateTime<Tz>
[src]

Makes a new DateTime from the current date, hour, minute, second and microsecond. The microsecond part can exceed 1,000,000 in order to represent the leap second. The offset in the current date is preserved.

Panics on invalid hour, minute, second and/or microsecond.

pub fn and_hms_micro_opt(
    &self,
    hour: u32,
    min: u32,
    sec: u32,
    micro: u32
) -> Option<DateTime<Tz>>
[src]

Makes a new DateTime from the current date, hour, minute, second and microsecond. The microsecond part can exceed 1,000,000 in order to represent the leap second. The offset in the current date is preserved.

Returns None on invalid hour, minute, second and/or microsecond.

pub fn and_hms_nano(
    &self,
    hour: u32,
    min: u32,
    sec: u32,
    nano: u32
) -> DateTime<Tz>
[src]

Makes a new DateTime from the current date, hour, minute, second and nanosecond. The nanosecond part can exceed 1,000,000,000 in order to represent the leap second. The offset in the current date is preserved.

Panics on invalid hour, minute, second and/or nanosecond.

pub fn and_hms_nano_opt(
    &self,
    hour: u32,
    min: u32,
    sec: u32,
    nano: u32
) -> Option<DateTime<Tz>>
[src]

Makes a new DateTime from the current date, hour, minute, second and nanosecond. The nanosecond part can exceed 1,000,000,000 in order to represent the leap second. The offset in the current date is preserved.

Returns None on invalid hour, minute, second and/or nanosecond.

pub fn succ(&self) -> Date<Tz>[src]

Makes a new Date for the next date.

Panics when self is the last representable date.

pub fn succ_opt(&self) -> Option<Date<Tz>>[src]

Makes a new Date for the next date.

Returns None when self is the last representable date.

pub fn pred(&self) -> Date<Tz>[src]

Makes a new Date for the prior date.

Panics when self is the first representable date.

pub fn pred_opt(&self) -> Option<Date<Tz>>[src]

Makes a new Date for the prior date.

Returns None when self is the first representable date.

pub fn offset(&self) -> &<Tz as TimeZone>::Offset[src]

Retrieves an associated offset from UTC.

pub fn timezone(&self) -> Tz[src]

Retrieves an associated time zone.

pub fn with_timezone<Tz2>(&self, tz: &Tz2) -> Date<Tz2> where
    Tz2: TimeZone
[src]

Changes the associated time zone. This does not change the actual Date (but will change the string representation).

pub fn checked_add_signed(self, rhs: Duration) -> Option<Date<Tz>>[src]

Adds given Duration to the current date.

Returns None when it will result in overflow.

pub fn checked_sub_signed(self, rhs: Duration) -> Option<Date<Tz>>[src]

Subtracts given Duration from the current date.

Returns None when it will result in overflow.

pub fn signed_duration_since<Tz2>(self, rhs: Date<Tz2>) -> Duration where
    Tz2: TimeZone
[src]

Subtracts another Date from the current date. Returns a Duration of integral numbers.

This does not overflow or underflow at all, as all possible output fits in the range of Duration.

pub fn naive_utc(&self) -> NaiveDate[src]

Returns a view to the naive UTC date.

pub fn naive_local(&self) -> NaiveDate[src]

Returns a view to the naive local date.

This is technically the same as naive_utc because the offset is restricted to never exceed one day, but provided for the consistency.

impl<Tz> Date<Tz> where
    Tz: TimeZone,
    <Tz as TimeZone>::Offset: Display
[src]

pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I> where
    I: Iterator<Item = B> + Clone,
    B: Borrow<Item<'a>>, 
[src]

Formats the date with the specified formatting items.

pub fn format(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>[src]

Formats the date with the specified format string. See the format::strftime module on the supported escape sequences.

Trait Implementations

impl<Tz> Add<Duration> for Date<Tz> where
    Tz: TimeZone
[src]

type Output = Date<Tz>

The resulting type after applying the + operator.

impl<Tz> Clone for Date<Tz> where
    Tz: Clone + TimeZone,
    <Tz as TimeZone>::Offset: Clone
[src]

impl<Tz> Copy for Date<Tz> where
    Tz: TimeZone,
    <Tz as TimeZone>::Offset: Copy
[src]

impl<Tz> Datelike for Date<Tz> where
    Tz: TimeZone
[src]

impl<Tz> Debug for Date<Tz> where
    Tz: TimeZone
[src]

impl<Tz> Display for Date<Tz> where
    Tz: TimeZone,
    <Tz as TimeZone>::Offset: Display
[src]

impl<Tz> Eq for Date<Tz> where
    Tz: TimeZone
[src]

impl<Tz> Hash for Date<Tz> where
    Tz: TimeZone
[src]

impl<Tz> Ord for Date<Tz> where
    Tz: TimeZone
[src]

impl<Tz, Tz2> PartialEq<Date<Tz2>> for Date<Tz> where
    Tz: TimeZone,
    Tz2: TimeZone
[src]

impl<Tz> PartialOrd<Date<Tz>> for Date<Tz> where
    Tz: TimeZone
[src]

impl<Tz> Send for Date<Tz> where
    Tz: TimeZone,
    <Tz as TimeZone>::Offset: Send
[src]

impl<Tz> Sub<Date<Tz>> for Date<Tz> where
    Tz: TimeZone
[src]

type Output = Duration

The resulting type after applying the - operator.

impl<Tz> Sub<Duration> for Date<Tz> where
    Tz: TimeZone
[src]

type Output = Date<Tz>

The resulting type after applying the - operator.

Auto Trait Implementations

impl<Tz> RefUnwindSafe for Date<Tz> where
    <Tz as TimeZone>::Offset: RefUnwindSafe

impl<Tz> Sync for Date<Tz> where
    <Tz as TimeZone>::Offset: Sync

impl<Tz> Unpin for Date<Tz> where
    <Tz as TimeZone>::Offset: Unpin

impl<Tz> UnwindSafe for Date<Tz> where
    <Tz as TimeZone>::Offset: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.