diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-06-18 20:47:02 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-06-18 20:47:02 +0000 |
commit | 23fa3049eb2a1141da22c31d4ce8e8d0ec0f1cf6 (patch) | |
tree | d552d228aaa3dbb5e5659b715695ab55348fee2f /ossl.c | |
parent | 77998de8ea95f8bcb03203c3f029745c93ecb8e3 (diff) | |
download | ruby-openssl-history-23fa3049eb2a1141da22c31d4ce8e8d0ec0f1cf6.tar.gz |
UTC->local time conversion fixes
Diffstat (limited to 'ossl.c')
-rw-r--r-- | ossl.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -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(); |