Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate chrono; // 0.4.4
- use std::time::{
- Duration,
- SystemTime,
- UNIX_EPOCH,
- };
- use chrono::{
- DateTime,
- Utc,
- };
- fn format_iso8601(ts: SystemTime) -> String {
- let fmt = DateTime::<Utc>::from(ts).format("%Y-%m-%dT%H:%M:%S%.6fZ");
- format!("{}", fmt)
- }
- fn main() {
- println!("{}", format_iso8601(UNIX_EPOCH));
- println!("{}", format_iso8601(SystemTime::now()));
- println!("{}", format_iso8601(UNIX_EPOCH + Duration::new(8474622245848, 0)));
- }
Add Comment
Please, Sign In to add comment