Add Z only if needed.

pull/2216/head
Phil Constantinou 2025-01-02 12:50:29 -08:00
parent c2175fe46e
commit e352784fed
1 changed files with 6 additions and 1 deletions

View File

@ -104,8 +104,13 @@ func (ts *Timestamp) UnmarshalJSON(b []byte) error {
case "-infinity":
*ts = Timestamp{Valid: true, InfinityModifier: -Infinity}
default:
tss := *s
// PostgreSQL uses ISO 8601 wihout timezone for to_json function and casting from a string to timestampt
tim, err := time.Parse(time.RFC3339Nano, *s+"Z")
if !strings.HasSuffix(tss, "Z") {
tss = tss + "Z"
}
tim, err := time.Parse(time.RFC3339Nano, tss)
if err != nil {
return err
}