Skip to content

Commit 748f4b7

Browse files
authored
Merge pull request #3781 from weiznich/fix/chrono
Remove usage of deprecated chrono functions
2 parents cf77884 + 6e54be7 commit 748f4b7

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

diesel/src/pg/types/date_and_time/chrono.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl ToSql<Timestamptz, Pg> for NaiveDateTime {
6565
impl FromSql<Timestamptz, Pg> for DateTime<Utc> {
6666
fn from_sql(bytes: PgValue<'_>) -> deserialize::Result<Self> {
6767
let naive_date_time = <NaiveDateTime as FromSql<Timestamptz, Pg>>::from_sql(bytes)?;
68-
Ok(DateTime::from_utc(naive_date_time, Utc))
68+
Ok(Utc.from_utc_datetime(&naive_date_time))
6969
}
7070
}
7171

diesel/src/sqlite/types/date_and_time/chrono.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl FromSql<TimestamptzSqlite, Sqlite> for DateTime<Utc> {
195195
// Fallback on assuming Utc
196196
let naive_date_time =
197197
<NaiveDateTime as FromSql<TimestamptzSqlite, Sqlite>>::from_sql(value)?;
198-
Ok(DateTime::from_utc(naive_date_time, Utc))
198+
Ok(Utc.from_utc_datetime(&naive_date_time))
199199
}
200200
}
201201

diesel_cli/tests/migration_generate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Creating migrations.\\d{4}-\\d{2}-\\d{2}-\\d{6}_hello.down.sql\
2727
let captured_timestamps = Regex::new(r"(?P<stamp>[\d-]*)_hello").unwrap();
2828
let mut stamps_found = 0;
2929
for caps in captured_timestamps.captures_iter(result.stdout()) {
30-
let timestamp = Utc.datetime_from_str(&caps["stamp"], TIMESTAMP_FORMAT);
30+
let timestamp = NaiveDateTime::parse_from_str(&caps["stamp"], TIMESTAMP_FORMAT);
3131
assert!(
3232
timestamp.is_ok(),
3333
"Found invalid timestamp format: {:?}",

diesel_tests/tests/schema_inference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ mod postgres {
229229
ts: (Bound::Included(dt), Bound::Unbounded),
230230
tstz: (
231231
Bound::Unbounded,
232-
Bound::Excluded(DateTime::<Utc>::from_utc(dt, Utc)),
232+
Bound::Excluded(Utc.from_utc_datetime(&dt)),
233233
),
234234
date: (Bound::Included(dt.date()), Bound::Unbounded),
235235
};

diesel_tests/tests/types_roundtrip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ mod pg_types {
367367
}
368368

369369
pub fn mk_datetime(data: (i64, u32)) -> DateTime<Utc> {
370-
DateTime::from_utc(mk_pg_naive_datetime(data), Utc)
370+
Utc.from_utc_datetime(&mk_pg_naive_datetime(data))
371371
}
372372
}
373373

0 commit comments

Comments
 (0)