public
Last active

  • Download Gist
timeoffset_patch.dif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
Index: ext/oci8/ocidatetime.c
===================================================================
--- ext/oci8/ocidatetime.c (revision 411)
+++ ext/oci8/ocidatetime.c (working copy)
@@ -102,7 +102,7 @@
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
-VALUE oci8_make_ocitimestamp(OCIDateTime *dttm)
+VALUE oci8_make_ocitimestamp(OCIDateTime *dttm, void *hndl)
{
sb2 year;
ub1 month;
@@ -118,7 +118,15 @@
oci_lc(OCIDateTimeGetDate(oci8_envhp, oci8_errhp, dttm, &year, &month, &day));
oci_lc(OCIDateTimeGetTime(oci8_envhp, oci8_errhp, dttm, &hour, &minute, &sec, &fsec));
- rv = OCIDateTimeGetTimeZoneOffset(oci8_envhp, oci8_errhp, dttm, &tz_hour, &tz_minute);
+ rv = OCIDateTimeGetTimeZoneOffset(hndl, oci8_errhp, dttm, &tz_hour, &tz_minute);
+ if (rv != OCI_SUCCESS) {
+ /* Get time zone of the specified handle. */
+ OCIDateTime *sys_date;
+ oci_lc(OCIDescriptorAlloc(oci8_envhp, (dvoid*)&sys_date, OCI_DTYPE_TIMESTAMP_TZ, 0, 0));
+ oci_lc(OCIDateTimeSysTimeStamp(hndl, oci8_errhp, sys_date));
+ rv = OCIDateTimeGetTimeZoneOffset(hndl, oci8_errhp, sys_date, &tz_hour, &tz_minute);
+ OCIDescriptorFree(sys_date, OCI_DTYPE_TIMESTAMP_TZ);
+ }
have_tz = (rv == OCI_SUCCESS);
return rb_ary_new3(9,
INT2FIX(year),
@@ -239,7 +247,10 @@
static VALUE bind_ocitimestamp_get(oci8_bind_t *obind, void *data, void *null_struct)
{
- return oci8_make_ocitimestamp(*(OCIDateTime **)data);
+ oci8_base_t *hndl;
+ for (hndl = obind->base.parent; hndl->type == OCI_HTYPE_STMT; hndl = hndl->parent) {
+ }
+ return oci8_make_ocitimestamp(*(OCIDateTime **)data, TO_SESSION(hndl->self));
}
static void bind_ocitimestamp_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.