Struct stdcli::prelude::chrono::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::ymdand 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
TimeZoneis free to assign anyOffsetto the local date, as long as that offset did occur in given day. For example, if2015-03-08T01:59-08:00is followed by2015-03-08T03:00-07:00, it may produce either2015-03-08-08:00or2015-03-08-07:00but not2015-03-08+00:00and others.Once constructed as a full
DateTime,DateTime::dateand other associated methods should return those for the originalDate. For example, ifdt = 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
NaiveDateandDurationmay not.
Methods
impl<Tz> Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
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.
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.
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.
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.
fn and_hms_milli(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> DateTime<Tz>[src]
&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,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> Option<DateTime<Tz>>[src]
&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,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> DateTime<Tz>[src]
&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,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> Option<DateTime<Tz>>[src]
&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, 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.
fn and_hms_nano_opt(
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> Option<DateTime<Tz>>[src]
&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) -> Date<Tz>[src]
Makes a new Date for the next date.
Panics when self is the last representable date.
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.
fn pred(&self) -> Date<Tz>[src]
Makes a new Date for the prior date.
Panics when self is the first representable date.
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.
fn offset(&'a self) -> &'a <Tz as TimeZone>::Offset[src]
Retrieves an associated offset from UTC.
fn timezone(&self) -> Tz[src]
Retrieves an associated time zone.
fn with_timezone<Tz2>(&self, tz: &Tz2) -> Date<Tz2> where
Tz2: TimeZone, [src]
Tz2: TimeZone,
Changes the associated time zone.
This does not change the actual Date (but will change the string representation).
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.
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.
fn signed_duration_since<Tz2>(self, rhs: Date<Tz2>) -> Duration where
Tz2: TimeZone, [src]
Tz2: TimeZone,
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.
fn naive_utc(&self) -> NaiveDate[src]
Returns a view to the naive UTC date.
fn naive_local(&self) -> NaiveDate[src]
Returns a view to the naive local date.
This is technically same to 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]
Tz: TimeZone,
<Tz as TimeZone>::Offset: Display,
fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat<I> where
I: Iterator<Item = Item<'a>> + Clone, [src]
I: Iterator<Item = Item<'a>> + Clone,
Formats the date with the specified formatting items.
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> Ord for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
impl<Tz> Copy for Date<Tz> where
Tz: TimeZone,
<Tz as TimeZone>::Offset: Copy, [src]
Tz: TimeZone,
<Tz as TimeZone>::Offset: Copy,
impl<Tz> Hash for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
impl<Tz> Clone for Date<Tz> where
Tz: TimeZone + Clone,
<Tz as TimeZone>::Offset: Clone, [src]
Tz: TimeZone + Clone,
<Tz as TimeZone>::Offset: Clone,
fn clone(&self) -> Date<Tz>[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<Tz> Datelike for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
fn year(&self) -> i32[src]
Returns the year number in the calendar date.
fn month(&self) -> u32[src]
Returns the month number starting from 1. Read more
fn month0(&self) -> u32[src]
Returns the month number starting from 0. Read more
fn day(&self) -> u32[src]
Returns the day of month starting from 1. Read more
fn day0(&self) -> u32[src]
Returns the day of month starting from 0. Read more
fn ordinal(&self) -> u32[src]
Returns the day of year starting from 1. Read more
fn ordinal0(&self) -> u32[src]
Returns the day of year starting from 0. Read more
fn weekday(&self) -> Weekday[src]
Returns the day of week.
fn iso_week(&self) -> IsoWeek[src]
Returns the ISO week.
fn with_year(&self, year: i32) -> Option<Date<Tz>>[src]
Makes a new value with the year number changed. Read more
fn with_month(&self, month: u32) -> Option<Date<Tz>>[src]
Makes a new value with the month number (starting from 1) changed. Read more
fn with_month0(&self, month0: u32) -> Option<Date<Tz>>[src]
Makes a new value with the month number (starting from 0) changed. Read more
fn with_day(&self, day: u32) -> Option<Date<Tz>>[src]
Makes a new value with the day of month (starting from 1) changed. Read more
fn with_day0(&self, day0: u32) -> Option<Date<Tz>>[src]
Makes a new value with the day of month (starting from 0) changed. Read more
fn with_ordinal(&self, ordinal: u32) -> Option<Date<Tz>>[src]
Makes a new value with the day of year (starting from 1) changed. Read more
fn with_ordinal0(&self, ordinal0: u32) -> Option<Date<Tz>>[src]
Makes a new value with the day of year (starting from 0) changed. Read more
fn year_ce(&self) -> (bool, u32)[src]
Returns the absolute year number starting from 1 with a boolean flag, which is false when the year predates the epoch (BCE/BC) and true otherwise (CE/AD). Read more
fn num_days_from_ce(&self) -> i32[src]
Returns the number of days since January 1, 1 (Day 1) in the proleptic Gregorian calendar.
impl<Tz> Eq for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
impl<Tz> Send for Date<Tz> where
Tz: TimeZone,
<Tz as TimeZone>::Offset: Send, [src]
Tz: TimeZone,
<Tz as TimeZone>::Offset: Send,
impl<Tz, Tz2> PartialEq<Date<Tz2>> for Date<Tz> where
Tz: TimeZone,
Tz2: TimeZone, [src]
Tz: TimeZone,
Tz2: TimeZone,
impl<Tz> Add<Duration> for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
impl<Tz> Debug for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter.
impl<Tz> Display for Date<Tz> where
Tz: TimeZone,
<Tz as TimeZone>::Offset: Display, [src]
Tz: TimeZone,
<Tz as TimeZone>::Offset: Display,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter. Read more
impl<Tz> Sub<Duration> for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,
impl<Tz> PartialOrd<Date<Tz>> for Date<Tz> where
Tz: TimeZone, [src]
Tz: TimeZone,