Skip to content

Commit ed17d5e

Browse files
jichangsfackler
authored andcommitted
Upgrade chrono to 0.4 (sfackler#272)
1 parent 9628c5b commit ed17d5e

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ types. The driver currently supports the following conversions:
207207
<tr>
208208
<td>
209209
<a href="https://github.com/rust-lang-deprecated/time">time::Timespec</a>,
210-
<a href="https://github.com/lifthrasiir/rust-chrono">chrono::DateTime&lt;UTC&gt;</a>,
210+
<a href="https://github.com/lifthrasiir/rust-chrono">chrono::DateTime&lt;Utc&gt;</a>,
211211
<a href="https://github.com/lifthrasiir/rust-chrono">chrono::DateTime&lt;Local&gt;</a>,
212212
and
213213
<a href="https://github.com/lifthrasiir/rust-chrono">chrono::DateTime&lt;FixedOffset&gt;</a>

postgres-shared/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ phf = "=0.7.21"
2323
postgres-protocol = { version = "0.3", path = "../postgres-protocol" }
2424

2525
bit-vec = { version = "0.4", optional = true }
26-
chrono = { version = "0.3", optional = true }
26+
chrono = { version = "0.4", optional = true }
2727
eui48 = { version = "0.1", optional = true }
2828
geo = { version = "0.4", optional = true }
2929
rustc-serialize = { version = "0.3", optional = true }

postgres-shared/src/types/chrono.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extern crate chrono;
22

33
use postgres_protocol::types;
4-
use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC, Local,
4+
use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, Utc, Local,
55
FixedOffset};
66
use std::error::Error;
77

@@ -39,18 +39,18 @@ impl ToSql for NaiveDateTime {
3939
to_sql_checked!();
4040
}
4141

42-
impl FromSql for DateTime<UTC> {
42+
impl FromSql for DateTime<Utc> {
4343
fn from_sql(type_: &Type,
4444
raw: &[u8])
45-
-> Result<DateTime<UTC>, Box<Error + Sync + Send>> {
45+
-> Result<DateTime<Utc>, Box<Error + Sync + Send>> {
4646
let naive = NaiveDateTime::from_sql(type_, raw)?;
47-
Ok(DateTime::from_utc(naive, UTC))
47+
Ok(DateTime::from_utc(naive, Utc))
4848
}
4949

5050
accepts!(Type::Timestamptz);
5151
}
5252

53-
impl ToSql for DateTime<UTC> {
53+
impl ToSql for DateTime<Utc> {
5454
fn to_sql(&self,
5555
type_: &Type,
5656
w: &mut Vec<u8>)
@@ -66,7 +66,7 @@ impl FromSql for DateTime<Local> {
6666
fn from_sql(type_: &Type,
6767
raw: &[u8])
6868
-> Result<DateTime<Local>, Box<Error + Sync + Send>> {
69-
let utc = DateTime::<UTC>::from_sql(type_, raw)?;
69+
let utc = DateTime::<Utc>::from_sql(type_, raw)?;
7070
Ok(utc.with_timezone(&Local))
7171
}
7272

@@ -78,7 +78,7 @@ impl ToSql for DateTime<Local> {
7878
type_: &Type,
7979
mut w: &mut Vec<u8>)
8080
-> Result<IsNull, Box<Error + Sync + Send>> {
81-
self.with_timezone(&UTC).to_sql(type_, w)
81+
self.with_timezone(&Utc).to_sql(type_, w)
8282
}
8383

8484
accepts!(Type::Timestamptz);
@@ -89,7 +89,7 @@ impl FromSql for DateTime<FixedOffset> {
8989
fn from_sql(type_: &Type,
9090
raw: &[u8])
9191
-> Result<DateTime<FixedOffset>, Box<Error + Sync + Send>> {
92-
let utc = DateTime::<UTC>::from_sql(type_, raw)?;
92+
let utc = DateTime::<Utc>::from_sql(type_, raw)?;
9393
Ok(utc.with_timezone(&FixedOffset::east(0)))
9494
}
9595

@@ -101,7 +101,7 @@ impl ToSql for DateTime<FixedOffset> {
101101
type_: &Type,
102102
w: &mut Vec<u8>)
103103
-> Result<IsNull, Box<Error + Sync + Send>> {
104-
self.with_timezone(&UTC).to_sql(type_, w)
104+
self.with_timezone(&Utc).to_sql(type_, w)
105105
}
106106

107107
accepts!(Type::Timestamptz);

postgres-shared/src/types/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl WrongType {
262262
/// | `serde_json::Value` | JSON, JSONB |
263263
/// | `time::Timespec` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
264264
/// | `chrono::NaiveDateTime` | TIMESTAMP |
265-
/// | `chrono::DateTime<UTC>` | TIMESTAMP WITH TIME ZONE |
265+
/// | `chrono::DateTime<Utc>` | TIMESTAMP WITH TIME ZONE |
266266
/// | `chrono::DateTime<Local>` | TIMESTAMP WITH TIME ZONE |
267267
/// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE |
268268
/// | `chrono::NaiveDate` | DATE |
@@ -461,7 +461,7 @@ pub enum IsNull {
461461
/// | `serde_json::Value` | JSON, JSONB |
462462
/// | `time::Timespec` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
463463
/// | `chrono::NaiveDateTime` | TIMESTAMP |
464-
/// | `chrono::DateTime<UTC>` | TIMESTAMP WITH TIME ZONE |
464+
/// | `chrono::DateTime<Utc>` | TIMESTAMP WITH TIME ZONE |
465465
/// | `chrono::DateTime<Local>` | TIMESTAMP WITH TIME ZONE |
466466
/// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE |
467467
/// | `chrono::NaiveDate` | DATE |

postgres/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ hex = "0.2"
6060
url = "1.0"
6161

6262
bit-vec = "0.4"
63-
chrono = "0.3"
63+
chrono = "0.4"
6464
eui48 = "0.1"
6565
geo = "0.4"
6666
rustc-serialize = "0.3"

postgres/tests/types/chrono.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate chrono;
22

3-
use self::chrono::{TimeZone, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC};
3+
use self::chrono::{TimeZone, NaiveDate, NaiveTime, NaiveDateTime, DateTime, Utc};
44
use types::test_type;
55

66
use postgres::types::{Date, Timestamp};
@@ -33,8 +33,8 @@ fn test_with_special_naive_date_time_params() {
3333

3434
#[test]
3535
fn test_date_time_params() {
36-
fn make_check<'a>(time: &'a str) -> (Option<DateTime<UTC>>, &'a str) {
37-
(Some(UTC.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()), time)
36+
fn make_check<'a>(time: &'a str) -> (Option<DateTime<Utc>>, &'a str) {
37+
(Some(Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()), time)
3838
}
3939
test_type("TIMESTAMP WITH TIME ZONE",
4040
&[make_check("'1970-01-01 00:00:00.010000000'"),
@@ -45,8 +45,8 @@ fn test_date_time_params() {
4545

4646
#[test]
4747
fn test_with_special_date_time_params() {
48-
fn make_check<'a>(time: &'a str) -> (Timestamp<DateTime<UTC>>, &'a str) {
49-
(Timestamp::Value(UTC.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()), time)
48+
fn make_check<'a>(time: &'a str) -> (Timestamp<DateTime<Utc>>, &'a str) {
49+
(Timestamp::Value(Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()), time)
5050
}
5151
test_type("TIMESTAMP WITH TIME ZONE",
5252
&[make_check("'1970-01-01 00:00:00.010000000'"),

0 commit comments

Comments
 (0)