getLocalTime(&local); Definitions of time zones

rin67630
Posts: 99
Joined: Sun Mar 11, 2018 5:13 pm

getLocalTime(&local); Definitions of time zones

Postby rin67630 » Thu Apr 05, 2018 11:33 am

Hi

I have a sample ESP32 sketch (Arduino ISP) using

Code: Select all

GetLocalTime(&local);
It uses a definition string for timezones for which I cound not find any documentation:

#define TZ_INFO "MST7MDT6,M3.2.0/02:00:00,M11.1.0/02:00:00" // Americas/Denver

I googled my fingers wound, without success.

What is the valid string for Western Europe?

Thank you

rin67630
Posts: 99
Joined: Sun Mar 11, 2018 5:13 pm

Re: getLocalTime(&local); Definitions of time zones

Postby rin67630 » Thu Apr 05, 2018 2:31 pm

I finally found it:
W. Europe Standard Time: "WEST-1DWEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"

https://www.di-mgt.com.au/wclock/tz-syntax.txt
[img]
https://www.cjoint.com/doc/18_04/HDfoEL ... String.jpg
[/img]


rin67630
Posts: 99
Joined: Sun Mar 11, 2018 5:13 pm

Re: getLocalTime(&local); Definitions of time zones

Postby rin67630 » Thu Apr 05, 2018 8:04 pm

Exactly that was not useful to find the solution.
It was not a matter of defining the time zones, but which syntax to use.

meowsqueak
Posts: 151
Joined: Thu Jun 15, 2017 4:54 am
Location: New Zealand

Re: getLocalTime(&local); Definitions of time zones

Postby meowsqueak » Thu Apr 05, 2018 9:41 pm

rin67630 wrote:
Exactly that was not useful to find the solution.
It was not a matter of defining the time zones, but which syntax to use.
I had the same problem - usually with most environments I'd use TZ="Pacific/Auckland" or sometimes ":Pacific/Auckland", which is what most timezone searches would reveal. But neither of those work here. Somewhere, after an hour of digging, I found I had to use "NZST-12NZDT,M9.5.0,M4.1.0/3". Not exactly obvious but at least it's explicit about daylight savings.

Also, to use UTC, you need to use "UTC0", or gmtime/gmtime_r().

Note that there's a fairly well known memory leak in setenv() which means that if you change timezones repeatedly, which you might do for an application that handles multiple time zones, you'll eventually run out of memory. I'm not sure if the environment is shared between tasks - if not, it might be better to have separate tasks for each timezone. If it is shared, then I'm not sure what the best way to deal with this is. In my case I worked out the difference between the two timezones and used that to calculate the second time.

waterfox
Posts: 20
Joined: Sun Mar 22, 2020 10:19 pm

Re: getLocalTime(&local); Definitions of time zones

Postby waterfox » Fri May 22, 2020 8:16 am

Are there any updates to this?
I've also searched how to set up the tz variable. But I only found a few examples.

Is there any possible to set the time with the IANA time zone database?

markkuk
Posts: 37
Joined: Wed Mar 27, 2019 11:50 am

Re: getLocalTime(&local); Definitions of time zones

Postby markkuk » Fri May 22, 2020 9:44 am

The official reference for the TZ setting syntax is in the Single Unix Specification (a.k.a. POSIX) standard: https://pubs.opengroup.org/onlinepubs/9 ... tml#tag_08. See also the GNU libc documentation: https://www.gnu.org/software/libc/manua ... iable.html

Monteggiack
Posts: 1
Joined: Tue Jun 09, 2020 5:24 am

Re: getLocalTime(&local); Definitions of time zones

Postby Monteggiack » Tue Jun 09, 2020 5:26 am

markkuk wrote:
Fri May 22, 2020 9:44 am
The official reference for the TZ setting syntax is in the Single Unix Specification (a.k.a. POSIX) standard: https://pubs.opengroup.org/onlinepubs/9 ... tml#tag_08. See also the GNU libc documentation: https://www.gnu.org/software/libc/manua ... iable.html
Love it thank for the valuable information…

Who is online

Users browsing this forum: Bing [Bot], runeruiter and 89 guests