-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
Dates/times must be post 2000/1/1 to work correctly with these simple implementations. Signed-off-by: Damien George <damien@micropython.org>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,12 +52,21 @@ void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, | |
mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month, | ||
mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second); | ||
|
||
mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, | ||
mp_uint_t timeutils_mktime_2000(mp_uint_t year, mp_int_t month, mp_int_t mday, | ||
mp_int_t hours, mp_int_t minutes, mp_int_t seconds); | ||
|
||
// Select the Epoch used by the port. | ||
#if MICROPY_EPOCH_IS_1970 | ||
|
||
static inline void timeutils_seconds_since_epoch_to_struct_time(uint64_t t, timeutils_struct_time_t *tm) { | ||
// TODO this will give incorrect results for dates before 2000/1/1 | ||
return timeutils_seconds_since_2000_to_struct_time(t - TIMEUTILS_SECONDS_1970_TO_2000, tm); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dpgeorge
Author
Member
|
||
} | ||
|
||
static inline uint64_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, mp_int_t hours, mp_int_t minutes, mp_int_t seconds) { | ||
return timeutils_mktime_2000(year, month, mday, hours, minutes, seconds) + TIMEUTILS_SECONDS_1970_TO_2000; | ||
} | ||
|
||
static inline uint64_t timeutils_seconds_since_epoch(mp_uint_t year, mp_uint_t month, | ||
mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second) { | ||
return timeutils_seconds_since_2000(year, month, date, hour, minute, second) + TIMEUTILS_SECONDS_1970_TO_2000; | ||
|
@@ -75,6 +84,7 @@ static inline uint64_t timeutils_nanoseconds_since_epoch_to_nanoseconds_since_19 | |
|
||
#define timeutils_seconds_since_epoch_to_struct_time timeutils_seconds_since_2000_to_struct_time | ||
#define timeutils_seconds_since_epoch timeutils_seconds_since_2000 | ||
#define timeutils_mktime timeutils_mktime_2000 | ||
|
||
static inline uint64_t timeutils_seconds_since_epoch_to_nanoseconds_since_1970(mp_uint_t s) { | ||
return ((uint64_t)s + TIMEUTILS_SECONDS_1970_TO_2000) * 1000000000ULL; | ||
|
This is a
void
function. Should it not be: