We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe6756a commit 8175877Copy full SHA for 8175877
1 file changed
unix/modtime.c
@@ -155,8 +155,14 @@ STATIC mp_obj_t mod_time_sleep_us(mp_obj_t arg) {
155
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_us_obj, mod_time_sleep_us);
156
157
STATIC mp_obj_t mod_time_strftime(mp_uint_t n_args, const mp_obj_t *args) {
158
- assert(n_args == 1);
159
- time_t t = time(NULL);
+ time_t t;
+ if (n_args == 1) {
160
+ t = time(NULL);
161
+ } else {
162
+ // CPython requires passing struct tm, but we allow to pass time_t
163
+ // (and don't support struct tm so far).
164
+ t = mp_obj_get_int(args[1]);
165
+ }
166
struct tm *tm = localtime(&t);
167
char buf[32];
168
size_t sz = strftime(buf, sizeof(buf), mp_obj_str_get_str(args[0]), tm);
0 commit comments