Fix case sensitivity with T, Z, and E.
This commit is contained in:
parent
7c969432ad
commit
b7493c9bef
|
@ -173,8 +173,9 @@ impl FromStr for Datetime {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Next parse the "partial-time" if available
|
// Next parse the "partial-time" if available
|
||||||
|
let next = chars.clone().next();
|
||||||
let partial_time = if full_date.is_some()
|
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();
|
chars.next();
|
||||||
true
|
true
|
||||||
|
@ -253,7 +254,7 @@ impl FromStr for Datetime {
|
||||||
// And finally, parse the offset
|
// And finally, parse the offset
|
||||||
let offset = if offset_allowed {
|
let offset = if offset_allowed {
|
||||||
let next = chars.clone().next();
|
let next = chars.clone().next();
|
||||||
if next == Some('Z') {
|
if next == Some('Z') || next == Some('z') {
|
||||||
chars.next();
|
chars.next();
|
||||||
Some(Offset::Z)
|
Some(Offset::Z)
|
||||||
} else if next.is_none() {
|
} else if next.is_none() {
|
||||||
|
|
|
@ -1169,7 +1169,10 @@ impl<'a> Deserializer<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn number_or_date(&mut self, span: Span, s: &'a str) -> Result<Value<'a>, Error> {
|
fn number_or_date(&mut self, span: Span, s: &'a str) -> Result<Value<'a>, 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)
|
self.datetime(span, s, false)
|
||||||
.map(|(Span { start, end }, d)| Value {
|
.map(|(Span { start, end }, d)| Value {
|
||||||
e: E::Datetime(d),
|
e: E::Datetime(d),
|
||||||
|
|
|
@ -14,6 +14,8 @@ fn times() {
|
||||||
fn good(s: &str) {
|
fn good(s: &str) {
|
||||||
dogood(s, s);
|
dogood(s, s);
|
||||||
dogood(&s.replace("T", " "), s);
|
dogood(&s.replace("T", " "), s);
|
||||||
|
dogood(&s.replace("T", "t"), s);
|
||||||
|
dogood(&s.replace("Z", "z"), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
good("1997-09-09T09:09:09Z");
|
good("1997-09-09T09:09:09Z");
|
||||||
|
|
|
@ -227,6 +227,7 @@ fn floats() {
|
||||||
t!("1.0e0", 1.0);
|
t!("1.0e0", 1.0);
|
||||||
t!("1.0e+0", 1.0);
|
t!("1.0e+0", 1.0);
|
||||||
t!("1.0e-0", 1.0);
|
t!("1.0e-0", 1.0);
|
||||||
|
t!("1E-0", 1.0);
|
||||||
t!("1.001e-0", 1.001);
|
t!("1.001e-0", 1.001);
|
||||||
t!("2e10", 2e10);
|
t!("2e10", 2e10);
|
||||||
t!("2e+10", 2e10);
|
t!("2e+10", 2e10);
|
||||||
|
|
Loading…
Reference in a new issue