aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/datetime.rs3
-rw-r--r--src/de.rs11
-rw-r--r--test-suite/tests/datetime.rs8
3 files changed, 19 insertions, 3 deletions
diff --git a/src/datetime.rs b/src/datetime.rs
index c67e2c4..3678f58 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -176,7 +176,8 @@ impl FromStr for Datetime {
// Next parse the "partial-time" if available
let partial_time = if full_date.is_some() &&
- chars.clone().next() == Some('T') {
+ (chars.clone().next() == Some('T')
+ || chars.clone().next() == Some(' ')) {
chars.next();
true
} else {
diff --git a/src/de.rs b/src/de.rs
index 1d43cc9..c2679f5 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -1010,6 +1010,17 @@ impl<'a> Deserializer<'a> {
-> Result<(Span, &'a str), Error> {
let start = self.tokens.substr_offset(date);
+ // Check for space separated date and time.
+ if let Some((_, Token::Whitespace(s))) = self.peek()? {
+ if s == " " {
+ self.next()?;
+ // Skip past the hour.
+ if let Some((_, Token::Keylike(_))) = self.peek()? {
+ self.next()?;
+ }
+ }
+ }
+
if colon_eaten || self.eat(Token::Colon)? {
// minutes
match self.next()? {
diff --git a/test-suite/tests/datetime.rs b/test-suite/tests/datetime.rs
index 948e863..f3b77e3 100644
--- a/test-suite/tests/datetime.rs
+++ b/test-suite/tests/datetime.rs
@@ -6,10 +6,14 @@ use toml::Value;
#[test]
fn times() {
- fn good(s: &str) {
+ fn dogood(s: &str, serialized: &str) {
let to_parse = format!("foo = {}", s);
let value = Value::from_str(&to_parse).unwrap();
- assert_eq!(value["foo"].as_datetime().unwrap().to_string(), s);
+ assert_eq!(value["foo"].as_datetime().unwrap().to_string(), serialized);
+ }
+ fn good(s: &str) {
+ dogood(s, s);
+ dogood(&s.replace("T", " "), s);
}
good("1997-09-09T09:09:09Z");