Skip to content

Commit

Permalink
Fix timezone specific issue when syncing time manually
Browse files Browse the repository at this point in the history
Time was off by one hour when using the sync button in the web UI.
tm_isdst = -1 means that mktime determines the DST flag based on the current timezone
  • Loading branch information
tbnobody committed Nov 29, 2022
1 parent 0d98cbb commit e8c517f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/WebApi_ntp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void WebApiNtpClass::onNtpTimePost(AsyncWebServerRequest* request)
local.tm_mday = root[F("day")].as<uint>(); // day of the month - [ 1 to 31 ]
local.tm_mon = root[F("month")].as<uint>() - 1; // months since January - [ 0 to 11 ]
local.tm_year = root[F("year")].as<uint>() - 1900; // years since 1900
local.tm_isdst = -1;

time_t t = mktime(&local);
struct timeval now = { .tv_sec = t, .tv_usec = 0 };
Expand Down

0 comments on commit e8c517f

Please sign in to comment.