Hi all -
Today I began working with maintaining wall time on the ESP32. Connecting to an NTP server was a breeze, but now I'm faced with the prospect of managing time zone settings. Various Google efforts haven't turned up much, so I figured I'd ask what other people use for this.
I'm specifically interested in two things:
1. is there an facility for easing the construction of strings like "PST8PDT,M3.2.0/2,M11.1.0" for time zone management?
2. does FreeRTOS have the ability to manage DST automatically? (If it doesn't, perhaps question 1 is moot.)
Thanks...
[resolved] what do you use for timezone management?
[resolved] what do you use for timezone management?
Last edited by mzimmers on Thu Jun 11, 2020 3:25 pm, edited 1 time in total.
Re: what do you use for timezone management?
We're having the same issue. Unable to find a simple library to convert something like USA/NewYork to posix timezone strings. It seems that bigger systems use the tzdata and full library, but that is too large for ESP32. Could probably parse the tzdata files to extract what we need, and wrap it in a library, but can't understand why this problem isn't solved (or the solution isn't easy to find).
Re: what do you use for timezone management?
You can take the standard tzdata database, then use something like https://github.com/nayarsystems/posix_tz_db to convert timezone rules into glibc TZ format.
Depending on the product market, filter out the locations/rules which you don't need.
Load the remaining rules (i.e. "location","TZ rule" pairs) into the firmware, either embedding the file directly into the app binary, or into some file system partition.
Let the user choose the location in device configuration UI, if one exists. Save TZ for chosen location into NVS.
Load TZ from NVS on startup and call setenv/tzset to apply the rule.
> does FreeRTOS have the ability to manage DST automatically? (If it doesn't, perhaps question 1 is moot.)
FreeRTOS doesn't, but then FreeRTOS does not deal with time at all (aside from maintaining a 32-bit unsigned tick counter). TZ strings include information about DST rules, and newlib will apply DST correction according to these rules.
Depending on the product market, filter out the locations/rules which you don't need.
Load the remaining rules (i.e. "location","TZ rule" pairs) into the firmware, either embedding the file directly into the app binary, or into some file system partition.
Let the user choose the location in device configuration UI, if one exists. Save TZ for chosen location into NVS.
Load TZ from NVS on startup and call setenv/tzset to apply the rule.
> does FreeRTOS have the ability to manage DST automatically? (If it doesn't, perhaps question 1 is moot.)
FreeRTOS doesn't, but then FreeRTOS does not deal with time at all (aside from maintaining a 32-bit unsigned tick counter). TZ strings include information about DST rules, and newlib will apply DST correction according to these rules.
Re: what do you use for timezone management?
I've forked this repository and made a minimal embedded-friendly library based on it. You could find it at https://github.com/jdlambert/posix_tz_db/tree/embedded.You can take the standard tzdata database, then use something like https://github.com/nayarsystems/posix_tz_db to convert timezone rules into glibc TZ format.
Who is online
Users browsing this forum: Baidu [Spider] and 97 guests