From 0a0fc03e8c487cda92f00fdd712aea89a9238127 Mon Sep 17 00:00:00 2001 From: Jake Thompson Date: Tue, 16 Jun 2020 01:46:20 +0000 Subject: [PATCH] Update parsing to support more formats, this includes the JS standard format that is not compatible with the `%+` time format --- src/scalars/datetime.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/scalars/datetime.rs b/src/scalars/datetime.rs index 2067d3c4..8c02bd8c 100644 --- a/src/scalars/datetime.rs +++ b/src/scalars/datetime.rs @@ -1,6 +1,6 @@ use crate::{InputValueError, InputValueResult, ScalarType, Value}; use async_graphql_derive::Scalar; -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, Utc}; /// Implement the DateTime scalar /// @@ -8,8 +8,10 @@ use chrono::{DateTime, TimeZone, Utc}; #[Scalar(internal, name = "DateTimeUtc")] impl ScalarType for DateTime { fn parse(value: Value) -> InputValueResult { - match value { - Value::String(s) => Ok(Utc.datetime_from_str(&s, "%+")?), + match &value { + Value::String(s) => s + .parse::>() + .map_err(|_| InputValueError::ExpectedType(value)), _ => Err(InputValueError::ExpectedType(value)), } }