Code: Select all
mp_obj_t tuple[8] = {
mp_obj_new_int(t.year),
mp_obj_new_int(t.month),
mp_obj_new_int(t.day),
mp_obj_new_int(t.dotw),
mp_obj_new_int(t.hour),
mp_obj_new_int(t.min),
mp_obj_new_int(t.sec),
mp_obj_new_int(0)
};
I hope that helps others who search for the same problem.
And here is how a format conversion works:
Micropython (Epoch/Unix time based on the year 2000)
Code: Select all
>>> t_rtc = rtc.datetime()
>>> t_rtc
(2022, 10, 15, 5, 16, 29, 37, 606547)
>>> t_mktime = (t_rtc[0], t_rtc[1], t_rtc[2], t_rtc[4], t_rtc[5], t_rtc[6], t_rtc[7], t_rtc[3])
>>> t_2000 = time.mktime(t_rtc)
>>> t_2000
719126189
>>> t_1970 = t_2000 + 946684800
>>> t_1970
1665810989
Code: Select all
>>> time.gmtime(1665810989)
time.struct_time(tm_year=2022, tm_mon=10, tm_mday=15, tm_hour=5, tm_min=16, tm_sec=29, tm_wday=5, tm_yday=288, tm_isdst=0)