summary refs log tree commit diff
diff options
context:
space:
mode:
authoralice.postfix <alice.git@postovskiy.net>2026-10-27 15:41:03 +0100
committerJune McEnroe <june@causal.agency>2026-10-27 11:01:12 -0400
commit310c512f92ea3dadc48f13a5af17aef9fd05731f (patch)
tree06ee42db60a8466f82d1fa3a3b440d9c355ecf67
parentAdd The Melancholy of Resistance (diff)
downloadsrc-master.tar.gz
src-master.zip
Allow M/D, Y/M/D, and Y-M-D dates HEAD master
-rw-r--r--bin/man1/when.19
-rw-r--r--bin/when.y3
2 files changed, 11 insertions, 1 deletions
diff --git a/bin/man1/when.1 b/bin/man1/when.1
index 3f2735f7..67b3e37a 100644
--- a/bin/man1/when.1
+++ b/bin/man1/when.1
@@ -1,4 +1,4 @@
-.Dd September 19, 2022
+.Dd October 27, 2026
 .Dt WHEN 1
 .Os
 .
@@ -42,6 +42,13 @@ A full date,
 or a date in the current year.
 Months can be abbreviated to three letters.
 .
+.It Oo Ar year Ns Sy / Oc Ns Ar month Ns Sy / Ns Ar date
+A full date in numbers,
+or a date in the current year.
+.
+.It Ar year Ns Sy - Ns Ar month Ns Sy - Ns Ar date
+A full date in numbers.
+.
 .It Ar day
 A day of the week
 in the current week.
diff --git a/bin/when.y b/bin/when.y
index 6517da32..4fe3156b 100644
--- a/bin/when.y
+++ b/bin/when.y
@@ -238,7 +238,10 @@ dateLit:
 	{ $$ = today(); }
 	| '.' { $$ = today(); }
 	| Month Number { $$ = monthDay($1.tm_mon, $2.tm_sec); }
+	| Number '/' Number { $$ = monthDay($1.tm_sec - 1, $3.tm_sec); }
 	| Month Number Number { $$ = monthDayYear($1.tm_mon, $2.tm_sec, $3.tm_sec); }
+	| Number '/' Number '/' Number { $$ = monthDayYear($3.tm_sec - 1, $5.tm_sec, $1.tm_sec); }
+	| Number '-' Number '-' Number { $$ = monthDayYear($3.tm_sec - 1, $5.tm_sec, $1.tm_sec); }
 	| Day { $$ = weekDay($1.tm_wday); }
 	;