diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-04-13 20:22:42 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-15 10:12:19 -0700 |
commit | e6e7530d10b74d763b4311ea93e0a831b810d6c2 (patch) | |
tree | 7ac83d3fecd39d6076f24eaddd6719a24c3b6ce8 /test-date.c | |
parent | 7897d84b8240720352e23030c35db461581b68e3 (diff) | |
download | git-e6e7530d10b74d763b4311ea93e0a831b810d6c2.tar.gz |
test helpers: move test-* to t/helper/ subdirectory
This keeps top dir a bit less crowded. And because these programs are
for testing purposes, it makes sense that they stay somewhere in t/
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-date.c')
-rw-r--r-- | test-date.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/test-date.c b/test-date.c deleted file mode 100644 index 63f373557e..0000000000 --- a/test-date.c +++ /dev/null @@ -1,73 +0,0 @@ -#include "cache.h" - -static const char *usage_msg = "\n" -" test-date show [time_t]...\n" -" test-date parse [date]...\n" -" test-date approxidate [date]...\n"; - -static void show_dates(char **argv, struct timeval *now) -{ - struct strbuf buf = STRBUF_INIT; - - for (; *argv; argv++) { - time_t t = atoi(*argv); - show_date_relative(t, 0, now, &buf); - printf("%s -> %s\n", *argv, buf.buf); - } - strbuf_release(&buf); -} - -static void parse_dates(char **argv, struct timeval *now) -{ - struct strbuf result = STRBUF_INIT; - - for (; *argv; argv++) { - unsigned long t; - int tz; - - strbuf_reset(&result); - parse_date(*argv, &result); - if (sscanf(result.buf, "%lu %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(char **argv, struct timeval *now) -{ - for (; *argv; argv++) { - time_t t; - t = approxidate_relative(*argv, now); - printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601))); - } -} - -int main(int argc, char **argv) -{ - struct timeval now; - const char *x; - - x = getenv("TEST_DATE_NOW"); - if (x) { - now.tv_sec = atoi(x); - now.tv_usec = 0; - } - else - gettimeofday(&now, NULL); - - argv++; - if (!*argv) - usage(usage_msg); - if (!strcmp(*argv, "show")) - show_dates(argv+1, &now); - else if (!strcmp(*argv, "parse")) - parse_dates(argv+1, &now); - else if (!strcmp(*argv, "approxidate")) - parse_approxidate(argv+1, &now); - else - usage(usage_msg); - return 0; -} |