MCPcopy Create free account
hub / github.com/git/git / approxidate_str

Function approxidate_str

date.c:1376–1411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1374}
1375
1376static 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
1413timestamp_t approxidate_careful(const char *date, int *error_ret)
1414{

Callers 1

approxidate_carefulFunction · 0.85

Calls 5

localtime_rFunction · 0.85
pending_numberFunction · 0.85
approxidate_digitFunction · 0.85
approxidate_alphaFunction · 0.85
update_tmFunction · 0.85

Tested by

no test coverage detected