- struct tm *tm;
- char buf[BUFSIZE];
-
- if (cp + 4 != ep)
- goto corrupt;
- ND_TCHECK2(*cp, 4);
- t = EXTRACT_32BITS(cp);
- if (NULL == (tm = gmtime(&t)))
- ND_PRINT((ndo, ": gmtime() error"));
- else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm))
- ND_PRINT((ndo, ": strftime() error"));
- else
- ND_PRINT((ndo, ": %s UTC", buf));
- return 0;
-
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
- ND_TCHECK2(*cp, ep - cp);
- return 0;
-trunc:
- ND_PRINT((ndo, "%s", tstr));
- return -1;
+ char buf[sizeof("-yyyyyyyyyy-mm-dd hh:mm:ss UTC")];
+
+ if (len != 4)
+ goto invalid;
+ t = GET_BE_U_4(cp);
+ ND_PRINT(": %s",
+ nd_format_time(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC",
+ gmtime(&t)));
+ return;
+
+invalid:
+ nd_print_invalid(ndo);
+ ND_TCHECK_LEN(cp, len);