Struct Date

struct Date<Tz: TimeZone> { ... }

ISO 8601 calendar date with time zone.

You almost certainly want to be using a NaiveDate instead of this type.

This type primarily exists to aid in the construction of DateTimes that have a timezone by way of the TimeZone datelike constructors (e.g. TimeZone::ymd).

This type should be considered ambiguous at best, due to the inherent lack of precision required for the time zone resolution.

There are some guarantees on the usage of Date<Tz>:

Implementations

impl<Tz: TimeZone> Date<Tz>

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

Formats the date with the specified formatting items.

fn format<'a>(self: &Self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>

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

impl<Tz: TimeZone> Date<Tz>

fn from_utc(date: NaiveDate, offset: <Tz as >::Offset) -> Date<Tz>

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

fn and_time(self: &Self, time: NaiveTime) -> Option<DateTime<Tz>>

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

Returns None on invalid datetime.

fn and_hms(self: &Self, hour: u32, min: u32, sec: u32) -> DateTime<Tz>

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.

fn and_hms_opt(self: &Self, hour: u32, min: u32, sec: u32) -> Option<DateTime<Tz>>

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.

fn and_hms_milli(self: &Self, hour: u32, min: u32, sec: u32, milli: u32) -> DateTime<Tz>

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.

fn and_hms_milli_opt(self: &Self, hour: u32, min: u32, sec: u32, milli: u32) -> Option<DateTime<Tz>>

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.

fn and_hms_micro(self: &Self, hour: u32, min: u32, sec: u32, micro: u32) -> DateTime<Tz>

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.

fn and_hms_micro_opt(self: &Self, hour: u32, min: u32, sec: u32, micro: u32) -> Option<DateTime<Tz>>

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.

fn and_hms_nano(self: &Self, hour: u32, min: u32, sec: u32, nano: u32) -> DateTime<Tz>

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.

fn and_hms_nano_opt(self: &Self, hour: u32, min: u32, sec: u32, nano: u32) -> Option<DateTime<Tz>>

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.

fn succ(self: &Self) -> Date<Tz>

Makes a new Date for the next date.

Panics when self is the last representable date.

fn succ_opt(self: &Self) -> Option<Date<Tz>>

Makes a new Date for the next date.

Returns None when self is the last representable date.

fn pred(self: &Self) -> Date<Tz>

Makes a new Date for the prior date.

Panics when self is the first representable date.

fn pred_opt(self: &Self) -> Option<Date<Tz>>

Makes a new Date for the prior date.

Returns None when self is the first representable date.

fn offset(self: &Self) -> &<Tz as >::Offset

Retrieves an associated offset from UTC.

fn timezone(self: &Self) -> Tz

Retrieves an associated time zone.

fn with_timezone<Tz2: TimeZone>(self: &Self, tz: &Tz2) -> Date<Tz2>

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

fn checked_add_signed(self: Self, rhs: TimeDelta) -> Option<Date<Tz>>

Adds given TimeDelta to the current date.

Returns None when it will result in overflow.

fn checked_sub_signed(self: Self, rhs: TimeDelta) -> Option<Date<Tz>>

Subtracts given TimeDelta from the current date.

Returns None when it will result in overflow.

fn signed_duration_since<Tz2: TimeZone>(self: Self, rhs: Date<Tz2>) -> TimeDelta

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

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

fn naive_utc(self: &Self) -> NaiveDate

Returns a view to the naive UTC date.

fn naive_local(self: &Self) -> NaiveDate

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.

fn years_since(self: &Self, base: Self) -> Option<u32>

Returns the number of whole years from the given base until self.

impl<T> Any for Date<Tz>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Date<Tz>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Date<Tz>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Date<Tz>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Date<Tz>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Date<Tz>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Date<Tz>

fn to_string(self: &Self) -> String

impl<T, U> Into for Date<Tz>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Date<Tz>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Date<Tz>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<Tz> Freeze for Date<Tz>

impl<Tz> RefUnwindSafe for Date<Tz>

impl<Tz> Sync for Date<Tz>

impl<Tz> Unpin for Date<Tz>

impl<Tz> UnwindSafe for Date<Tz>

impl<Tz: $crate::clone::Clone + TimeZone> Clone for Date<Tz>

fn clone(self: &Self) -> Date<Tz>

impl<Tz: TimeZone> Add for Date<Tz>

fn add(self: Self, rhs: TimeDelta) -> Date<Tz>

impl<Tz: TimeZone> AddAssign for Date<Tz>

fn add_assign(self: &mut Self, rhs: TimeDelta)

impl<Tz: TimeZone> Copy for Date<Tz>

impl<Tz: TimeZone> Datelike for Date<Tz>

fn year(self: &Self) -> i32
fn month(self: &Self) -> u32
fn month0(self: &Self) -> u32
fn day(self: &Self) -> u32
fn day0(self: &Self) -> u32
fn ordinal(self: &Self) -> u32
fn ordinal0(self: &Self) -> u32
fn weekday(self: &Self) -> Weekday
fn iso_week(self: &Self) -> IsoWeek
fn with_year(self: &Self, year: i32) -> Option<Date<Tz>>
fn with_month(self: &Self, month: u32) -> Option<Date<Tz>>
fn with_month0(self: &Self, month0: u32) -> Option<Date<Tz>>
fn with_day(self: &Self, day: u32) -> Option<Date<Tz>>
fn with_day0(self: &Self, day0: u32) -> Option<Date<Tz>>
fn with_ordinal(self: &Self, ordinal: u32) -> Option<Date<Tz>>
fn with_ordinal0(self: &Self, ordinal0: u32) -> Option<Date<Tz>>

impl<Tz: TimeZone> Debug for Date<Tz>

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl<Tz: TimeZone> Display for Date<Tz>

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl<Tz: TimeZone> Eq for Date<Tz>

impl<Tz: TimeZone> Hash for Date<Tz>

fn hash<H: hash::Hasher>(self: &Self, state: &mut H)

impl<Tz: TimeZone> Ord for Date<Tz>

fn cmp(self: &Self, other: &Date<Tz>) -> Ordering

impl<Tz: TimeZone> PartialOrd for Date<Tz>

fn partial_cmp(self: &Self, other: &Date<Tz>) -> Option<Ordering>

impl<Tz: TimeZone> Send for Date<Tz>

impl<Tz: TimeZone> Sub for Date<Tz>

fn sub(self: Self, rhs: TimeDelta) -> Date<Tz>

impl<Tz: TimeZone> Sub for Date<Tz>

fn sub(self: Self, rhs: Date<Tz>) -> TimeDelta

impl<Tz: TimeZone> SubAssign for Date<Tz>

fn sub_assign(self: &mut Self, rhs: TimeDelta)

impl<Tz: TimeZone, Tz2: TimeZone> PartialEq for Date<Tz>

fn eq(self: &Self, other: &Date<Tz2>) -> bool