add _der_gmtime, use and test it
This commit is contained in:
@@ -426,22 +426,22 @@ der_put_length_and_tag (unsigned char *p, size_t len, size_t len_val,
|
||||
int
|
||||
_heim_time2generalizedtime (time_t t, heim_octet_string *s, int gtimep)
|
||||
{
|
||||
struct tm *tm;
|
||||
struct tm tm;
|
||||
const size_t len = gtimep ? 15 : 13;
|
||||
|
||||
s->data = malloc(len + 1);
|
||||
if (s->data == NULL)
|
||||
return ENOMEM;
|
||||
s->length = len;
|
||||
tm = gmtime (&t);
|
||||
_der_gmtime(t, &tm);
|
||||
if (gtimep)
|
||||
snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
else
|
||||
snprintf (s->data, len + 1, "%02d%02d%02d%02d%02d%02dZ",
|
||||
tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user