diff options
Diffstat (limited to 'ossl.c')
-rw-r--r-- | ossl.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -54,7 +54,11 @@ VALUE asn1time_to_time(ASN1_UTCTIME *time) { struct tm tm; + time_t t; + char env[16]; + const char *tz; + memset(&tm, 0, sizeof(struct tm)); switch(time->type) { case V_ASN1_UTCTIME: if (!strptime(time->data, "%y%m%d%H%M%SZ", &tm)) { @@ -69,8 +73,18 @@ asn1time_to_time(ASN1_UTCTIME *time) default: rb_raise(rb_eTypeError, "unknown time format"); } - /*return rb_time_new(mktime(gmtime(mktime(&tm))), 0); * Is this correct? */ - return rb_time_new(mktime(&tm), 0); /* or this one? */ + + /* workaround to convert into UTC time */ + tz = getenv("TZ"); + putenv("TZ=UTC0"); + t = mktime(&tm); + if(!tz) unsetenv("TZ"); + else { + snprintf(env, sizeof(env), "TZ=%s", tz); + putenv(env); + } + + return rb_time_new(t, 0); } /* |