Skip to content

Commit afa591b

Browse files
author
Stefan Puhlmann
committed
Adding Normalizable implementation for NaiveDateTime
This makes it possible represent a range of chrono::NaiveDateTime, which is what rust-postgres maps to for tsrange columns without timezone.
1 parent dbcbc52 commit afa591b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern crate chrono;
1414
extern crate postgres;
1515

1616
#[cfg(feature = "with-chrono")]
17-
use chrono::{DateTime, TimeZone};
17+
use chrono::{DateTime, NaiveDateTime, TimeZone};
1818
use std::cmp::Ordering;
1919
use std::fmt;
2020
use std::i32;
@@ -176,6 +176,16 @@ impl<T> Normalizable for DateTime<T>
176176
}
177177
}
178178

179+
#[cfg(feature = "with-chrono")]
180+
impl Normalizable for NaiveDateTime
181+
{
182+
fn normalize<S>(bound: RangeBound<S, NaiveDateTime>) -> RangeBound<S, NaiveDateTime>
183+
where
184+
S: BoundSided,
185+
{
186+
bound
187+
}
188+
}
179189

180190
/// The possible sides of a bound.
181191
#[derive(Debug, PartialEq, Eq, Clone, Copy)]

0 commit comments

Comments
 (0)