Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

DateTime

ISO 8601 combined date and time without timezone.

Example

NaiveDateTime is commonly created from NaiveDate.

use chrono::{NaiveDate, NaiveDateTime};

let dt: NaiveDateTime =
    NaiveDate::from_ymd_opt(2016, 7, 8).unwrap().and_hms_opt(9, 10, 11).unwrap();
 let _ = dt;

You can use typical date-like and time-like methods, provided that relevant traits are in the scope.

 use chrono::{NaiveDate, NaiveDateTime};
 let dt: NaiveDateTime = NaiveDate::from_ymd_opt(2016, 7, 8).unwrap().and_hms_opt(9, 10,
11).unwrap();
use chrono::{Datelike, Timelike, Weekday};

assert_eq!(dt.weekday(), Weekday::Fri);
assert_eq!(dt.num_seconds_from_midnight(), 33011);

Fully qualified path: chrono::datetime::DateTime

#[derive(Copy, PartialEq, Drop, Serde, starknet::Store)]
pub struct DateTime {
    pub date: Date,
    pub time: Time,
}

Members

date

Fully qualified path: chrono::datetime::DateTime::date

pub date: Date

time

Fully qualified path: chrono::datetime::DateTime::time

pub time: Time