summary refs log tree commit diff
path: root/bin/when.y
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-09-19 20:58:21 -0400
committerJune McEnroe <june@causal.agency>2022-09-19 20:58:21 -0400
commit4aa4e5d9b13190e94fe97664598f2dc70187a889 (patch)
tree14a28c7115c4527ede342515b0d97ec7549dffec /bin/when.y
parentPublish Apologies (diff)
downloadsrc-4aa4e5d9b13190e94fe97664598f2dc70187a889.tar.gz
src-4aa4e5d9b13190e94fe97664598f2dc70187a889.zip
Add when - to print all named dates
Diffstat (limited to '')
-rw-r--r--bin/when.y12
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/when.y b/bin/when.y
index 69ccc343..c94c5514 100644
--- a/bin/when.y
+++ b/bin/when.y
@@ -319,8 +319,16 @@ int main(int argc, char *argv[]) {
 	}
 
 	if (argc > 1) {
-		input = argv[1];
-		return yyparse();
+		if (strcmp(argv[1], "-")) {
+			input = argv[1];
+			return yyparse();
+		} else {
+			for (size_t i = 0; i < dates.len; ++i) {
+				printf("%s: ", dates.ptr[i].tm_zone);
+				printScalar(dateDiff(today(), dates.ptr[i]));
+			}
+			return EX_OK;
+		}
 	}
 
 	struct tm date = today();