From 54bccb898e4b8a1f4bdcb3670a94869ff5b9c4fb Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 31 May 2024 07:15:16 -0500 Subject: [PATCH] Run tzset() and localtime() in getTZOffset() to ensure proper timezone offset (#3999) * Run tzset() and localtime() in getTZOffset() to ensure proper timezone offset * Try #2 to fix timezone/DST --- src/gps/RTC.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index 864b246a35..d60e3825c8 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -222,9 +222,8 @@ bool perhapsSetRTC(RTCQuality q, struct tm &t) */ int32_t getTZOffset() { - time_t now; + time_t now = getTime(false); struct tm *gmt; - now = time(NULL); gmt = gmtime(&now); gmt->tm_isdst = -1; return (int32_t)difftime(now, mktime(gmt)); @@ -265,4 +264,4 @@ time_t gm_mktime(struct tm *tm) setenv("TZ", "UTC0", 1); } return res; -} +} \ No newline at end of file