Module melib::datetime [−][src]
Expand description
Functions for dealing with date strings and UNIX Epoch timestamps.
Examples
// Get current UNIX Epoch timestamp.
let now: UnixTimestamp = now();
// Parse date from string
let date_val = "Wed, 8 Jan 2020 10:44:03 -0800";
let timestamp = rfc822_to_timestamp(date_val).unwrap();
assert_eq!(timestamp, 1578509043);
// Convert timestamp back to string
let s = timestamp_to_string(timestamp, Some("%Y-%m-%d"), true);
assert_eq!(s, "2020-01-08");