time: Allow constructing a struct_time from another struct_time
Closes: #4917
This commit is contained in:
parent
33482e0831
commit
cac71a33fc
@ -83,12 +83,10 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp
|
||||
if (n_args != 1 || (kw_args != NULL && kw_args->used > 0)) {
|
||||
return namedtuple_make_new(type, n_args, args, kw_args);
|
||||
}
|
||||
if (mp_obj_get_type(args[0])->getiter != mp_obj_tuple_getiter || ((mp_obj_tuple_t *)MP_OBJ_TO_PTR(args[0]))->len != 9) {
|
||||
mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence"));
|
||||
}
|
||||
|
||||
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(args[0]);
|
||||
return namedtuple_make_new(type, 9, tuple->items, NULL);
|
||||
size_t len;
|
||||
mp_obj_t *items;
|
||||
mp_obj_get_array(args[0], &len, &items);
|
||||
return namedtuple_make_new(type, len, items, NULL);
|
||||
}
|
||||
|
||||
//| class struct_time:
|
||||
|
Loading…
Reference in New Issue
Block a user