Created
December 21, 2010 13:32
-
-
Save kubo/749935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment