From 0bc4127ebcdbd51bbcdcac93ee4fdffb7ab13f4a Mon Sep 17 00:00:00 2001 From: dowwie Date: Mon, 5 Feb 2018 08:31:47 -0500 Subject: [PATCH 1/2] drafted working support for tstzrange using chrono::DateTime --- Cargo.toml | 4 +++- src/lib.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7c27408..19e2ec8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ documentation = "https://sfackler.github.io/rust-postgres-range/doc/v0.9.0/postg time = "0.1" postgres = "0.15" postgres-protocol = "0.3" +chrono = "0.4.0" +postgres-shared = { version = "0.4.0", features = ["with-chrono"] } [dev-dependencies] -postgres = { version = "0.15", features = ["with-time"] } \ No newline at end of file +postgres = { version = "0.15", features = ["with-time"] } diff --git a/src/lib.rs b/src/lib.rs index 55ffa69..bfcdf9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,11 @@ #[macro_use(to_sql_checked)] extern crate postgres; extern crate postgres_protocol; +extern crate postgres_shared; extern crate time; +extern crate chrono; +use chrono::prelude::*; +use chrono::DateTime; use std::cmp::Ordering; use std::fmt; @@ -155,6 +159,16 @@ impl Normalizable for Timespec { } } +impl Normalizable for DateTime { + fn normalize(bound: RangeBound>) -> RangeBound> + where + S: BoundSided, + { + bound + } +} + + /// The possible sides of a bound. #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum BoundSide { From f2cba670c1ec759793bf47bf78acdc8e1e7accf3 Mon Sep 17 00:00:00 2001 From: dowwie Date: Tue, 6 Feb 2018 16:15:44 -0500 Subject: [PATCH 2/2] done --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bfcdf9b..5b28546 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,8 +7,7 @@ extern crate postgres_protocol; extern crate postgres_shared; extern crate time; extern crate chrono; -use chrono::prelude::*; -use chrono::DateTime; +use chrono::{DateTime, TimeZone}; use std::cmp::Ordering; use std::fmt; @@ -159,8 +158,9 @@ impl Normalizable for Timespec { } } -impl Normalizable for DateTime { - fn normalize(bound: RangeBound>) -> RangeBound> +impl Normalizable for DateTime + where T: TimeZone { + fn normalize(bound: RangeBound>) -> RangeBound> where S: BoundSided, {