Skip to content

Commit

Permalink
Clean up approxidate() in preparation for fixes
Browse files Browse the repository at this point in the history
Our approxidate cannot handle simple times like "5 PM yesterday", and to
fix that, we will need to add some logic for number handling.  This just
splits that out into a function of its own (the same way the _real_ date
parsing works).

Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Sep 29, 2006
1 parent 100690b commit e92a54d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,15 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)
return end;
}

static const char *approxidate_digit(const char *date, struct tm *tm, int *num)
{
char *end;
unsigned long number = strtoul(date, &end, 10);

*num = number;
return end;
}

unsigned long approxidate(const char *date)
{
int number = 0;
Expand All @@ -731,9 +740,7 @@ unsigned long approxidate(const char *date)
break;
date++;
if (isdigit(c)) {
char *end;
number = strtoul(date-1, &end, 10);
date = end;
date = approxidate_digit(date-1, &tm, &number);
continue;
}
if (isalpha(c))
Expand Down

0 comments on commit e92a54d

Please sign in to comment.