parse_rfc3339_datetime

Function parse_rfc3339_datetime 

Source
pub fn parse_rfc3339_datetime(
    inp: &str,
) -> Result<PreciseShiftedDateTime, Error<'_>>
Expand description

Parse a RFC3339 formatted datetime string.

This follows the liberal parsing rules of RFC3339, and will accept both uppercase and lowercase letters for the T and Z separators. Also, the fractional seconds part is optional and the T separator can be replaced with a space.

ยงExample

let dt = parse_rfc3339_datetime("2023-09-17T09:08:58.763072Z").unwrap();
assert_eq!(dt.year, Year::new(2023).unwrap());
assert_eq!(dt.month, Month::new(9).unwrap());
assert_eq!(dt.day, Day::new(17).unwrap());
assert_eq!(dt.hour, Hour::new(9).unwrap());
assert_eq!(dt.minute, Minute::new(8).unwrap());
assert_eq!(dt.second, Second::new(58).unwrap());
assert_eq!(dt.nanosecond, Nanosecond::new(763072000).unwrap());