Fix date change if timezone brings to different day

replace/c50dfab39cca2bc152cce332b80fde6ebd5dd45e
Federico Amedeo Izzo 2021-04-10 15:57:58 +02:00
rodzic 341c46a263
commit 26eb381ca2
1 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -96,9 +96,15 @@ curTime_t state_getLocalTime(curTime_t utc_time)
{
curTime_t local_time = utc_time;
if(local_time.hour + state.settings.utc_timezone >= 24)
{
local_time.hour = local_time.hour - 24 + state.settings.utc_timezone;
local_time.date += 1;
}
else if(local_time.hour + state.settings.utc_timezone < 0)
{
local_time.hour = local_time.hour + 24 + state.settings.utc_timezone;
local_time.date -= 1;
}
else
local_time.hour += state.settings.utc_timezone;
return local_time;
@ -108,9 +114,15 @@ curTime_t state_getUTCTime(curTime_t local_time)
{
curTime_t utc_time = local_time;
if(utc_time.hour - state.settings.utc_timezone >= 24)
{
utc_time.hour = utc_time.hour - 24 - state.settings.utc_timezone;
utc_time.date += 1;
}
else if(utc_time.hour - state.settings.utc_timezone < 0)
{
utc_time.hour = utc_time.hour + 24 - state.settings.utc_timezone;
local_time.date -= 1;
}
else
utc_time.hour -= state.settings.utc_timezone;
return utc_time;