No TZ.h File for ESP32?

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

No TZ.h File for ESP32?

Postby gfvalvo » Wed Apr 26, 2023 8:29 pm

So, the ESP8266 Arduino core has a very handy file called 'TZ.h" located in:
…/esp8266\hardware\esp8266\3.1.1\cores\esp8266

It contains the Unix time zone codes ('TZ' environment variable) for hundreds of locations around the world. They're defined with human-readable macros. For example:

Code: Select all

#define TZ_America_Chicago	PSTR("CST6CDT,M3.2.0,M11.1.0")
#define TZ_Europe_London	PSTR("GMT0BST,M3.5.0/1,M10.5.0")
#define TZ_America_New_York	PSTR("EST5EDT,M3.2.0,M11.1.0")
However, this file doesn't exist in the ESP32. Wondering if that's intentional or an oversight?

Anyway, I copied the file and included it in one of my ESP32 projects. It compiles and works just fine:

Code: Select all

configTzTime(TZ_America_New_York, ntpServer1, ntpServer2);

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: No TZ.h File for ESP32?

Postby lbernstone » Wed Apr 26, 2023 8:57 pm

It's not there because it changes frequently and is not something that is worth espressif maintaining. You can find a maintained list at https://raw.githubusercontent.com/nayar ... /zones.csv, and an example using that at https://github.com/lbernstone/setTZ

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

Re: No TZ.h File for ESP32?

Postby gfvalvo » Thu Apr 27, 2023 1:35 pm

Thanks for the reply. I guess Espressif came to that epiphany sometime between creating the ESP8266 core and creating the the ESP32 core.

Who is online

Users browsing this forum: No registered users and 70 guests