Timezone support for "time" module
From the release notes of MicroPython ESP8266 firmware v1.8 is clear, ntptime only supports UTC. I agree, time zone handling is out of the focus of ntptime. But it would be nice, if ntptime.settime() would support a offset argument, which is be added to ntptime.time() before setting the rtc.
Something like ntptime.settime(offset=2*3600) to provide CEST.
Then, getting the local time is easy as time.localtime() (if #2097 is solved).
I believe, this is a simple api enhancement. Later, a timezone module may calculate the offset by time zone and daylight saving.
I can provide a pull request, but I am not sure about the api and what unit (seconds, minutes or hours) is advisable for the offset. Also the PR may conflict with #2121 .
added timezone support in ntptime
This PR is to add standard timezone support without DST in the micropython ntptime module.
The new addition includes a comprehensive list of timezones. The existing method settime() is modified to take an optional string parameter via which user can specify the required timezone.
Thanks @ljnath
Unfortunately the
ntptimemodule is frozen into many boards by default and needs to be as minimal as possible. We cannot afford to include a full copy of the set of global timezones. Also, to do timezone support properly, the timezone data needs to be dynamic (e.g. daylight saving time).Any timezone support will need to be provided by an optional library that the user can install separately to ntptime.
@jimmo , thank you for your feedback. I will close this PR and will another one with an alternate solution.