From c67f21bf963c626d9ab31e3aaac159371b70a51e Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 6 Dec 2021 11:57:45 -0600 Subject: [PATCH] Fix timezone to zero for UTC time values https://github.com/Hamlib/Hamlib/issues/851 --- src/misc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/misc.c b/src/misc.c index 7598a24d6..7e9d5f24c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2430,23 +2430,26 @@ char *date_strget(char *buf, int buflen, int localtime) time_t t; struct timeval tv; struct tm result; + int mytimezone; t = time(NULL); if (localtime) { mytm = localtime_r(&t, &result); + mytimezone = timezone; } else { mytm = gmtime_r(&t, &result); + mytimezone = 0; } strftime(buf, buflen, "%Y-%m-%dT%H:%M:%S.", mytm); gettimeofday(&tv, NULL); snprintf(tmpbuf, sizeof(tmpbuf), "%06ld", (long)tv.tv_usec); strcat(buf, tmpbuf); - snprintf(tmpbuf, sizeof(tmpbuf), "%s%04d", timezone >=0? "-":"+", ((int)abs(timezone)/3600)*100); + snprintf(tmpbuf, sizeof(tmpbuf), "%s%04d", mytimezone >=0? "-":"+", ((int)abs(mytimezone)/3600)*100); strcat(buf, tmpbuf); return buf; }