ports: Add utime.gmtime() function.

To portably get the Epoch.  This is simply aliased to localtime() on ports
that are not timezone aware.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2020-09-14 00:07:12 +10:00
parent b28758054b
commit bd7af6151d
7 changed files with 28 additions and 9 deletions

View File

@@ -29,12 +29,11 @@ def time():
return val - NTP_DELTA
# There's currently no timezone support in MicroPython, so
# utime.localtime() will return UTC time (as if it was .gmtime())
# There's currently no timezone support in MicroPython, and the RTC is set in UTC time.
def settime():
t = time()
import machine
import utime
tm = utime.localtime(t)
tm = utime.gmtime(t)
machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6] + 1, tm[3], tm[4], tm[5], 0))