Expand description
Utilities for parsing and formatting RFC 3339 timestamps.
The Timestamp
newtype wraps chrono::DateTime<Utc>
or time::OffsetDateTime
if the time
feature is enabled.
§Formatting
let timestamp: Timestamp = GuildId::new(175928847299117063).created_at();
assert_eq!(timestamp.unix_timestamp(), 1462015105);
assert_eq!(timestamp.to_string(), "2016-04-30T11:18:25.796Z");
§Parsing RFC 3339 string
let timestamp = Timestamp::parse("2016-04-30T11:18:25Z").unwrap();
let timestamp = Timestamp::parse("2016-04-30T11:18:25+00:00").unwrap();
let timestamp = Timestamp::parse("2016-04-30T11:18:25.796Z").unwrap();
let timestamp: Timestamp = "2016-04-30T11:18:25Z".parse().unwrap();
let timestamp: Timestamp = "2016-04-30T11:18:25+00:00".parse().unwrap();
let timestamp: Timestamp = "2016-04-30T11:18:25.796Z".parse().unwrap();
assert!(Timestamp::parse("2016-04-30T11:18:25").is_err());
assert!(Timestamp::parse("2016-04-30T11:18").is_err());
Structs§
- Inner
Error - An error from the
parse
function. - Invalid
Timestamp - Parse
Error - Signifies the failure to parse the
Timestamp
from an RFC 3339 string. - Timestamp