static ASN1_UTCTIME* obj_to_asn1utime(VALUE time) { time_t sec; ASN1_UTCTIME *t; sec = time_to_time_t(time); if(!(t = ASN1_UTCTIME_set(NULL, sec))) ossl_raise(eASN1Error, NULL); return t; }
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t) { struct tm *ts; struct tm data; ts = OPENSSL_gmtime(&t, &data); if (ts == NULL) { ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME); return NULL; } if ((ts->tm_year >= 50) && (ts->tm_year < 150)) return ASN1_UTCTIME_set(s, t); return ASN1_GENERALIZEDTIME_set(s, t); }
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t) { struct tm *ts; #if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__) struct tm data; gmtime_r(&t,&data); ts=&data; /* should return &data, but doesn't on some systems, so we don't even look at the return value */ #else ts=gmtime(&t); #endif if((ts->tm_year >= 50) && (ts->tm_year < 150)) return ASN1_UTCTIME_set(s, t); return ASN1_GENERALIZEDTIME_set(s,t); }
inline void utctime::set_time(time_t time) const { throw_error_if_not(ASN1_UTCTIME_set(ptr().get(), time)); }