40#pragma GCC diagnostic push
42#pragma clang diagnostic ignored "-Wreserved-id-macro"
45#define _SEC_IN_MINUTE 60L
46#define _SEC_IN_HOUR 3600L
47#define _SEC_IN_DAY 86400L
50 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
52#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])
55 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
57#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))
58#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365)
60#pragma GCC diagnostic pop
85 days += tim_p->tm_mday - 1;
87 if (tim_p->tm_mon > 1 &&
_DAYS_IN_YEAR (tim_p->tm_year) == 366)
91 tim_p->tm_yday = (int)days;
93 if (tim_p->tm_year > 10000 || tim_p->tm_year < -10000)
97 if ((year = tim_p->tm_year) > 70)
99 for (year = 70; year < tim_p->tm_year; year++)
104 for (year = 69; year > tim_p->tm_year; year--)
113 if ((tim_p->tm_wday = (
int)((days + 4) % 7)) < 0)
127 int days_in_feb = 28;
130 if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59)
132 res = div (tim_p->tm_sec, 60);
133 tim_p->tm_min += res.quot;
134 if ((tim_p->tm_sec = res.rem) < 0)
141 if (tim_p->tm_min < 0 || tim_p->tm_min > 59)
143 res = div (tim_p->tm_min, 60);
144 tim_p->tm_hour += res.quot;
145 if ((tim_p->tm_min = res.rem) < 0)
152 if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23)
154 res = div (tim_p->tm_hour, 24);
155 tim_p->tm_mday += res.quot;
156 if ((tim_p->tm_hour = res.rem) < 0)
158 tim_p->tm_hour += 24;
163 if (tim_p->tm_mon < 0 || tim_p->tm_mon > 11)
165 res = div (tim_p->tm_mon, 12);
166 tim_p->tm_year += res.quot;
167 if ((tim_p->tm_mon = res.rem) < 0)
177 if (tim_p->tm_mday <= 0)
179 while (tim_p->tm_mday <= 0)
181 if (--tim_p->tm_mon == -1)
185 days_in_feb = ((
_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? 29 : 28);
195 if (++tim_p->tm_mon == 12)
199 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)