97strptime(
const char *buf,
const char *fmt,
struct tm *tm)
100 const unsigned char *bp, *ep;
101 int alt_format, i, split_year = 0, neg = 0, offs;
104 bp = (
const u_char *)buf;
106 while (bp != NULL && (c = *fmt++) !=
'\0') {
122again:
switch (c = *fmt++) {
154 new_fmt =
"%m/%d/%y";
159 new_fmt =
"%Y-%m-%d";
169 new_fmt =
"%I:%M:S %p";
174 new_fmt =
"%H:%M:%S";
188 bp = (
const u_char *)
strptime((
const char *)bp,
198 bp = find_string(bp, &tm->tm_wday, day, abday, 7);
205 bp = find_string(bp, &tm->tm_mon, mon, abmon, 12);
211 bp = conv_num(bp, &i, 0, 99);
213 i = i * 100 - TM_YEAR_BASE;
215 i += tm->tm_year % 100;
223 bp = conv_num(bp, &tm->tm_mday, 1, 31);
231 bp = conv_num(bp, &tm->tm_hour, 0, 23);
239 bp = conv_num(bp, &tm->tm_hour, 1, 12);
240 if (tm->tm_hour == 12)
247 bp = conv_num(bp, &i, 1, 366);
253 bp = conv_num(bp, &tm->tm_min, 0, 59);
259 bp = conv_num(bp, &i, 1, 12);
265 bp = find_string(bp, &i, am_pm, NULL, 2);
266 if (tm->tm_hour > 11)
268 tm->tm_hour += i * 12;
273 bp = conv_num(bp, &tm->tm_sec, 0, 61);
278#define TIME_MAX INT64_MAX
285 if (*bp <
'0' || *bp >
'9') {
294 }
while (((uint64_t)sse * 10 <=
TIME_MAX) &&
295 rulim && *bp >=
'0' && *bp <=
'9');
297 if (sse < 0 || (uint64_t)sse >
TIME_MAX) {
302 tm = localtime(&sse);
316 bp = conv_num(bp, &i, 0, 53);
321 bp = conv_num(bp, &tm->tm_wday, 0, 6);
326 bp = conv_num(bp, &i, 1, 7);
334 bp = conv_num(bp, &i, 0, 99);
342 while (isdigit(*bp));
346 bp = conv_num(bp, &i, 0, 53);
351 bp = conv_num(bp, &i, 0, 9999);
352 tm->tm_year = i - TM_YEAR_BASE;
358 bp = conv_num(bp, &i, 0, 99);
362 i += (tm->tm_year / 100) * 100;
366 i = i + 2000 - TM_YEAR_BASE;
368 i = i + 1900 - TM_YEAR_BASE;
375 if (strncasecmp((
const char *)bp, gmt, 3) == 0
376 || strncasecmp((
const char *)bp, utc, 3) == 0) {
386 ep = find_string(bp, &i,
388 (
const char *
const *)_tzname,
390 (
const char *
const *)tzname,
396 tm->TM_GMTOFF = -(timezone);
399 tm->TM_ZONE = tzname[i];
453 ep = find_string(bp, &i, nast, NULL, 4);
456 tm->TM_GMTOFF = -5 - i;
459 tm->TM_ZONE = __UNCONST(nast[i]);
464 ep = find_string(bp, &i, nadt, NULL, 4);
468 tm->TM_GMTOFF = -4 - i;
471 tm->TM_ZONE = __UNCONST(nadt[i]);
477 if ((*bp >=
'A' && *bp <=
'I') ||
478 (*bp >=
'L' && *bp <=
'Y')) {
481 if (*bp >=
'A' && *bp <=
'I')
483 (
'A' - 1) - (
int)*bp;
484 else if (*bp >=
'L' && *bp <=
'M')
485 tm->TM_GMTOFF =
'A' - (int)*bp;
486 else if (*bp >=
'N' && *bp <=
'Y')
487 tm->TM_GMTOFF = (int)*bp -
'M';
498 for (i = 0; i < 4;) {
500 offs = offs * 10 + (*bp++ -
'0');
504 if (i == 2 && *bp ==
':') {
519 offs = (offs / 100) * 100 + (i * 50) / 30;
528 tm->TM_GMTOFF = offs;