Skip to content

Commit

Permalink
Remove usage of deprecated chrono functions
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Sep 6, 2023
1 parent cf77884 commit 6e54be7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion diesel/src/pg/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ToSql<Timestamptz, Pg> for NaiveDateTime {
impl FromSql<Timestamptz, Pg> for DateTime<Utc> {
fn from_sql(bytes: PgValue<'_>) -> deserialize::Result<Self> {
let naive_date_time = <NaiveDateTime as FromSql<Timestamptz, Pg>>::from_sql(bytes)?;
Ok(DateTime::from_utc(naive_date_time, Utc))
Ok(Utc.from_utc_datetime(&naive_date_time))
}
}

Expand Down
2 changes: 1 addition & 1 deletion diesel/src/sqlite/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl FromSql<TimestamptzSqlite, Sqlite> for DateTime<Utc> {
// Fallback on assuming Utc
let naive_date_time =
<NaiveDateTime as FromSql<TimestamptzSqlite, Sqlite>>::from_sql(value)?;
Ok(DateTime::from_utc(naive_date_time, Utc))
Ok(Utc.from_utc_datetime(&naive_date_time))
}
}

Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/tests/migration_generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Creating migrations.\\d{4}-\\d{2}-\\d{2}-\\d{6}_hello.down.sql\
let captured_timestamps = Regex::new(r"(?P<stamp>[\d-]*)_hello").unwrap();
let mut stamps_found = 0;
for caps in captured_timestamps.captures_iter(result.stdout()) {
let timestamp = Utc.datetime_from_str(&caps["stamp"], TIMESTAMP_FORMAT);
let timestamp = NaiveDateTime::parse_from_str(&caps["stamp"], TIMESTAMP_FORMAT);
assert!(
timestamp.is_ok(),
"Found invalid timestamp format: {:?}",
Expand Down
2 changes: 1 addition & 1 deletion diesel_tests/tests/schema_inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod postgres {
ts: (Bound::Included(dt), Bound::Unbounded),
tstz: (
Bound::Unbounded,
Bound::Excluded(DateTime::<Utc>::from_utc(dt, Utc)),
Bound::Excluded(Utc.from_utc_datetime(&dt)),
),
date: (Bound::Included(dt.date()), Bound::Unbounded),
};
Expand Down
2 changes: 1 addition & 1 deletion diesel_tests/tests/types_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ mod pg_types {
}

pub fn mk_datetime(data: (i64, u32)) -> DateTime<Utc> {
DateTime::from_utc(mk_pg_naive_datetime(data), Utc)
Utc.from_utc_datetime(&mk_pg_naive_datetime(data))
}
}

Expand Down

0 comments on commit 6e54be7

Please sign in to comment.