diff --git a/src/tds/time/chrono.rs b/src/tds/time/chrono.rs index 0f58ddd0..f6de5001 100644 --- a/src/tds/time/chrono.rs +++ b/src/tds/time/chrono.rs @@ -81,7 +81,7 @@ from_sql!( let offset = chrono::Duration::minutes(dto.offset as i64); let naive = NaiveDateTime::new(date, time).sub(offset); - chrono::DateTime::from_utc(naive, Utc) + chrono::DateTime::from_naive_utc_and_offset(naive, Utc) }), ColumnData::DateTime2(ref dt2) => dt2.map(|dt2| { let date = from_days(dt2.date.days() as i64, 1); @@ -89,7 +89,7 @@ from_sql!( let time = NaiveTime::from_hms_opt(0,0,0).unwrap() + chrono::Duration::nanoseconds(ns); let naive = NaiveDateTime::new(date, time); - chrono::DateTime::from_utc(naive, Utc) + chrono::DateTime::from_naive_utc_and_offset(naive, Utc) }); chrono::DateTime: ColumnData::DateTimeOffset(ref dto) => dto.map(|dto| { let date = from_days(dto.datetime2.date.days() as i64, 1); @@ -99,7 +99,7 @@ from_sql!( let offset = FixedOffset::east_opt((dto.offset as i32) * 60).unwrap(); let naive = NaiveDateTime::new(date, time); - chrono::DateTime::from_utc(naive, offset) + chrono::DateTime::from_naive_utc_and_offset(naive, offset) }) ); diff --git a/tests/query.rs b/tests/query.rs index 38a766ec..4cf3c62b 100644 --- a/tests/query.rs +++ b/tests/query.rs @@ -2237,7 +2237,7 @@ where .unwrap() .and_hms_opt(16, 20, 0) .unwrap(); - let dt: DateTime = DateTime::from_utc(naive, Utc); + let dt: DateTime = DateTime::from_naive_utc_and_offset(naive, Utc); let row = conn .query("SELECT @P1", &[&dt]) @@ -2276,7 +2276,7 @@ where .unwrap(); let fixed = FixedOffset::east_opt(3600 * 3).unwrap(); - let dt: DateTime = DateTime::from_utc(naive, fixed); + let dt: DateTime = DateTime::from_naive_utc_and_offset(naive, fixed); let row = conn .query("SELECT @P1", &[&dt]) @@ -2314,7 +2314,7 @@ where .and_hms_opt(16, 20, 0) .unwrap(); let fixed = FixedOffset::east_opt(3600 * 3).unwrap(); - let dt: DateTime = DateTime::from_utc(naive, fixed); + let dt: DateTime = DateTime::from_naive_utc_and_offset(naive, fixed); let row = conn .query(format!("SELECT CAST('{}' AS datetimeoffset(7))", dt), &[])