diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-11-04 17:32:25 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-11-04 17:32:25 +0100 |
commit | 8439e606df3b5b18f5ad7c994211c9aa0c35bae3 (patch) | |
tree | a4be175cec6397ffa1c5f9f4aaca1e1592408305 | |
parent | 9034895827a878c756c58da7136251e3a8668c94 (diff) | |
download | snooze-8439e606df3b5b18f5ad7c994211c9aa0c35bae3.tar.gz snooze-8439e606df3b5b18f5ad7c994211c9aa0c35bae3.tar.xz snooze-8439e606df3b5b18f5ad7c994211c9aa0c35bae3.zip |
Print duration and day of week with -n
-rw-r--r-- | snooze.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/snooze.c b/snooze.c index d7dd67e..73de94e 100644 --- a/snooze.c +++ b/snooze.c @@ -318,8 +318,18 @@ int main(int argc, char *argv[]) /* dry-run, just output the next 5 dates. */ int i; for (i = 0; i < 5; i++) { - if (t > 0) - printf("%s\n", isotime(localtime(&t))); + if (t > 0) { + char weekstr[4]; + struct tm *tm = localtime(&t); + strftime(weekstr, sizeof weekstr, "%a", tm); + printf("%s %s %2ldd%3ldh%3ldm%3lds\n", + isotime(tm), + weekstr, + ((t - now) / (60*60*24)), + ((t - now) / (60*60)) % 24, + ((t - now) / 60) % 60, + (t - now) % 60); + } t = find_next(t + 1); } exit(0); |