33 # define __isleap(year) \
34 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
39 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
41 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
44 #define SECS_PER_HOUR (60 * 60)
45 #define SECS_PER_DAY (SECS_PER_HOUR * 24)
62 date_time->min = rem / 60;
63 date_time->sec = rem % 60;
65 date_time->wday = (4 + days) % 7;
68 #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
69 #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
71 while (days < 0 || days >= (
__isleap (y) ? 366 : 365))
74 uint16_t yg = y + days / 365 - (days % 365 < 0);
77 days -= ((yg - y) * 365
82 date_time->year = y - 1900;
83 if (date_time->year != y - 1900)
89 for (y = 11; days < (uint16_t)ip[y]; --y){
94 date_time->mday = days + 1;
void date_from_timestamp(uint32_t timestamp, DateTimeT *date_time)
#define LEAPS_THRU_END_OF(y)
static const uint16_t __mon_yday[2][13]
Time conversion functions.