38 #ifndef HAVE_STRPTIME_PROTOTYPE
122 for (i = 0; strs[
i] != NULL; ++
i) {
123 int len = strlen (strs[i]);
125 if (strncasecmp (*buf, strs[i], len) == 0) {
145 return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
157 for (; year > 1970; --year)
169 int fday =
first_day (timeptr->tm_year + tm_year_base);
171 timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday;
172 if (timeptr->tm_yday < 0) {
173 timeptr->tm_wday = fday;
174 timeptr->tm_yday = 0;
185 int fday = (
first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
187 timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday;
188 if (timeptr->tm_yday < 0) {
189 timeptr->tm_wday = (fday + 1) % 7;
190 timeptr->tm_yday = 0;
201 int fday = (
first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
207 timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday;
208 if (timeptr->tm_yday < 0) {
209 timeptr->tm_wday = fday;
210 timeptr->tm_yday = 0;
228 while (isspace (*buf))
230 }
else if (c ==
'%' && format[1] !=
'\0') {
232 if (c ==
'E' || c ==
'O')
239 timeptr->tm_wday = ret;
245 timeptr->tm_wday = ret;
251 timeptr->tm_mon = ret;
258 timeptr->tm_mon = ret;
261 ret = strtol (buf, &s, 10);
264 timeptr->tm_year = (ret * 100) - tm_year_base;
270 s =
strptime (buf,
"%m/%d/%y", timeptr);
277 ret = strtol (buf, &s, 10);
280 timeptr->tm_mday = ret;
285 ret = strtol (buf, &s, 10);
288 timeptr->tm_hour = ret;
293 ret = strtol (buf, &s, 10);
297 timeptr->tm_hour = 0;
299 timeptr->tm_hour = ret;
303 ret = strtol (buf, &s, 10);
306 timeptr->tm_yday = ret - 1;
310 ret = strtol (buf, &s, 10);
313 timeptr->tm_mon = ret - 1;
317 ret = strtol (buf, &s, 10);
320 timeptr->tm_min = ret;
333 if (timeptr->tm_hour == 0) {
335 timeptr->tm_hour = 12;
337 timeptr->tm_hour += 12;
340 s =
strptime (buf,
"%I:%M:%S %p", timeptr);
346 s =
strptime (buf,
"%H:%M", timeptr);
352 ret = strtol (buf, &s, 10);
355 timeptr->tm_sec = ret;
366 s =
strptime (buf,
"%H:%M:%S", timeptr);
372 ret = strtol (buf, &s, 10);
375 timeptr->tm_wday = ret - 1;
379 ret = strtol (buf, &s, 10);
382 timeptr->tm_wday = ret;
386 ret = strtol (buf, &s, 10);
393 ret = strtol (buf, &s, 10);
400 ret = strtol (buf, &s, 10);
407 s =
strptime (buf,
"%Y:%m:%d", timeptr);
413 ret = strtol (buf, &s, 10);
417 timeptr->tm_year = 100 + ret;
419 timeptr->tm_year = ret;
423 ret = strtol (buf, &s, 10);
441 if (*buf ==
'%' || *++buf == c)