Skip to content

Commit 21f39b1

Browse files
committed
Upgrade chrono and get rid of workaround
1 parent 1f251c4 commit 21f39b1

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ uuid = { version = "0.1", optional = true }
3535
unix_socket = { version = "0.3", optional = true }
3636
time = { version = "0.1.14", optional = true }
3737
serde = { version = "0.3", optional = true }
38-
chrono = { version = "0.2", optional = true }
38+
chrono = { version = "0.2.14", optional = true }
3939

4040
[dev-dependencies]
4141
url = "0.2"

src/types/chrono.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,14 @@ use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC}
77
use Result;
88
use types::{FromSql, ToSql, IsNull, Type};
99

10-
const USEC_PER_SEC: i64 = 1_000_000;
11-
const NSEC_PER_USEC: i64 = 1_000;
12-
13-
// Number of seconds from 1970-01-01 to 2000-01-01
14-
const TIME_SEC_CONVERSION: i64 = 946684800;
15-
1610
fn base() -> NaiveDateTime {
1711
NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0)
1812
}
1913

2014
impl FromSql for NaiveDateTime {
2115
fn from_sql<R: Read>(_: &Type, raw: &mut R) -> Result<NaiveDateTime> {
22-
// FIXME should be this, blocked on lifthrasiir/rust-chrono#37
23-
/*
2416
let t = try!(raw.read_i64::<BigEndian>());
2517
Ok(base() + Duration::microseconds(t))
26-
*/
27-
28-
let t = try!(raw.read_i64::<BigEndian>());
29-
let mut sec = t / USEC_PER_SEC + TIME_SEC_CONVERSION;
30-
let mut usec = t % USEC_PER_SEC;
31-
32-
if usec < 0 {
33-
sec -= 1;
34-
usec = USEC_PER_SEC + usec;
35-
}
36-
37-
Ok(NaiveDateTime::from_timestamp(sec, (usec * NSEC_PER_USEC) as u32))
3818
}
3919

4020
accepts!(Type::Timestamp);

0 commit comments

Comments
 (0)