use crate::{GQLScalar, InputValueError, InputValueResult, ScalarType, Value}; use chrono::{DateTime, FixedOffset, Local, Utc}; /// Implement the DateTime scalar /// /// The input/output is a string in RFC3339 format. #[GQLScalar(internal, name = "DateTime")] impl ScalarType for DateTime { fn parse(value: Value) -> InputValueResult { match &value { Value::String(s) => Ok(s.parse::>()?), _ => Err(InputValueError::ExpectedType(value)), } } fn to_value(&self) -> Value { Value::String(self.to_rfc3339()) } } /// Implement the DateTime scalar /// /// The input/output is a string in RFC3339 format. #[GQLScalar(internal, name = "DateTime")] impl ScalarType for DateTime { fn parse(value: Value) -> InputValueResult { match &value { Value::String(s) => Ok(s.parse::>()?), _ => Err(InputValueError::ExpectedType(value)), } } fn to_value(&self) -> Value { Value::String(self.to_rfc3339()) } } /// Implement the DateTime scalar /// /// The input/output is a string in RFC3339 format. #[GQLScalar(internal, name = "DateTime")] impl ScalarType for DateTime { fn parse(value: Value) -> InputValueResult { match &value { Value::String(s) => Ok(s.parse::>()?), _ => Err(InputValueError::ExpectedType(value)), } } fn to_value(&self) -> Value { Value::String(self.to_rfc3339()) } }