esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
16.07k stars 13.33k forks source link

[ESP8266 - Timezones]: TZ.h has wrong definitions #9197

Closed hasenradball closed 2 months ago

hasenradball commented 2 months ago

Dear ESP Team, @mcspr ,

I used the TZ.h definitions in a project and realized that some things going wrong... Take the following picture as a example:

grafik

If I feed the Timezome like UTC+2 or GMT+2 I expected to get the Time from Berlin (in Summer). Lets assume we have UTC0 = 12:00 and i feed UTC+2 I get the time 10:00 but expected 14:00.

So I think the is a error in the definitions.

Is it?

I used the latest TZ.h

best Frank

mcspr commented 2 months ago

You'd have to take a look at TZ variable definition and what 'offset' is: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

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.

Berlin is on the east of the Prime Meridian (offset +00:00), hence you'd use negative offset and not positive.

If I feed the Timezome like UTC+2 or GMT+2 I expected to get the Time from Berlin (in Summer).

Use TZ_Europe_Berlin? edit: TZ_Etc_GMTp2 is meant to mimic TZ=":Etc/GMT+2" for systems using tz info data at /usr/share/zoneinfo/, which obviously should give the exact same result of 'GMT-02:00' https://github.com/esp8266/Arduino/blob/ccea72823ac50290bc05c67350d2be6626e65547/cores/esp8266/TZ.h#L440

hasenradball commented 2 months ago

Thanks for the Information,

so it is a misunderstanding from my point of view.

I created a wordclock with the ESP8266 and transferrred the TZ.h in json format to easily set the TZ on website.

grafik

Therfore I thought GMTp3 means GMT+ 3 Hours to East.

A short question al least.

The TZ.h is very long, do you think it is possible to easily reduce the lines to unique entries? It seems there are many double entries in side.

mcspr commented 2 months ago

I created a wordclock with the ESP8266 and transferrred the TZ.h in json format to easily set the TZ on website. The TZ.h is very long, do you think it is possible to easily reduce the lines to unique entries? It seems there are many double entries in side.

I believe it would be much easier to make it local to the project, see https://github.com/esp8266/Arduino/blob/master/tools/format_tzdata.py

Entries here repeat tzdata verbatim, plus I'd expect regional names are used instead of hard numbered offsets. Etc zone is a weird one, though, that I agree.

hasenradball commented 2 months ago

What I did is created a json object in js to be able to select it via drop down.

For this it is normally no need for the TZ.h on the ESP side.

What do you mean by keep it locally to the project?

mcspr commented 2 months ago

What I did is created a json object in js to be able to select it via drop down.

For this it is normally no need for the TZ.h on the ESP side.

What do you mean by keep it locally to the project?

To make tzdata the source of timezone data, not TZ.h. You can modify the script to generate the json like it generates either TZ.h or markdown.

hasenradball commented 2 months ago

Ah now I got your point…

I thought of this to modify the python script but with a few mouse clicks I easily got the json from TZ.h.

So no urgent need to change or modify the python.