From 65c2098b4007a4588ea0c7e1bcf5d23314aac7c4 Mon Sep 17 00:00:00 2001 From: tb Date: Wed, 20 Apr 2022 15:29:24 +0000 Subject: [PATCH] Print UTC time with gmtime() This replaces a strange hack that sets TZ=UTC and calls localtime(). Tweak format string to keep printing UTC. ok claudio --- usr.sbin/rpki-client/output-json.c | 5 ++--- usr.sbin/rpki-client/output.c | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/usr.sbin/rpki-client/output-json.c b/usr.sbin/rpki-client/output-json.c index 6b85893b665..781dc567442 100644 --- a/usr.sbin/rpki-client/output-json.c +++ b/usr.sbin/rpki-client/output-json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output-json.c,v 1.24 2022/04/19 13:52:24 claudio Exp $ */ +/* $OpenBSD: output-json.c,v 1.25 2022/04/20 15:29:24 tb Exp $ */ /* * Copyright (c) 2019 Claudio Jeker * @@ -31,8 +31,7 @@ outputheader_json(FILE *out, struct stats *st) int i; time(&t); - setenv("TZ", "UTC", 1); - tp = localtime(&t); + tp = gmtime(&t); strftime(tbuf, sizeof tbuf, "%FT%TZ", tp); gethostname(hn, sizeof hn); diff --git a/usr.sbin/rpki-client/output.c b/usr.sbin/rpki-client/output.c index b23b3f8066d..fc22af28d8d 100644 --- a/usr.sbin/rpki-client/output.c +++ b/usr.sbin/rpki-client/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.25 2022/04/19 13:52:24 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.26 2022/04/20 15:29:24 tb Exp $ */ /* * Copyright (c) 2019 Theo de Raadt * @@ -204,9 +204,8 @@ outputheader(FILE *out, struct stats *st) int i; time(&t); - setenv("TZ", "UTC", 1); - tp = localtime(&t); - strftime(tbuf, sizeof tbuf, "%a %b %e %H:%M:%S %Z %Y", tp); + tp = gmtime(&t); + strftime(tbuf, sizeof tbuf, "%a %b %e %H:%M:%S UTC %Y", tp); gethostname(hn, sizeof hn); -- 2.20.1