← index #7137PR #545
Off-topic · high · value 0.940
QUERY · ISSUE

ntptime.py settime() does not cope with errors

openby peterhinchopened 2021-04-20updated 2022-07-31

This arose in the forum.

If an exception occurs in the time() function, msg is not updated so a value of -NTP_DELTA is returned. If this is the intended mechanism for reporting exceptions, settime() should check for this and avoid updating the RTC.

Or perhaps the finally clause in time() should re-raise the exception?

CANDIDATE · PULL REQUEST

added timezone support in ntptime

closedby ljnathopened 2022-10-07updated 2022-10-09

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.

2 comments
jimmo · 2022-10-07

Thanks @ljnath

Unfortunately the ntptime module 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.

ljnath · 2022-10-09

@jimmo , thank you for your feedback. I will close this PR and will another one with an alternate solution.

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