| 1374 | } |
| 1375 | |
| 1376 | static timestamp_t approxidate_str(const char *date, |
| 1377 | const struct timeval *tv, |
| 1378 | int *error_ret) |
| 1379 | { |
| 1380 | int number = 0; |
| 1381 | int touched = 0; |
| 1382 | struct tm tm, now; |
| 1383 | time_t time_sec; |
| 1384 | |
| 1385 | time_sec = tv->tv_sec; |
| 1386 | localtime_r(&time_sec, &tm); |
| 1387 | now = tm; |
| 1388 | |
| 1389 | tm.tm_year = -1; |
| 1390 | tm.tm_mon = -1; |
| 1391 | tm.tm_mday = -1; |
| 1392 | |
| 1393 | for (;;) { |
| 1394 | unsigned char c = *date; |
| 1395 | if (!c) |
| 1396 | break; |
| 1397 | date++; |
| 1398 | if (isdigit(c)) { |
| 1399 | pending_number(&tm, &number); |
| 1400 | date = approxidate_digit(date-1, &tm, &number, time_sec); |
| 1401 | touched = 1; |
| 1402 | continue; |
| 1403 | } |
| 1404 | if (isalpha(c)) |
| 1405 | date = approxidate_alpha(date-1, &tm, &now, &number, &touched); |
| 1406 | } |
| 1407 | pending_number(&tm, &number); |
| 1408 | if (!touched) |
| 1409 | *error_ret = 1; |
| 1410 | return (timestamp_t)update_tm(&tm, &now, 0); |
| 1411 | } |
| 1412 | |
| 1413 | timestamp_t approxidate_careful(const char *date, int *error_ret) |
| 1414 | { |
no test coverage detected