xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.99k stars 636 forks source link

WebUI NTP time not in local timezone #2220

Closed mcspr closed 3 years ago

mcspr commented 4 years ago

I noticed a problem with the time display. I have defined server and time zone in custom.h

  #define NTP_SUPPORT                 1
  #define NTP_SERVER                  "homegateway.lan"
  #define NTP_TIMEZONE                TZ_Europe_Warsaw

the time refresh process is running correctly, timezone is also correctly decoded because I see in webinterface:

CET-1CEST,M3.5.0,M10.5.0/3

but on webinterface I still see time as UTC (18h instead 20h)

Originally posted by @reaper7 in https://github.com/xoseperez/espurna/issues/2219#issuecomment-612157081

mcspr commented 4 years ago

Gist of the issue: UI receives raw seconds unix timestamp and we use (new Date(timestamp * 1000)).toISOString() to print it (Stripping T and Z symbols, as it is ISO string output). This is done because NTPCLientLib used to output unix timestamp in local timezone. Current NTP library uses UTC, but string still shows the same data :)

reaper7 commented 4 years ago

so, basically setting the correct time zone only matters when scheduler is used ?

mcspr commented 4 years ago

Right now, yes, this is only a display issue. See ntp terminal output for example.

yo8aiv commented 4 years ago

hi. i'm kind of having the same issue .. but weird .. when i set UTC+2 .. in debug shows wrong by cutting 2h instead of adding them .. if i put -2 it will do the correct thing while in status page nothing seems to change.

Probably unrelated !! using pzem 004t with voltage level shifter : observing that values (power, voltage, etc) aren't changing instantly .. compared to another pzem016 i have. is this normal ??

having sensors set to read and report every 1sec - reading seems to still be done every 6sec ! , reporting looks fine at least on debugging.

ESPURNA 1.14.2-dev PZEM004T-12F

THX.

mcspr commented 4 years ago

See https://github.com/xoseperez/espurna/blob/e26ba9f52ecd60afbbed2ec13d80f4072dad9607/code/espurna/config/general.h#L1551-L1558

Quoting the doc from the gnu.org:

The offset specifies the time value you must add to the local time to get a Coordinated Universal Time value. It has syntax like [+|-]hh[:mm[:ss]]. This is positive if the local time zone is west of the Prime Meridian and negative if it is east. The hour must be between 0 and 24, and the minute and seconds between 0 and 59.

UTC+2 means -2h per the specification, you need to use UTC-2. Or, like it happens to work with -2

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

mcspr commented 3 years ago

Closing via aec13cef63d12ccf1f03a72f55079c6bdb1c120b