From: tb Date: Wed, 20 Apr 2022 15:29:24 +0000 (+0000) Subject: Print UTC time with gmtime() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=65c2098b4007a4588ea0c7e1bcf5d23314aac7c4;p=openbsd 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 --- 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);