X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=date.c;h=00f9eb5d0b9730107a8e08e92eb04d4cc9233595;hb=21746aa34fc99d2c73634bc9829387c27c109dbe;hp=68cdcaa3f6268855539fcae02c8e87b965204b4d;hpb=ba4d01bd74edae1e4adb540a03ba17961f8dd4b2;p=git.git diff --git a/date.c b/date.c index 68cdcaa3f..00f9eb5d0 100644 --- a/date.c +++ b/date.c @@ -586,7 +586,7 @@ static int date_string(unsigned long date, int offset, char *buf, int len) /* Gr. strptime is crap for this; it doesn't have a way to require RFC2822 (i.e. English) day/month names, and it doesn't work correctly with %z. */ -int parse_date_toffset(const char *date, unsigned long *timestamp, int *offset) +int parse_date_basic(const char *date, unsigned long *timestamp, int *offset) { struct tm tm; int tm_gmt; @@ -635,24 +635,23 @@ int parse_date_toffset(const char *date, unsigned long *timestamp, int *offset) /* mktime uses local timezone */ *timestamp = tm_to_time_t(&tm); if (*offset == -1) - *offset = (*timestamp - mktime(&tm)) / 60; + *offset = ((time_t)*timestamp - mktime(&tm)) / 60; if (*timestamp == -1) return -1; if (!tm_gmt) *timestamp -= *offset * 60; - return 1; /* success */ + return 0; /* success */ } int parse_date(const char *date, char *result, int maxlen) { unsigned long timestamp; int offset; - if (parse_date_toffset(date, ×tamp, &offset) > 0) - return date_string(timestamp, offset, result, maxlen); - else + if (parse_date_basic(date, ×tamp, &offset)) return -1; + return date_string(timestamp, offset, result, maxlen); } enum date_mode parse_date_format(const char *format) @@ -1004,9 +1003,8 @@ unsigned long approxidate_relative(const char *date, const struct timeval *tv) int offset; int errors = 0; - if (parse_date_toffset(date, ×tamp, &offset) > 0) + if (!parse_date_basic(date, ×tamp, &offset)) return timestamp; - return approxidate_str(date, tv, &errors); } @@ -1019,7 +1017,7 @@ unsigned long approxidate_careful(const char *date, int *error_ret) if (!error_ret) error_ret = &dummy; - if (parse_date_toffset(date, ×tamp, &offset) > 0) { + if (!parse_date_basic(date, ×tamp, &offset)) { *error_ret = 0; return timestamp; }