]> git.netwichtig.de Git - user/henk/code/snooze.git/commitdiff
Print duration and day of week with -n
authorChristian Neukirchen <chneukirchen@gmail.com>
Wed, 4 Nov 2015 16:32:25 +0000 (17:32 +0100)
committerChristian Neukirchen <chneukirchen@gmail.com>
Wed, 4 Nov 2015 16:32:25 +0000 (17:32 +0100)
snooze.c

index d7dd67e0ccd221c1788b80cded3a4a70a7beeff0..73de94e1d7c5f0f01f53bab263e6f631a00ac81b 100644 (file)
--- 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);