Struct chrono::naive::datetime::NaiveDateTime
[-] [+]
[src]
pub struct NaiveDateTime { // some fields omitted }
ISO 8601 combined date and time without timezone.
Methods
impl NaiveDateTime
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.
Fails 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
Same to NaiveDateTime::from_timestamp
.
fn from_num_seconds_from_unix_epoch_opt(secs: i64, nsecs: u32) -> Option<NaiveDateTime>
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
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.