Closed RileyRaschke closed 1 year ago
I find some issues related to reading time zone as describe in issue #419 after fixing these issue i get the following result: go result
{
"CurrentDate": "2023-08-12 11:17:26",
"CurrentTimestamp": "2023-08-12 11:17:26 +03:00",
"Sysdate": "2023-08-12 11:17:26",
"Systimestamp": "2023-08-12 11:17:26 +03:00",
"TimeCurrentDate": "2023-08-12T11:17:26Z",
"TimeCurrentTimestamp": "2023-08-12T11:17:26+03:00",
"TimeSysdate": "2023-08-12T11:17:26Z",
"TimeSystimestamp": "2023-08-12T11:17:26.94+03:00"
}
Sysdate: Sat Aug 12 11:17:26 UTC 2023
Systimestamp: Sat Aug 12 11:17:26 +03:00 2023
Real Time: Sat Aug 12 11:04:22 +03 2023
SQL developer result (after 2 minutes)
{
"CurrentDate": "2023-08-12 11:19:55",
"CurrentTimestamp": "2023-08-12 11:19:55 ASIA/RIYADH",
"Sysdate": "2023-08-12 11:19:55",
"Systimestamp": "2023-08-12 11:19:55 +03:00",
"TimeCurrentDate": "12-AUG-23",
"TimeCurrentTimestamp": "12-AUG-23 11.19.55.000000000 AM ASIA/RIYADH",
"TimeSysdate": "12-AUG-23",
"TimeSystimestamp": "12-AUG-23 11.19.55.524000000 AM +03:00"
}
fixed in v2.7.12
I believe this was nearly solved in: https://github.com/sijms/go-ora/issues/24
I just re-ran my test with v2.7.11 on with go1.20.7.
Given the following
struct
and SQL query:And the following Testing Functions
Yields the following output. Note the
Time
prefixed items are scanned to typetime.Time
while the string fields are using oracleTO_CHAR
to produce the real time.Above we can see
sysdate
scanned totime.Time
is the correct time, but defaults to wrong zone.systimestamp
scanned totime.Time
is the right zone, but the wrong time.I believe the issue resides in v2.7.11 here
I think the solution is to default to the zone resulting from
select to_char(systimestamp,'TZR') from dual;
for bothdate
andtimestamp
oracle types with a connection option being added to use any specific zone as the default and override the above assumption.The above is the approach used by github.com/godror/godror
godror
has a whole document on this subject and oracle's poor presumptions at: timezone.mdI'd love to use your instant client free driver, but until it can tell time, I cannot.
I have a full version of my test ready to run at: https://github.com/RileyRaschke/goora_date_test