From 79644f9279694ca9a953b2c1825c8c54114b70eb Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 7 Feb 2017 20:18:26 -0800 Subject: [PATCH] Update to chrono 0.3 Closes #232 --- postgres-shared/Cargo.toml | 2 +- postgres-shared/src/types/chrono.rs | 6 +++--- postgres/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/postgres-shared/Cargo.toml b/postgres-shared/Cargo.toml index ee9be273..c6e7b183 100644 --- a/postgres-shared/Cargo.toml +++ b/postgres-shared/Cargo.toml @@ -22,7 +22,7 @@ phf = "=0.7.21" postgres-protocol = "0.2" bit-vec = { version = "0.4", optional = true } -chrono = { version = "0.2.14", optional = true } +chrono = { version = "0.3", optional = true } eui48 = { version = "0.1", optional = true } rustc-serialize = { version = "0.3", optional = true } serde_json = { version = ">= 0.6, < 0.10", optional = true } diff --git a/postgres-shared/src/types/chrono.rs b/postgres-shared/src/types/chrono.rs index 60d8d15e..1ce73956 100644 --- a/postgres-shared/src/types/chrono.rs +++ b/postgres-shared/src/types/chrono.rs @@ -29,7 +29,7 @@ impl ToSql for NaiveDateTime { w: &mut Vec, _: &SessionInfo) -> Result> { - let time = match (*self - base()).num_microseconds() { + let time = match self.signed_duration_since(base()).num_microseconds() { Some(time) => time, None => return Err("value too large to transmit".into()), }; @@ -134,7 +134,7 @@ impl ToSql for NaiveDate { w: &mut Vec, _: &SessionInfo) -> Result> { - let jd = (*self - base().date()).num_days(); + let jd = self.signed_duration_since(base().date()).num_days(); if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 { return Err("value too large to transmit".into()); } @@ -165,7 +165,7 @@ impl ToSql for NaiveTime { w: &mut Vec, _: &SessionInfo) -> Result> { - let delta = *self - NaiveTime::from_hms(0, 0, 0); + let delta = self.signed_duration_since(NaiveTime::from_hms(0, 0, 0)); let time = match delta.num_microseconds() { Some(time) => time, None => return Err("value too large to transmit".into()), diff --git a/postgres/Cargo.toml b/postgres/Cargo.toml index 2dddac12..3c682a6f 100644 --- a/postgres/Cargo.toml +++ b/postgres/Cargo.toml @@ -55,7 +55,7 @@ postgres-shared = { version = "0.1", path = "../postgres-shared" } url = "1.0" bit-vec = "0.4" -chrono = "0.2.14" +chrono = "0.3" eui48 = "0.1" rustc-serialize = "0.3" serde_json = ">= 0.6, < 0.10"