← index #2130PR #695
Likely Duplicate · medium · value 1.937
QUERY · ISSUE

Timezone support for "time" module

openby puuuopened 2016-05-30updated 2024-09-29
enhancement

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 .

CANDIDATE · PULL REQUEST

ntptime: Allows manual timezone setting.

closedby Wind-stormgeropened 2023-06-29updated 2023-09-06

Adds only a minimal amount of code, allowing manual setting of the timezone.

Similar to this PR, but it's closed. https://github.com/micropython/micropython-lib/pull/634

2 comments
MrEbbinghaus · 2023-08-31

Same issue as in: https://github.com/micropython/micropython-lib/pull/715
See my comment: https://github.com/micropython/micropython-lib/pull/715#issuecomment-1701200071

projectgus · 2023-09-06

Thanks for submitting this PR. Everyone seems to agree MicroPython should solve this problem, but the best place is probably not in the ntptime module (as NTP itself doesn't know about timezones, and numeric Unix timestamps are generally always in UTC.).

I've started a Discussion here to talk about the possible ways forward for this:
https://github.com/orgs/micropython/discussions/12378

Please feel free to reply there with any other thoughts or suggestions.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied