Skip to content

Commit 19a6ef7

Browse files
committed
fix more deprecated chrono functions
1 parent b4ebc4e commit 19a6ef7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

postgres-types/src/chrono_04.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl ToSql for NaiveDateTime {
4242
impl<'a> FromSql<'a> for DateTime<Utc> {
4343
fn from_sql(type_: &Type, raw: &[u8]) -> Result<DateTime<Utc>, Box<dyn Error + Sync + Send>> {
4444
let naive = NaiveDateTime::from_sql(type_, raw)?;
45-
Ok(Utc::from_utc_datetime(naive))
45+
Ok(Utc.from_utc_datetime(&naive))
4646
}
4747

4848
accepts!(TIMESTAMPTZ);

tokio-postgres/tests/test/types/chrono_04.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ async fn test_with_special_naive_date_time_params() {
5353
async fn test_date_time_params() {
5454
fn make_check(time: &str) -> (Option<DateTime<Utc>>, &str) {
5555
(
56-
Some(
57-
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
58-
.unwrap(),
59-
),
56+
Some(Utc.from_utc_datetime(
57+
&NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(),
58+
)),
6059
time,
6160
)
6261
}
@@ -76,10 +75,9 @@ async fn test_date_time_params() {
7675
async fn test_with_special_date_time_params() {
7776
fn make_check(time: &str) -> (Timestamp<DateTime<Utc>>, &str) {
7877
(
79-
Timestamp::Value(
80-
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
81-
.unwrap(),
82-
),
78+
Timestamp::Value(Utc.from_utc_datetime(
79+
&NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(),
80+
)),
8381
time,
8482
)
8583
}

0 commit comments

Comments
 (0)