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