← index #682Issue #2130
Related · high · value 1.724
QUERY · ISSUE

ntptime Feature request: Would like to have the ntp server configurable

openby hagenbuchopened 2023-06-14updated 2023-06-28

The timeserver is hardcoded n ntptime.py:

host = "pool.ntp.org"

I would prefer to have this configurable, for several reasons:

  • There might only be a local network where the node is
  • DNS might not be available in some cases and under some error conditions
  • One might as well use a numeric values
  • Coordinated time might be more important than a real interconnection for embedded devices often involved with logging.

I'm sorry I have no idea (yet) where to start to create a full pull request..

1 comment
massimosala · 2023-06-28

Hi Andreas

It isn't hard-coded.

It is weird they don't put the 'host' as a parameter of the function, but you can do this:

import ntptime
ntptime.host = "your choice"
ntptime.settime()
CANDIDATE · 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 .

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