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_utc(timestamp, Some("%Y-%m-%d"), true);
assert_eq!(s, "2020-01-08");
Modules§
Functions§
- Return a UNIX epoch timestamp as string in the local timezone, using
fmt
as the format argument passed tostrptime
. - Return a UNIX epoch timestamp as string in the UTC/GMT/+00:00 timezone, using
fmt
as the format argument passed tostrptime
.