3 static const char *usage_msg = "\n"
4 " test-date show [time_t]...\n"
5 " test-date parse [date]...\n"
6 " test-date approxidate [date]...\n";
8 static void show_dates(char **argv, struct timeval *now)
12 for (; *argv; argv++) {
13 time_t t = atoi(*argv);
14 show_date_relative(t, 0, now, buf, sizeof(buf));
15 printf("%s -> %s\n", *argv, buf);
19 static void parse_dates(char **argv, struct timeval *now)
21 for (; *argv; argv++) {
26 parse_date(*argv, result, sizeof(result));
27 t = strtoul(result, NULL, 0);
28 printf("%s -> %s\n", *argv,
29 t ? show_date(t, 0, DATE_ISO8601) : "bad");
33 static void parse_approxidate(char **argv, struct timeval *now)
35 for (; *argv; argv++) {
37 t = approxidate_relative(*argv, now);
38 printf("%s -> %s\n", *argv, show_date(t, 0, DATE_ISO8601));
42 int main(int argc, char **argv)
47 x = getenv("TEST_DATE_NOW");
53 gettimeofday(&now, NULL);
58 if (!strcmp(*argv, "show"))
59 show_dates(argv+1, &now);
60 else if (!strcmp(*argv, "parse"))
61 parse_dates(argv+1, &now);
62 else if (!strcmp(*argv, "approxidate"))
63 parse_approxidate(argv+1, &now);