-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB timestamp (no tz) returned with local timezone in Go time.Time #133
Comments
In the version I'm testing I've replaced all the occurrences of time.Local with time.UTC in column.go. |
I am not clear what your problem is, so I assume you want to access column data types that can store time zone. As far as I can see, none of the types currently supported by this driver allow for storing timezone information. I googled for such types, and I can find SQL_SS_TIMESTAMPOFFSET (from https://docs.microsoft.com/en-us/sql/relational-databases/native-client-odbc-date-time/data-type-support-for-odbc-date-and-time-improvements?view=sql-server-2017 ). According to that page, SQL_SS_TIMESTAMPOFFSET is called Alex |
I don't think that watercraft's problem is being unable to access column data types that can store time zone information. Instead, I think the problem is the default time zone that this driver applies to column data types that do not themselves supply time zone information.
Correct. And because of that, this driver must assign some time zone when creating time.Time variables. Currently it hard-codes the time zone
Go's time.Date function requires a non-nil *Location for the final argument, and For example, assume you have a system that uses Microsoft SQL Server as the database engine, and all date/time information is stored in DateTime2 columns. Further assume that the system architect declared that, by convention, all data stored in these columns must be UTC at the time of insertion. SQL Server's DateTime2 data type does not store time zone information, so a value in a table might look something like this:
Because of the system architect's convention that all date/time values are inserted as UTC values, that value should be interpreted as:
But when this driver extracts the value it will assign it to the local time zone. If the system on which this driver is running is in the EDT time zone, for example, then this driver will return a time.Time variable with value:
That is four hours off what it was intended to be. Unfortunately, Go doesn't have a built-in method to rezone a time value that has the wrong time zone. You can convert to UTC (e.g.
Therefore, it would be handy if the default time zone for this driver could be configured rather than hard coded as Does this make sense, and would you have any interest in such a change? |
Replied at #157 (comment) Alex |
My current application goes though hoops to workaround the fact that the database type
timestamp (without the -tz for Vertica) is returned with the local timestamp. The intention here was to
record the UTC timestamp of events that may be published in different timezones. First
I tried backing the local timezone out which gave me problems when we changed our
daylight savings offset. What I have now converts all these timestamps to strings that are
then parsed in Go.
Note, the lib/pq is able to return these timestamps as UTC.
Is there some configuration I could use like the connection timezone to get these timestamps
parsed into UTC?
The text was updated successfully, but these errors were encountered: