Skip to content

Commit

Permalink
revert chrono changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Jul 17, 2024
1 parent 2760050 commit 24e517a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/tds/time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ 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);
let ns = dt2.time.increments as i64 * 10i64.pow(9 - dt2.time.scale as u32);
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<FixedOffset>: ColumnData::DateTimeOffset(ref dto) => dto.map(|dto| {
let date = from_days(dto.datetime2.date.days() as i64, 1);
Expand All @@ -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)
})
);

Expand Down
6 changes: 3 additions & 3 deletions tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ where
.unwrap()
.and_hms_opt(16, 20, 0)
.unwrap();
let dt: DateTime<Utc> = DateTime::from_utc(naive, Utc);
let dt: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive, Utc);

let row = conn
.query("SELECT @P1", &[&dt])
Expand Down Expand Up @@ -2276,7 +2276,7 @@ where
.unwrap();

let fixed = FixedOffset::east_opt(3600 * 3).unwrap();
let dt: DateTime<FixedOffset> = DateTime::from_utc(naive, fixed);
let dt: DateTime<FixedOffset> = DateTime::from_naive_utc_and_offset(naive, fixed);

let row = conn
.query("SELECT @P1", &[&dt])
Expand Down Expand Up @@ -2314,7 +2314,7 @@ where
.and_hms_opt(16, 20, 0)
.unwrap();
let fixed = FixedOffset::east_opt(3600 * 3).unwrap();
let dt: DateTime<FixedOffset> = DateTime::from_utc(naive, fixed);
let dt: DateTime<FixedOffset> = DateTime::from_naive_utc_and_offset(naive, fixed);

let row = conn
.query(format!("SELECT CAST('{}' AS datetimeoffset(7))", dt), &[])
Expand Down

0 comments on commit 24e517a

Please sign in to comment.