8000 shared/timeutils: Document the range of year/month/day etc input values. · micropython/micropython@43bd57f · GitHub
[go: up one dir, main page]

Skip to content

Commit 43bd57f

Browse files
committed
shared/timeutils: Document the range of year/month/day etc input values.
These differ to, eg, the standard `mktime()` function. Signed-off-by: Damien George <damien@micropython.org>
1 parent 078ead2 commit 43bd57f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

shared/timeutils/timeutils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t date);
4949
void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t,
5050
timeutils_struct_time_t *tm);
5151

52+
// Year is absolute, month/date are 1-based, hour/minute/second are 0-based.
5253
mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month,
5354
mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second);
5455

56+
// Year is absolute, month/mday are 1-based, hours/minutes/seconds are 0-based.
5557
mp_uint_t timeutils_mktime_2000(mp_uint_t year, mp_int_t month, mp_int_t mday,
5658
mp_int_t hours, mp_int_t minutes, mp_int_t seconds);
5759

@@ -63,10 +65,12 @@ static inline void timeutils_seconds_since_epoch_to_struct_time(uint64_t t, time
6365
timeutils_seconds_since_2000_to_struct_time(t - TIMEUTILS_SECONDS_1970_TO_2000, tm);
6466
}
6567

68+
// Year is absolute, month/mday are 1-based, hours/minutes/seconds are 0-based.
6669
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) {
6770
return timeutils_mktime_2000(year, month, mday, hours, minutes, seconds) + TIMEUTILS_SECONDS_1970_TO_2000;
6871
}
6972

73+
// Year is absolute, month/date are 1-based, hour/minute/second are 0-based.
7074
static inline uint64_t timeutils_seconds_since_epoch(mp_uint_t year, mp_uint_t month,
7175
mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second) {
7276
// TODO this will give incorrect results for dates before 2000/1/1

0 commit comments

Comments
 (0)
0