Merge pull request #535 from oeed/master
Aligned NaiveDateTime formatting with DateTime
This commit is contained in:
commit
b9d142bba0
8
src/types/external/naive_time.rs
vendored
8
src/types/external/naive_time.rs
vendored
|
@ -20,13 +20,13 @@ impl ScalarType for NaiveDate {
|
||||||
impl ScalarType for NaiveTime {
|
impl ScalarType for NaiveTime {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
match value {
|
match value {
|
||||||
Value::String(s) => Ok(NaiveTime::parse_from_str(&s, "%H:%M:%S")?),
|
Value::String(s) => Ok(NaiveTime::parse_from_str(&s, "%H:%M:%S%.f")?),
|
||||||
_ => Err(InputValueError::expected_type(value)),
|
_ => Err(InputValueError::expected_type(value)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_value(&self) -> Value {
|
fn to_value(&self) -> Value {
|
||||||
Value::String(self.format("%H:%M:%S").to_string())
|
Value::String(self.format("%H:%M:%S%.f").to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,12 @@ impl ScalarType for NaiveTime {
|
||||||
impl ScalarType for NaiveDateTime {
|
impl ScalarType for NaiveDateTime {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
match value {
|
match value {
|
||||||
Value::String(s) => Ok(NaiveDateTime::parse_from_str(&s, "%Y-%m-%d %H:%M:%S")?),
|
Value::String(s) => Ok(NaiveDateTime::parse_from_str(&s, "%Y-%m-%dT%H:%M:%S%.f")?),
|
||||||
_ => Err(InputValueError::expected_type(value)),
|
_ => Err(InputValueError::expected_type(value)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_value(&self) -> Value {
|
fn to_value(&self) -> Value {
|
||||||
Value::String(self.format("%Y-%m-%d %H:%M:%S").to_string())
|
Value::String(self.format("%Y-%m-%dT%H:%M:%S%.f").to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user