3636#include "shared-bindings/time/__init__.h"
3737#include "supervisor/shared/translate.h"
3838
39- #define EPOCH1970_EPOCH2000_DIFF_SECS 946684800
40-
4139//| :mod:`time` --- time and timing related functions
4240//| ========================================================
4341//|
@@ -142,9 +140,9 @@ const mp_obj_namedtuple_type_t struct_time_type_obj = {
142140
143141mp_obj_t struct_time_from_tm (timeutils_struct_time_t * tm ) {
144142 timeutils_struct_time_t tmp ;
145- mp_uint_t secs = timeutils_seconds_since_2000 (tm -> tm_year , tm -> tm_mon , tm -> tm_mday ,
143+ mp_uint_t secs = timeutils_seconds_since_epoch (tm -> tm_year , tm -> tm_mon , tm -> tm_mday ,
146144 tm -> tm_hour , tm -> tm_min , tm -> tm_sec );
147- timeutils_seconds_since_2000_to_struct_time (secs , & tmp );
145+ timeutils_seconds_since_epoch_to_struct_time (secs , & tmp );
148146 tm -> tm_wday = tmp .tm_wday ;
149147 tm -> tm_yday = tmp .tm_yday ;
150148
@@ -202,9 +200,9 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) {
202200STATIC mp_obj_t time_time (void ) {
203201 timeutils_struct_time_t tm ;
204202 struct_time_to_tm (rtc_get_time_source_time (), & tm );
205- mp_uint_t secs = timeutils_seconds_since_2000 (tm .tm_year , tm .tm_mon , tm .tm_mday ,
203+ mp_uint_t secs = timeutils_seconds_since_epoch (tm .tm_year , tm .tm_mon , tm .tm_mday ,
206204 tm .tm_hour , tm .tm_min , tm .tm_sec );
207- return mp_obj_new_int_from_uint (secs + EPOCH1970_EPOCH2000_DIFF_SECS );
205+ return mp_obj_new_int_from_uint (secs );
208206}
209207MP_DEFINE_CONST_FUN_OBJ_0 (time_time_obj , time_time );
210208
@@ -228,7 +226,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
228226 mp_raise_msg (& mp_type_OverflowError , translate ("timestamp out of range for platform time_t" ));
229227
230228 timeutils_struct_time_t tm ;
231- timeutils_seconds_since_2000_to_struct_time (secs - EPOCH1970_EPOCH2000_DIFF_SECS , & tm );
229+ timeutils_seconds_since_epoch_to_struct_time (secs , & tm );
232230
233231 return struct_time_from_tm (& tm );
234232}
@@ -262,7 +260,7 @@ STATIC mp_obj_t time_mktime(mp_obj_t t) {
262260
263261 mp_uint_t secs = timeutils_mktime (mp_obj_get_int (elem [0 ]), mp_obj_get_int (elem [1 ]), mp_obj_get_int (elem [2 ]),
264262 mp_obj_get_int (elem [3 ]), mp_obj_get_int (elem [4 ]), mp_obj_get_int (elem [5 ]));
265- return mp_obj_new_int_from_uint (secs + EPOCH1970_EPOCH2000_DIFF_SECS );
263+ return mp_obj_new_int_from_uint (secs );
266264}
267265MP_DEFINE_CONST_FUN_OBJ_1 (time_mktime_obj , time_mktime );
268266#endif // MICROPY_LONGINT_IMPL
0 commit comments