Skip to content

Commit

Permalink
add dt2 decoding case
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Jun 3, 2024
1 parent 5595382 commit f071fb4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tds/time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ from_sql!(
let offset = chrono::Duration::minutes(dto.offset as i64);
let naive = NaiveDateTime::new(date, time).sub(offset);

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_naive_utc_and_offset(naive, Utc)
});
chrono::DateTime<FixedOffset>: ColumnData::DateTimeOffset(ref dto) => dto.map(|dto| {
Expand Down

0 comments on commit f071fb4

Please sign in to comment.