Struct chrono::naive::date::NaiveDate [-] [+] [src]

pub struct NaiveDate {
    // some fields omitted
}

ISO 8601 calendar date without timezone. Allows for every proleptic Gregorian date from Jan 1, 262145 BCE to Dec 31, 262143 CE. Also supports the conversion from ISO 8601 ordinal and week date.

Methods

impl NaiveDate

fn from_ymd(year: i32, month: u32, day: u32) -> NaiveDate

Makes a new NaiveDate from year, month and day. This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.

Fails on the out-of-range date, invalid month and/or day.

fn from_ymd_opt(year: i32, month: u32, day: u32) -> Option<NaiveDate>

Makes a new NaiveDate from year, month and day. This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.

Returns None on the out-of-range date, invalid month and/or day.

fn from_yo(year: i32, ordinal: u32) -> NaiveDate

Makes a new NaiveDate from year and day of year (DOY or "ordinal"). This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.

Fails on the out-of-range date and/or invalid DOY.

fn from_yo_opt(year: i32, ordinal: u32) -> Option<NaiveDate>

Makes a new NaiveDate from year and day of year (DOY or "ordinal"). This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.

Returns None on the out-of-range date and/or invalid DOY.

fn from_isoywd(year: i32, week: u32, weekday: Weekday) -> NaiveDate

Makes a new NaiveDate from ISO week date (year and week number) and day of the week (DOW). This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE. The resulting NaiveDate may have a different year from the input year.

Fails on the out-of-range date and/or invalid week number.

fn from_isoywd_opt(year: i32, week: u32, weekday: Weekday) -> Option<NaiveDate>

Makes a new NaiveDate from ISO week date (year and week number) and day of the week (DOW). This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE. The resulting NaiveDate may have a different year from the input year.

Returns None on the out-of-range date and/or invalid week number.

fn from_num_days_from_ce(days: i32) -> NaiveDate

Makes a new NaiveDate from the number of days since January 1, 1 (Day 1) in the proleptic Gregorian calendar.

Fails on the out-of-range date.

fn from_num_days_from_ce_opt(days: i32) -> Option<NaiveDate>

Makes a new NaiveDate from the number of days since January 1, 1 (Day 1) in the proleptic Gregorian calendar.

Returns None on the out-of-range date.

fn parse_from_str(s: &str, fmt: &str) -> ParseResult<NaiveDate>

Parses a string with the specified format string and returns a new NaiveDate. See the format::strftime module on the supported escape sequences.

fn and_time(&self, time: NaiveTime) -> NaiveDateTime

Makes a new NaiveDateTime from the current date and given NaiveTime.

fn and_hms(&self, hour: u32, min: u32, sec: u32) -> NaiveDateTime

Makes a new NaiveDateTime from the current date, hour, minute and second.

Fails on invalid hour, minute and/or second.

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

Makes a new NaiveDateTime from the current date, hour, minute and second.

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

fn and_hms_milli(&self, hour: u32, min: u32, sec: u32, milli: u32) -> NaiveDateTime

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

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

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

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

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

fn and_hms_micro(&self, hour: u32, min: u32, sec: u32, micro: u32) -> NaiveDateTime

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

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

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

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

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

fn and_hms_nano(&self, hour: u32, min: u32, sec: u32, nano: u32) -> NaiveDateTime

Makes a new NaiveDateTime 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.

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

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

Makes a new NaiveDateTime 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.

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

fn succ(&self) -> NaiveDate

Makes a new NaiveDate for the next date.

Fails when self is the last representable date.

fn succ_opt(&self) -> Option<NaiveDate>

Makes a new NaiveDate for the next date.

Returns None when self is the last representable date.

fn pred(&self) -> NaiveDate

Makes a new NaiveDate for the prior date.

Fails when self is the first representable date.

fn pred_opt(&self) -> Option<NaiveDate>

Makes a new NaiveDate for the prior date.

Returns None when self is the first representable date.

fn checked_add(self, rhs: Duration) -> Option<NaiveDate>

Adds the days part of given Duration to the current date.

Returns None when it will result in overflow.

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

Subtracts the days part of given Duration from the current date.

Returns None when it will result in overflow.

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 Datelike for NaiveDate

fn year(&self) -> i32

fn month(&self) -> u32

fn month0(&self) -> u32

fn day(&self) -> u32

fn day0(&self) -> u32

fn ordinal(&self) -> u32

fn ordinal0(&self) -> u32

fn weekday(&self) -> Weekday

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

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

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

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

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

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

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

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

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

fn num_days_from_ce(&self) -> i32

impl Hash for NaiveDate

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

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

impl Add<Duration> for NaiveDate

type Output = NaiveDate

fn add(self, rhs: Duration) -> NaiveDate

impl Sub<NaiveDate> for NaiveDate

type Output = Duration

fn sub(self, rhs: NaiveDate) -> Duration

impl Sub<Duration> for NaiveDate

type Output = NaiveDate

fn sub(self, rhs: Duration) -> NaiveDate

impl Debug for NaiveDate

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

impl Display for NaiveDate

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

impl FromStr for NaiveDate

type Err = ParseError

fn from_str(s: &str) -> ParseResult<NaiveDate>

Derived Implementations

impl Clone for NaiveDate

fn clone(&self) -> NaiveDate

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

impl Copy for NaiveDate

impl Ord for NaiveDate

fn cmp(&self, __arg_0: &NaiveDate) -> Ordering

impl PartialOrd for NaiveDate

fn partial_cmp(&self, __arg_0: &NaiveDate) -> Option<Ordering>

fn lt(&self, __arg_0: &NaiveDate) -> bool

fn le(&self, __arg_0: &NaiveDate) -> bool

fn gt(&self, __arg_0: &NaiveDate) -> bool

fn ge(&self, __arg_0: &NaiveDate) -> bool

impl Eq for NaiveDate

fn assert_receiver_is_total_eq(&self)

impl PartialEq for NaiveDate

fn eq(&self, __arg_0: &NaiveDate) -> bool

fn ne(&self, __arg_0: &NaiveDate) -> bool