You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure this is a bug you can or should do anything about, but I figured you should be made aware of it.
The timestamp with time zone (timestamptz) type decodes with different time.Location values depending on the encoding:
DecodeText yields a time.Time with location time.UTC
DecodeBinary yields a time.Time with location time.Local
You can see this for yourself by running the modified tests found in this commit: bvisness@a859409
The reason for this, I think, is that DecodeText uses time.Parse with a format string like "2006-01-02 15:04:05.999999999Z07:00:00". The problem is Z; time.Parse does not recognize Z as a valid timezone specifier and so falls back to parsing as UTC. DecodeBinary simply uses time.Unix, which always produces a local Go time.
As I said, I'm not even really sure if this is a bug since I'm not sure we should depend on a particular time.Location from Postgres, given that the timestamptz from Postgres does not contain any location information. Arguably it could always produce a UTC time, since it's always stored in Postgres as UTC, but as a fully qualified time I'm not sure it even matters.
If anything, the worst part is that there is a discrepancy between the two encodings.
Feel free to close if you don't think it's worth doing anything about!
The text was updated successfully, but these errors were encountered:
The problem is Z; time.Parse does not recognize Z as a valid timezone specifier and so falls back to parsing as UTC.
It ends up in UTC, but it does handle the +7 offset.
I agree the situation is not ideal, but I'm not sure what would be an improvement. And then there's the problem of not breaking backwards compatibility.
I'm not sure this is a bug you can or should do anything about, but I figured you should be made aware of it.
The
timestamp with time zone
(timestamptz
) type decodes with differenttime.Location
values depending on the encoding:DecodeText
yields atime.Time
with locationtime.UTC
DecodeBinary
yields atime.Time
with locationtime.Local
You can see this for yourself by running the modified tests found in this commit: bvisness@a859409
The reason for this, I think, is that
DecodeText
usestime.Parse
with a format string like"2006-01-02 15:04:05.999999999Z07:00:00"
. The problem isZ
;time.Parse
does not recognizeZ
as a valid timezone specifier and so falls back to parsing as UTC.DecodeBinary
simply usestime.Unix
, which always produces a local Go time.As I said, I'm not even really sure if this is a bug since I'm not sure we should depend on a particular
time.Location
from Postgres, given that thetimestamptz
from Postgres does not contain any location information. Arguably it could always produce a UTC time, since it's always stored in Postgres as UTC, but as a fully qualified time I'm not sure it even matters.If anything, the worst part is that there is a discrepancy between the two encodings.
Feel free to close if you don't think it's worth doing anything about!
The text was updated successfully, but these errors were encountered: