summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-09-28 19:12:28 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-09-29 01:23:25 (GMT)
commite92a54d99cb36eab6e29069fe3b135e6e6b24f12 (patch)
tree9a5dff3463914a89b8f918df5a8b607a5e021731 /date.c
parent100690b6e8e9cc3cfe2c1d170192b5505d7a2ea8 (diff)
downloadgit-e92a54d99cb36eab6e29069fe3b135e6e6b24f12.zip
git-e92a54d99cb36eab6e29069fe3b135e6e6b24f12.tar.gz
git-e92a54d99cb36eab6e29069fe3b135e6e6b24f12.tar.bz2
Clean up approxidate() in preparation for fixes
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 <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'date.c')
-rw-r--r--date.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/date.c b/date.c
index e387dcd..4ff6604 100644
--- a/date.c
+++ b/date.c
@@ -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;
@@ -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))