Skip to content

fix(utime.c): make set_time correctly subtract TZONE_OFFSET

Ferdinand Bachmann requested to merge (removed):master into master

there were two bugs in set_time:

  • TZONE_OFFSET is not multiplied by 1000, even though epic_rtc_set_milliseconds was used.
  • TZONE_OFFSET is added in both time and set_time. set_time should subtract the timezone offset.

Testcase:

import utime

old = utime.time()
utime.set_time(old)
new = utime.time()

if old != new:
  print("time difference:", new - old)
  # will print 7607, or 2.11 hours with the old code
  # should print 0 or 1 at most
Edited by Ferdinand Bachmann

Merge request reports