Struct chrono::date::Date [] [src]

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

ISO 8601 calendar date with time zone.

Methods

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

fn from_utc(date: NaiveDate, offset: Tz::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, time: NaiveTime) -> Option<DateTime<Tz>>

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

Fails on invalid datetime.

fn and_hms(&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.

Fails on invalid hour, minute and/or second.

fn and_hms_opt(&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, 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.

Fails 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>>

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>

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.

Fails 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>>

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>

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.

Fails 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>>

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>

Makes a new Date for the next date.

Fails when self is the last representable date.

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

Makes a new Date for the next date.

Returns None when self is the last representable date.

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

Makes a new Date for the prior date.

Fails when self is the first representable date.

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

Makes a new Date for the prior date.

Returns None when self is the first representable date.

fn offset<'a>(&'a self) -> &'a Tz::Offset

Retrieves an associated offset from UTC.

fn timezone(&self) -> Tz

Retrieves an associated time zone.

fn with_timezone<Tz2: TimeZone>(&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(self, rhs: Duration) -> Option<Date<Tz>>

Adds given Duration to the current date.

Returns None when it will result in overflow.

fn checked_sub(self, rhs: Duration) -> Option<Date<Tz>>

Subtracts given Duration from the current date.

Returns None when it will result in overflow.

fn naive_utc(&self) -> NaiveDate

Returns a view to the naive UTC date.

fn naive_local(&self) -> NaiveDate

Returns a view to the naive local date.

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

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

Formats the date with the specified formatting items.

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

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

Trait Implementations

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

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

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

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

fn year(&self) -> i32

Returns the year number.

fn month(&self) -> u32

Returns the month number starting from 1.

fn month0(&self) -> u32

Returns the month number starting from 0.

fn day(&self) -> u32

Returns the day of month starting from 1.

fn day0(&self) -> u32

Returns the day of month starting from 0.

fn ordinal(&self) -> u32

Returns the day of year starting from 1.

fn ordinal0(&self) -> u32

Returns the day of year starting from 0.

fn weekday(&self) -> Weekday

Returns the day of week.

fn isoweekdate(&self) -> (i32, u32, Weekday)

Returns the ISO week date: an adjusted year, week number and day of week. The adjusted year may differ from that of the calendar date. Read more

fn with_year(&self, year: i32) -> Option<Date<Tz>>

Makes a new value with the year number changed. Read more

fn with_month(&self, month: u32) -> Option<Date<Tz>>

Makes a new value with the month number (starting from 1) changed. Read more

fn with_month0(&self, month0: u32) -> Option<Date<Tz>>

Makes a new value with the month number (starting from 0) changed. Read more

fn with_day(&self, day: u32) -> Option<Date<Tz>>

Makes a new value with the day of month (starting from 1) changed. Read more

fn with_day0(&self, day0: u32) -> Option<Date<Tz>>

Makes a new value with the day of month (starting from 0) changed. Read more

fn with_ordinal(&self, ordinal: u32) -> Option<Date<Tz>>

Makes a new value with the day of year (starting from 1) changed. Read more

fn with_ordinal0(&self, ordinal0: u32) -> Option<Date<Tz>>

Makes a new value with the day of year (starting from 0) changed. Read more

fn year_ce(&self) -> (bool, u32)

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

Returns the number of days since January 1, 1 (Day 1) in the proleptic Gregorian calendar.

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

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

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

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

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

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

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

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

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, other: &Rhs) -> bool
1.0.0

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Rhs) -> bool
1.0.0

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

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

This method returns an Ordering between self and other. Read more

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

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

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

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

type Output = Date<Tz>

The resulting type after applying the + operator

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

The method for the + operator

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

type Output = Duration

The resulting type after applying the - operator

fn sub(self, rhs: Date<Tz2>) -> Duration

The method for the - operator

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

type Output = Date<Tz>

The resulting type after applying the - operator

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

The method for the - operator

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

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

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

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.