diff --git a/src/datetime/tests.rs b/src/datetime/tests.rs index 407f17e8af..361b034d68 100644 --- a/src/datetime/tests.rs +++ b/src/datetime/tests.rs @@ -805,6 +805,8 @@ fn test_parse_datetime_utc() { "2001-02-03T04:05:06+0000", "2001-02-03T04:05:06-00:00", "2001-02-03T04:05:06-01:00", + "2012-12-12 12:12:12Z", + "2012-12-12t12:12:12Z", "2012-12-12T12:12:12Z", "2012 -12-12T12:12:12Z", "2012 -12-12T12:12:12Z", @@ -871,7 +873,6 @@ fn test_parse_datetime_utc() { "2012-12-12T12:61:12Z", // invalid minute "2012-12-12T12:12:62Z", // invalid second "2012-12-12 T12:12:12Z", // space after date - "2012-12-12t12:12:12Z", // wrong divider 't' "2012-12-12T12:12:12ZZ", // trailing literal 'Z' "+802701-12-12T12:12:12Z", // invalid year (out of bounds) "+ 2012-12-12T12:12:12Z", // invalid space before year diff --git a/src/format/parse.rs b/src/format/parse.rs index 210a554c92..b3099672aa 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -567,10 +567,14 @@ fn parse_rfc3339_relaxed<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult Err((_s, e)) => return Err(e), Ok(_) => return Err(NOT_ENOUGH), }; - if !(s.starts_with('T') || s.starts_with(' ')) { - return Err(INVALID); - } - match parse_internal(parsed, &s[1..], TIME_ITEMS.iter()) { + + s = match s.as_bytes().first() { + Some(&b't' | &b'T' | &b' ') => &s[1..], + Some(_) => return Err(INVALID), + None => return Err(TOO_SHORT), + }; + + match parse_internal(parsed, s, TIME_ITEMS.iter()) { Err((s, e)) if e.0 == ParseErrorKind::TooLong => Ok((s, ())), Err((_s, e)) => Err(e), Ok(s) => Ok((s, ())),