summary refs log tree commit diff
path: root/bin/when.y
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-10-05 23:36:30 -0400
committerJune McEnroe <june@causal.agency>2022-10-05 23:36:30 -0400
commitb8e33ff1f3231aa5dd84b27fc53c8bf4ace2da90 (patch)
tree67300b657124118769e31be7a5c445c7a578abb7 /bin/when.y
parentUpdate "Care" with more on electrolysis (diff)
downloadsrc-b8e33ff1f3231aa5dd84b27fc53c8bf4ace2da90.tar.gz
src-b8e33ff1f3231aa5dd84b27fc53c8bf4ace2da90.zip
Fix same month, different day diffs
This fixes it expressing a 355d difference, for example, as 1y -1m
20d. Just switching to <= would make it express 365d as 12m rather
than 1y.
Diffstat (limited to '')
-rw-r--r--bin/when.y5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/when.y b/bin/when.y
index c94c5514..46651ebb 100644
--- a/bin/when.y
+++ b/bin/when.y
@@ -121,7 +121,10 @@ static struct tm dateDiff(struct tm a, struct tm b) {
 		.tm_mon = a.tm_mon - b.tm_mon,
 		.tm_mday = a.tm_mday - b.tm_mday,
 	};
-	if (a.tm_mon < b.tm_mon) {
+	if (
+		a.tm_mon < b.tm_mon ||
+		(a.tm_mon == b.tm_mon && a.tm_mday < b.tm_mday)
+	) {
 		diff.tm_year--;
 		diff.tm_mon += 12;
 	}
192d066f792c1f2bfbc414c&follow=1'>Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe 2022-02-18Implement new line editing "library"June McEnroe 2022-02-18Simplify cursor positioning in inputJune McEnroe 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe