summaryrefslogtreecommitdiff
path: root/print-ntp.c
diff options
context:
space:
mode:
authorUlrich Windl <Ulrich.Windl@RZ.Uni-Regensburg.DE>2017-08-24 09:22:57 +0200
committerDenis Ovsienko <denis@ovsienko.info>2017-08-29 14:47:51 +0100
commit99412d6d5ae0697d223bddf283c453bb29151037 (patch)
treec69fb4bdaad7a6a8bf6f646efc266560c74b26c9 /print-ntp.c
parent1136bb5c531281e8450ddee797b3eaace1459017 (diff)
downloadtcpdump-99412d6d5ae0697d223bddf283c453bb29151037.tar.gz
Print NTP timestamps as UTC, not local time
print-ntp.c: Change p_ntp_time() to print NTP timestamps in UTC instead of local time. This allows for consistent output for automatic testing different time zones. Also use an ISO 8601 (RFC3339) format for the time stamps.
Diffstat (limited to 'print-ntp.c')
-rw-r--r--print-ntp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/print-ntp.c b/print-ntp.c
index 8edb58fc..a0b04641 100644
--- a/print-ntp.c
+++ b/print-ntp.c
@@ -366,15 +366,16 @@ p_ntp_time(netdissect_options *ndo,
#ifdef HAVE_STRFTIME
/*
- * print the time in human-readable format.
+ * print the UTC time in human-readable format.
*/
if (i) {
time_t seconds = i - JAN_1970;
struct tm *tm;
char time_buf[128];
- tm = localtime(&seconds);
- strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm);
+ tm = gmtime(&seconds);
+ /* use ISO 8601 (RFC3339) format */
+ strftime(time_buf, sizeof (time_buf), "%Y-%m-%dT%H:%M:%S", tm);
ND_PRINT((ndo, " (%s)", time_buf));
}
#endif