Skip to content

Commit

Permalink
date.c: improve guess between timezone offset and year.
Browse files Browse the repository at this point in the history
When match_digit() guesses a four-digit string to tell if it is
a year or a timezone, it did not consider that some real-world
places have UTC offsets equal to +1400.

   $ date; TZ=UTC0 date; TZ=Pacific/Kiritimati date
   Wed Jun  7 23:25:42 PDT 2006
   Thu Jun  8 06:25:42 UTC 2006
   Thu Jun  8 20:25:42 LINT 2006

Signed-off-by: Paul Eggert <eggert@CS.UCLA.EDU>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
eggert authored and Junio C Hamano committed Jun 9, 2006
1 parent 7612a1e commit 7122f82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion date.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt

/* Four-digit year or a timezone? */
if (n == 4) {
if (num <= 1200 && *offset == -1) {
if (num <= 1400 && *offset == -1) {
unsigned int minutes = num % 100;
unsigned int hours = num / 100;
*offset = hours*60 + minutes;
Expand Down

0 comments on commit 7122f82

Please sign in to comment.