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

@@ -36,11 +36,17 @@ behave not as expected.
Functions
---------
.. function:: localtime([secs])
.. function:: gmtime([secs])
localtime([secs])
Convert a time expressed in seconds since the Epoch (see above) into an 8-tuple which
contains: (year, month, mday, hour, minute, second, weekday, yearday)
If secs is not provided or None, then the current time from the RTC is used.
Convert the time *secs* expressed in seconds since the Epoch (see above) into an
8-tuple which contains: ``(year, month, mday, hour, minute, second, weekday, yearday)``
If *secs* is not provided or None, then the current time from the RTC is used.
The `gmtime()` function returns a date-time tuple in UTC, and `localtime()` returns a
date-time tuple in local time.
The format of the entries in the 8-tuple are:
* year includes the century (for example 2014).
* month is 1-12