From 8fce90e9cd4be4cbb12b66fedb2de72a73214f15 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 19 Feb 2019 10:59:42 -0800 Subject: Fix case sensitivity with T, Z, and E. --- src/datetime.rs | 5 +++-- src/de.rs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/datetime.rs b/src/datetime.rs index 363160b..9239593 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -173,8 +173,9 @@ impl FromStr for Datetime { }; // Next parse the "partial-time" if available + let next = chars.clone().next(); let partial_time = if full_date.is_some() - && (chars.clone().next() == Some('T') || chars.clone().next() == Some(' ')) + && (next == Some('T') || next == Some('t') || next == Some(' ')) { chars.next(); true @@ -253,7 +254,7 @@ impl FromStr for Datetime { // And finally, parse the offset let offset = if offset_allowed { let next = chars.clone().next(); - if next == Some('Z') { + if next == Some('Z') || next == Some('z') { chars.next(); Some(Offset::Z) } else if next.is_none() { diff --git a/src/de.rs b/src/de.rs index 85aef61..437ead5 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1169,7 +1169,10 @@ impl<'a> Deserializer<'a> { } fn number_or_date(&mut self, span: Span, s: &'a str) -> Result, Error> { - if s.contains('T') || (s.len() > 1 && s[1..].contains('-')) && !s.contains("e-") { + if s.contains('T') + || s.contains('t') + || (s.len() > 1 && s[1..].contains('-') && !s.contains("e-") && !s.contains("E-")) + { self.datetime(span, s, false) .map(|(Span { start, end }, d)| Value { e: E::Datetime(d), -- cgit v1.2.3