]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
RRSIG's inception/expiration data is now printed as YYYYMMDDHHMMSS
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 7 Apr 2005 13:06:50 +0000 (13:06 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 7 Apr 2005 13:06:50 +0000 (13:06 +0000)
just as in bind

host2str.c
str2host.c

index 134450840f56adb97cd4cd7e1ebb57ce91793742..ff5892ed4f4621a0973032eb9acc314717fc5311 100644 (file)
@@ -17,6 +17,7 @@
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netdb.h>
+#include <time.h>
 
 #include <ldns/host2str.h>
 #include <ldns/packet.h>
@@ -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);
 }
 
index b6a44cdd06f6c1121f0821d2e5c3867b1068f093..4847bbc2850bb1964913bcf2c4785078f0663251 100644 (file)
@@ -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;