25#pragma GCC diagnostic push
27#pragma clang diagnostic ignored "-Wreserved-id-macro"
30#define _SEC_IN_MINUTE 60L
31#define _SEC_IN_HOUR 3600L
32#define _SEC_IN_DAY 86400L
35 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
37#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])
39#pragma GCC diagnostic push
41#pragma clang diagnostic ignored "-Wreserved-identifier"
44 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
45#pragma GCC diagnostic pop
47#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))
48#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365)
50#pragma GCC diagnostic pop
75 days += tim_p->tm_mday - 1;
77 if (tim_p->tm_mon > 1 &&
_DAYS_IN_YEAR (tim_p->tm_year) == 366)
81 tim_p->tm_yday = (int)days;
83 if (tim_p->tm_year > 10000 || tim_p->tm_year < -10000)
87 if ((year = tim_p->tm_year) > 70)
89 for (year = 70; year < tim_p->tm_year; year++)
94 for (year = 69; year > tim_p->tm_year; year--)
103 if ((tim_p->tm_wday = (
int)((days + 4) % 7)) < 0)
117 int days_in_feb = 28;
119#pragma GCC diagnostic push
120#if defined(__clang__)
121#elif defined(__GNUC__)
123#pragma GCC diagnostic ignored "-Waggregate-return"
126 if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59)
128 res = div (tim_p->tm_sec, 60);
129 tim_p->tm_min += res.quot;
130 if ((tim_p->tm_sec = res.rem) < 0)
137 if (tim_p->tm_min < 0 || tim_p->tm_min > 59)
139 res = div (tim_p->tm_min, 60);
140 tim_p->tm_hour += res.quot;
141 if ((tim_p->tm_min = res.rem) < 0)
148 if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23)
150 res = div (tim_p->tm_hour, 24);
151 tim_p->tm_mday += res.quot;
152 if ((tim_p->tm_hour = res.rem) < 0)
154 tim_p->tm_hour += 24;
159 if (tim_p->tm_mon < 0 || tim_p->tm_mon > 11)
161 res = div (tim_p->tm_mon, 12);
162 tim_p->tm_year += res.quot;
163 if ((tim_p->tm_mon = res.rem) < 0)
169#pragma GCC diagnostic pop
174 if (tim_p->tm_mday <= 0)
176 while (tim_p->tm_mday <= 0)
178 if (--tim_p->tm_mon == -1)
182 days_in_feb = ((
_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? 29 : 28);
192 if (++tim_p->tm_mon == 12)
196 days_in_feb = ((
_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? 29 : 28);
static void validate_structure(struct tm *tim_p)
static const int DAYS_IN_MONTH[12]
#define _DAYS_IN_YEAR(year)
static const int _DAYS_BEFORE_MONTH[12]
#define _DAYS_IN_MONTH(x)
time_t timegm(struct tm *tim_p)