summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 19:34:56 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 19:34:56 (GMT)
commit68849b544258cafdf42f3ebe9772ee7a346f7147 (patch)
tree908c0d82bd1f423abff08162cc5156f736a016cd /date.c
parent198b0fb635ed8a007bac0c16eab112c5e2c7995c (diff)
downloadgit-68849b544258cafdf42f3ebe9772ee7a346f7147.zip
git-68849b544258cafdf42f3ebe9772ee7a346f7147.tar.gz
git-68849b544258cafdf42f3ebe9772ee7a346f7147.tar.bz2
date handling: handle "AM"/"PM" on time
And be a bitmore careful about matching: if we don't recognize a word or a number, we skip the whole thing, rather than trying the next character in that word/number. Finally: since ctime() adds the final '\n', don't add another one in test-date.
Diffstat (limited to 'date.c')
-rw-r--r--date.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/date.c b/date.c
index 5ee4984..aa4fb3e 100644
--- a/date.c
+++ b/date.c
@@ -114,6 +114,15 @@ static int match_string(const char *date, const char *str)
return i;
}
+static int skip_alpha(const char *date)
+{
+ int i = 0;
+ do {
+ i++;
+ } while (isalpha(date[i]));
+ return i;
+}
+
/*
* Parse month, weekday, or timezone name
*/
@@ -153,8 +162,14 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
}
}
+ if (match_string(date, "PM") == 2) {
+ if (tm->tm_hour > 0 && tm->tm_hour < 12)
+ tm->tm_hour += 12;
+ return 2;
+ }
+
/* BAD CRAP */
- return 0;
+ return skip_alpha(date);
}
static int is_date(int year, int month, int day, struct tm *tm)
@@ -332,14 +347,13 @@ static int match_tz(char *date, int *offp)
* a valid minute. We might want to check that the minutes
* are divisible by 30 or something too.
*/
- if (min >= 60 || n < 3)
- return 0;
+ if (min < 60 && n > 2) {
+ offset = hour*60+min;
+ if (*date == '-')
+ offset = -offset;
- offset = hour*60+min;
- if (*date == '-')
- offset = -offset;
-
- *offp = offset;
+ *offp = offset;
+ }
return end - date;
}