feat: add ensureUTC function and apply it to datetime transformations in MSSQL processing

This commit is contained in:
2026-04-07 11:37:04 -05:00
parent aea310a3dd
commit 2f8263d332
2 changed files with 14 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/binary"
"time"
)
func mssqlUuidToBigEndian(mssqlUuid []byte) []byte {
@@ -50,3 +51,11 @@ func wkbToEwkbWithSrid(geometry []byte, srid int) []byte {
return result
}
func ensureUTC(t time.Time) time.Time {
if t.Location() == time.UTC {
return t
}
return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.UTC)
}

View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"sync"
"time"
"github.com/jackc/pgx/v5/pgxpool"
@@ -83,6 +84,10 @@ func transformRowsMssql(columns []ColumnType, in <-chan []UnknownRowValues, out
if b, ok := value.([]byte); ok {
rowValues[i] = wkbToEwkbWithSrid(b, 4326)
}
} else if col.SystemType() == "datetime" || col.SystemType() == "datetime2" {
if t, ok := value.(time.Time); ok {
rowValues[i] = ensureUTC(t)
}
}
}
}