summaryrefslogtreecommitdiff
path: root/ports/esp8266/modutime.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-03-10 11:13:43 +1100
committerDamien George <damien@micropython.org>2023-04-27 14:55:07 +1000
commit083dc1f08296adc8fa80cbc13a18df8cdd526824 (patch)
tree5074d73afdadb890df96644905263c45a43a7870 /ports/esp8266/modutime.c
parent26cc647fcec3bade2a470097e80b6b9c461f650b (diff)
ports: Use extmod version of mktime instead of port-specific one.
Apart from slight differences in the error message, the functionality of all ports is unchanged. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/esp8266/modutime.c')
-rw-r--r--ports/esp8266/modutime.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/ports/esp8266/modutime.c b/ports/esp8266/modutime.c
index 08508f881..5b784a887 100644
--- a/ports/esp8266/modutime.c
+++ b/ports/esp8266/modutime.c
@@ -77,26 +77,6 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime);
-/// \function mktime()
-/// This is inverse function of localtime. It's argument is a full 8-tuple
-/// which expresses a time as per localtime. It returns an integer which is
-/// the number of seconds since Jan 1, 2000.
-STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
- size_t len;
- mp_obj_t *elem;
- mp_obj_get_array(tuple, &len, &elem);
-
- // localtime generates a tuple of len 8. CPython uses 9, so we accept both.
- if (len < 8 || len > 9) {
- mp_raise_msg_varg(&mp_type_TypeError, MP_ERROR_TEXT("mktime needs a tuple of length 8 or 9 (%d given)"), len);
- }
-
- return mp_obj_new_int_from_uint(timeutils_mktime(mp_obj_get_int(elem[0]),
- mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]), mp_obj_get_int(elem[3]),
- mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5])));
-}
-MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
-
/// \function time()
/// Returns the number of seconds, as an integer, since the Epoch.
STATIC mp_obj_t time_time(void) {
@@ -110,7 +90,7 @@ STATIC const mp_rom_map_elem_t time_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&time_localtime_obj) },
{ MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&time_localtime_obj) },
- { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&time_mktime_obj) },
+ { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mp_utime_mktime_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mp_utime_sleep_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_utime_sleep_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_utime_sleep_us_obj) },