From: Miek Gieben Date: Thu, 7 Apr 2005 13:06:50 +0000 (+0000) Subject: RRSIG's inception/expiration data is now printed as YYYYMMDDHHMMSS X-Git-Tag: release-0.50~148 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b348b97b6a2ec3fe3eeb31058dfeb61bdc800cf5;p=thirdparty%2Fldns.git RRSIG's inception/expiration data is now printed as YYYYMMDDHHMMSS just as in bind --- diff --git a/host2str.c b/host2str.c index 13445084..ff5892ed 100644 --- a/host2str.c +++ b/host2str.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -160,8 +161,20 @@ ldns_rdf2buffer_str_int32(ldns_buffer *output, ldns_rdf *rdf) ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, ldns_rdf *rdf) { + /* create a YYYYMMDDHHMMSS string if possible */ uint32_t data = read_uint32(ldns_rdf_data(rdf)); - ldns_buffer_printf(output, "%lu", (unsigned long) data); + time_t data_time; + struct tm tm; + char date_buf[16]; + + memcpy(&data_time, &data, sizeof(uint32_t)); + /* TODO check for NULL */ + (void)gmtime_r(&data_time, &tm); + + (void)strftime(date_buf, 15, "%Y%m%d%H%M%S", &tm); + + ldns_buffer_printf(output, "%s", date_buf); + return ldns_buffer_status(output); } diff --git a/str2host.c b/str2host.c index b6a44cdd..4847bbc2 100644 --- a/str2host.c +++ b/str2host.c @@ -63,7 +63,7 @@ ldns_str2rdf_int16(ldns_rdf **rd, const char *shortstr) ldns_status ldns_str2rdf_time(ldns_rdf **rd, const char *time) { - /* convert a time YYDDMMHHMMSS to wireformat */ + /* convert a time YYYYDDMMHHMMSS to wireformat */ uint16_t *r = NULL; struct tm tm; uint32_t l;