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.