extmod/modutime: Provide a generic time module.

Based on extmod/utime_mphal.c, with:
- a globals dict added
- time.localtime wrapper added
- time.time wrapper added
- time.time_ns function added

New configuration options are added for this module:
- MICROPY_PY_UTIME (enabled at basic features level)
- MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME
- MICROPY_PY_UTIME_TIME_TIME_NS

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2023-03-10 12:16:00 +11:00
parent 083dc1f082
commit 9955553001
19 changed files with 141 additions and 38 deletions

View File

@@ -1468,10 +1468,19 @@ typedef double mp_float_t;
#define MICROPY_PY_USELECT_SELECT (1)
#endif
// Whether to provide "utime" module functions implementation
// in terms of mp_hal_* functions.
#ifndef MICROPY_PY_UTIME_MP_HAL
#define MICROPY_PY_UTIME_MP_HAL (0)
// Whether to provide the "utime" module
#ifndef MICROPY_PY_UTIME
#define MICROPY_PY_UTIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES)
#endif
// Whether to provide utime.gmtime/localtime/mktime functions
#ifndef MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME
#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (0)
#endif
// Whether to provide utime.time/time_ns functions
#ifndef MICROPY_PY_UTIME_TIME_TIME_NS
#define MICROPY_PY_UTIME_TIME_TIME_NS (0)
#endif
// Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()