In [ ]:
:timing
:sccache 1
In [5]:
use std::time::{SystemTime, UNIX_EPOCH};
In [6]:
SystemTime::now()
Out[6]:
In [7]:
let start = SystemTime::now();
start.duration_since(UNIX_EPOCH).expect("Time went backwards")
Out[7]:
In [8]:
let start = SystemTime::now();
start.duration_since(UNIX_EPOCH).unwrap()
Out[8]:
In [10]:
let start = SystemTime::now();
start.duration_since(UNIX_EPOCH).unwrap().as_secs()
Out[10]:
In [9]:
let start = SystemTime::now();
start.duration_since(UNIX_EPOCH).unwrap().as_millis()
Out[9]:
In [15]:
let start = SystemTime::now();
start.duration_since(UNIX_EPOCH).unwrap().as_nanos()
Out[15]:
In [11]:
:dep chrono = "0.4.19"
In [12]:
use std::time::SystemTime;
use chrono::offset::Local;
use chrono::DateTime;
In [13]:
let datetime: DateTime<Local> = SystemTime::now().into();
println!("{}", datetime.format("%Y-%m-%d %H:%M:%S.%f"));
In [14]:
Local::now()
Out[14]:
The Rust Crate time¶
In [ ]:
References¶
In [ ]: