Struct chrono::naive::datetime::NaiveDateTime [] [src]

pub struct NaiveDateTime {
    // some fields omitted
}

ISO 8601 combined date and time without timezone.

Methods

impl NaiveDateTime
[src]

fn new(date: NaiveDate, time: NaiveTime) -> NaiveDateTime

Makes a new NaiveDateTime from date and time components. Equivalent to date.and_time(time) and many other helper constructors on NaiveDate.

fn from_timestamp(secs: i64, nsecs: u32) -> NaiveDateTime

Makes a new NaiveDateTime from the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp") and the number of nanoseconds since the last whole non-leap second.

Panics on the out-of-range number of seconds and/or invalid nanosecond.

fn from_timestamp_opt(secs: i64, nsecs: u32) -> Option<NaiveDateTime>

Makes a new NaiveDateTime from the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp") and the number of nanoseconds since the last whole non-leap second.

Returns None on the out-of-range number of seconds and/or invalid nanosecond.

fn from_num_seconds_from_unix_epoch(secs: i64, nsecs: u32) -> NaiveDateTime

Deprecated: Same to NaiveDateTime::from_timestamp.

fn from_num_seconds_from_unix_epoch_opt(secs: i64, nsecs: u32) -> Option<NaiveDateTime>

Deprecated: Same to NaiveDateTime::from_timestamp_opt.

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

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

fn date(&self) -> NaiveDate

Retrieves a date component.

fn time(&self) -> NaiveTime

Retrieves a time component.

fn timestamp(&self) -> i64

Returns the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp"). Note that this does not account for the timezone!

fn num_seconds_from_unix_epoch(&self) -> i64

Deprecated: Same to NaiveDateTime::timestamp.

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

Adds given Duration to the current date and time.

Returns None when it will result in overflow.

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

Subtracts given Duration from the current date and time.

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 combined date and time with the specified formatting items.

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

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

Trait Implementations

impl Clone for NaiveDateTime
[src]

fn clone(&self) -> NaiveDateTime

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 Copy for NaiveDateTime
[src]

impl Ord for NaiveDateTime
[src]

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

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

impl PartialOrd for NaiveDateTime
[src]

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

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

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

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

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

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

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

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

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

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

impl Eq for NaiveDateTime
[src]

impl PartialEq for NaiveDateTime
[src]

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

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

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

This method tests for !=.

impl Datelike for NaiveDateTime
[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<NaiveDateTime>

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

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

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

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

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

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

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

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

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

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

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

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

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 Timelike for NaiveDateTime
[src]

fn hour(&self) -> u32

Returns the hour number from 0 to 23.

fn minute(&self) -> u32

Returns the minute number from 0 to 59.

fn second(&self) -> u32

Returns the second number from 0 to 59.

fn nanosecond(&self) -> u32

Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second. Read more

fn with_hour(&self, hour: u32) -> Option<NaiveDateTime>

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

fn with_minute(&self, min: u32) -> Option<NaiveDateTime>

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

fn with_second(&self, sec: u32) -> Option<NaiveDateTime>

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

fn with_nanosecond(&self, nano: u32) -> Option<NaiveDateTime>

Makes a new value with nanoseconds since the whole non-leap second changed. Read more

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

Returns the hour number from 1 to 12 with a boolean flag, which is false for AM and true for PM. Read more

fn num_seconds_from_midnight(&self) -> u32

Returns the number of non-leap seconds past the last midnight.

impl Hash for NaiveDateTime
[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 Add<Duration> for NaiveDateTime
[src]

type Output = NaiveDateTime

The resulting type after applying the + operator

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

The method for the + operator

impl Sub<NaiveDateTime> for NaiveDateTime
[src]

type Output = Duration

The resulting type after applying the - operator

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

The method for the - operator

impl Sub<Duration> for NaiveDateTime
[src]

type Output = NaiveDateTime

The resulting type after applying the - operator

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

The method for the - operator

impl Debug for NaiveDateTime
[src]

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

Formats the value using the given formatter.

impl Display for NaiveDateTime
[src]

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

Formats the value using the given formatter.

impl FromStr for NaiveDateTime
[src]

type Err = ParseError

The associated error which can be returned from parsing.

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

Parses a string s to return a value of this type. Read more