Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Run tzset() and localtime() in getTZOffset() to ensure proper timezon…
Browse files Browse the repository at this point in the history
…e offset (meshtastic#3999)

* Run tzset() and localtime() in getTZOffset() to ensure proper timezone offset

* Try #2 to fix timezone/DST
  • Loading branch information
jp-bennett authored May 31, 2024
1 parent 8d90c49 commit 54bccb8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/gps/RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -265,4 +264,4 @@ time_t gm_mktime(struct tm *tm)
setenv("TZ", "UTC0", 1);
}
return res;
}
}

0 comments on commit 54bccb8

Please sign in to comment.