godror

Timezones

Oracle DB has three time zones:

For details, see https://stackoverflow.com/a/29272926

Go does have a time zone information for every time.Time value. So, how do we determine what time zone should be set on a value returned by a SELECT DATE_column FROM table ?

If you insert SYSDATE into that column, then the OS’ time zone is the relevant. If you insert CURRENT_DATE, then SESSIONTIMEZONE is the relevant.

As I don’t use CURRENT_DATE, I pick the OS’ time zone.

Godror will print a

godor WARNING: discrepancy between DBTIMEZONE and SYSTIMESTAMP

warning that it chosen the DB’s OS’ time zone (TO_CHAR(SYSTIMESTAMP, 'TZR')),

Why do we need to handle time zones for DATE ?

DATEs should use something else than time.Time, as the don’t have a time zone. Only TIMESTAMP WITH TIME (LOCAL) TIMEZONE data types should use time.Time.

That’d mean we push the burden of choosing the right time zone to the developer, and the std lib (database/sql/driver.Value) mandates the management of time.Time, thus either we error out at runtime when we get a time.Time, or manage it somehow.

That’s why we have to use time.Time, and deal with time zones.