Browse Source

lib/timeutils/timeutils: timeutils_mktime may accept negative time values.

And will normalize them.
pull/2147/head
Paul Sokolovsky 9 years ago
parent
commit
993cc3611a
  1. 4
      lib/timeutils/timeutils.c
  2. 4
      lib/timeutils/timeutils.h

4
lib/timeutils/timeutils.c

@ -158,8 +158,8 @@ mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month,
+ (year - 2000) * 31536000;
}
mp_uint_t timeutils_mktime(mp_uint_t year, mp_uint_t month, mp_uint_t mday,
mp_uint_t hours, mp_uint_t minutes, mp_uint_t seconds) {
mp_uint_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) {
// Normalize the tuple. This allows things like:
//

4
lib/timeutils/timeutils.h

@ -49,7 +49,7 @@ 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_uint_t month, mp_uint_t mday,
mp_uint_t hours, mp_uint_t minutes, mp_uint_t seconds);
mp_uint_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);
#endif // __MICROPY_INCLUDED_LIB_TIMEUTILS_H__

Loading…
Cancel
Save