← index #2130Issue #2237
Related · medium · value 0.834
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 · ISSUE

1.8.2 ESP8266 Issues setting RTC

closedby Cabalistopened 2016-07-12updated 2022-06-25
port-esp8266

I am getting some odd behaviour when I try and set the RTC using a time tuple. Code to reproduce:

>>> import machine
>>> import time
>>> time.localtime()
(2000, 1, 1, 0, 0, 17, 5, 1)
>>> rtc = machine.RTC()
>>> rtc.datetime() # 5 hour difference from the time module
(2000, 1, 1, 5, 0, 0, 32, 77)
>>> import ntptime
>>> x = ntptime.time()
>>> x
521665069
>>> time.localtime(x) # This is correct
(2016, 7, 12, 18, 57, 49, 1, 194)
>>> rtc.datetime(time.localtime(x)) # Set RTC with timetuple
>>> rtc.datetime() # Roughly 1 day 5 hours off.
(2016, 7, 14, 3, 9, 49, 11, 925)

Any thoughts? I am building from the source tagged 1.8.2

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