When 29f4332e66 (Quit passing 'now' to date code, 2019-09-11) removed its timeval parameter, approxidate_relative() became equivalent to approxidate(). Convert its last two call sites and remove the redundant function. Signed-off-by: René Scharfe <l.s.r@xxxxxx> --- Formatted with -U16 for easier review. Only useful in date.c, but cannot be restricted to just one file. date.c | 14 -------------- date.h | 1 - t/helper/test-date.c | 4 ++-- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/date.c b/date.c index 1fb2cd1b53..7c8650f799 100644 --- a/date.c +++ b/date.c @@ -1353,46 +1353,32 @@ static timestamp_t approxidate_str(const char *date, date++; if (isdigit(c)) { pending_number(&tm, &number); date = approxidate_digit(date-1, &tm, &number, time_sec); touched = 1; continue; } if (isalpha(c)) date = approxidate_alpha(date-1, &tm, &now, &number, &touched); } pending_number(&tm, &number); if (!touched) *error_ret = 1; return (timestamp_t)update_tm(&tm, &now, 0); } -timestamp_t approxidate_relative(const char *date) -{ - struct timeval tv; - timestamp_t timestamp; - int offset; - int errors = 0; - - if (!parse_date_basic(date, ×tamp, &offset)) - return timestamp; - - get_time(&tv); - return approxidate_str(date, (const struct timeval *) &tv, &errors); -} - timestamp_t approxidate_careful(const char *date, int *error_ret) { struct timeval tv; timestamp_t timestamp; int offset; int dummy = 0; if (!error_ret) error_ret = &dummy; if (!parse_date_basic(date, ×tamp, &offset)) { *error_ret = 0; return timestamp; } get_time(&tv); return approxidate_str(date, &tv, error_ret); diff --git a/date.h b/date.h index 5d4eaba0a9..6136212a19 100644 --- a/date.h +++ b/date.h @@ -55,20 +55,19 @@ const char *show_date(timestamp_t time, int timezone, const struct date_mode *mo */ void parse_date_format(const char *format, struct date_mode *mode); /** * Release a "struct date_mode", currently only required if * parse_date_format() has parsed a "DATE_STRFTIME" format. */ void date_mode_release(struct date_mode *mode); void show_date_relative(timestamp_t time, struct strbuf *timebuf); int parse_date(const char *date, struct strbuf *out); int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset); int parse_expiry_date(const char *date, timestamp_t *timestamp); void datestamp(struct strbuf *out); #define approxidate(s) approxidate_careful((s), NULL) timestamp_t approxidate_careful(const char *, int *); -timestamp_t approxidate_relative(const char *date); int date_overflows(timestamp_t date); time_t tm_to_time_t(const struct tm *tm); #endif diff --git a/t/helper/test-date.c b/t/helper/test-date.c index cd6a6df702..2d9232cc68 100644 --- a/t/helper/test-date.c +++ b/t/helper/test-date.c @@ -68,42 +68,42 @@ static void parse_dates(const char **argv) strbuf_reset(&result); parse_date(*argv, &result); if (sscanf(result.buf, "%"PRItime" %d", &t, &tz) == 2) printf("%s -> %s\n", *argv, show_date(t, tz, DATE_MODE(ISO8601))); else printf("%s -> bad\n", *argv); } strbuf_release(&result); } static void parse_approxidate(const char **argv) { for (; *argv; argv++) { timestamp_t t; - t = approxidate_relative(*argv); + t = approxidate(*argv); printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601))); } } static void parse_approx_timestamp(const char **argv) { for (; *argv; argv++) { timestamp_t t; - t = approxidate_relative(*argv); + t = approxidate(*argv); printf("%s -> %"PRItime"\n", *argv, t); } } static void getnanos(const char **argv) { double seconds = getnanotime() / 1.0e9; if (*argv) seconds -= strtod(*argv, NULL); printf("%lf\n", seconds); } int cmd__date(int argc UNUSED, const char **argv) { const char *x; -- 2.40.0