From 5d52752e0cb715a1af4095c890dc623ce369f1ac Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 29 Mar 2022 19:08:36 -0400 Subject: main: If debugging, print formatted time Not seconds since Epoch. --- diff --git a/TODO b/TODO index a4e3da6..0a038a3 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -if -d, printf() parsed time, not diff from epoch drop timegm() try to fix dst bug test with other libc's (newlib? musl? fbsd? obsd?) diff --git a/src/main.c b/src/main.c index 93689d3..3ce51dc 100644 --- a/src/main.c +++ b/src/main.c @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -274,8 +273,13 @@ main(int argc, char * const argv[]) #if defined(ENABLE_TESTS) && ENABLE_TESTS if (dbg == true) { - dif = datetime_diff_epoch(arg); - printf("%" PRId64 "\n", (int64_t) dif); + printf("%04d-%02d-%02d %02d:%02d:%02d\n", + arg_tm.tm_year + 1900, + arg_tm.tm_mon + 1, + arg_tm.tm_mday, + arg_tm.tm_hour, + arg_tm.tm_min, + arg_tm.tm_sec); return EXIT_SUCCESS; } #endif diff --git a/tests/parse.sh b/tests/parse.sh index 1150f28..a3b1f26 100755 --- a/tests/parse.sh +++ b/tests/parse.sh @@ -51,13 +51,13 @@ run_test() got="$(TZ=UTC0 "${TOP_BUILDDIR}/@" -d '1969-12-31 23:59:30' \ "${datetime}" 2>&1)" || : - if [ x"${got}" = x'0' ]; then + if [ x"${got}" = x'1970-01-01 00:00:00' ]; then ok_ -- "${datetime}" else not_ok_ -- "${datetime}" diag_ " Failed test '${datetime}'" diag_ " got: '${got}'" - diag_ " expected: '0'" + diag_ " expected: '1970-01-01 00:00:00'" fi } -- cgit v0.9.1