aboutsummaryrefslogtreecommitdiffstats
path: root/ossl.c
diff options
context:
space:
mode:
authorMichal Rokos <m.rokos@sh.cvut.cz>2002-06-18 20:47:02 +0000
committerMichal Rokos <m.rokos@sh.cvut.cz>2002-06-18 20:47:02 +0000
commit23fa3049eb2a1141da22c31d4ce8e8d0ec0f1cf6 (patch)
treed552d228aaa3dbb5e5659b715695ab55348fee2f /ossl.c
parent77998de8ea95f8bcb03203c3f029745c93ecb8e3 (diff)
downloadruby-openssl-history-23fa3049eb2a1141da22c31d4ce8e8d0ec0f1cf6.tar.gz
UTC->local time conversion fixes
Diffstat (limited to 'ossl.c')
-rw-r--r--ossl.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ossl.c b/ossl.c
index 6587e79..ad80f64 100644
--- a/ossl.c
+++ b/ossl.c
@@ -51,10 +51,12 @@ ossl_check_instance(VALUE obj, VALUE klass)
* DATE conversion
*/
VALUE
-asn1time_to_time(ASN1_UTCTIME *time)
+asn1time_to_time(ASN1_TIME *time)
{
struct tm tm;
+ 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,24 +71,19 @@ asn1time_to_time(ASN1_UTCTIME *time)
default:
ossl_raise(rb_eTypeError, "unknown time format");
}
- /*
- * QUESTION:
- * return rb_time_new(mktime(gmtime(mktime(&tm))), 0);
- * Is this better than following?
- */
- return rb_time_new(mktime(&tm), 0);
+ return rb_time_new(mktime(&tm) - timezone, 0);
}
/*
* This function is not exported in Ruby's *.h
*/
-extern struct timeval rb_time_timeval(VALUE time);
+extern struct timeval rb_time_timeval(VALUE);
time_t
time_to_time_t(VALUE time)
{
struct timeval t = rb_time_timeval(time);
-
+
return t.tv_sec;
}
@@ -208,6 +205,11 @@ void
Init_openssl()
{
/*
+ * Init timezone info
+ */
+ tzset();
+
+ /*
* Init all digests, ciphers
*/
OpenSSL_add_all_algorithms();