summary refs log tree commit diff
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
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;
 	}
03:24:00 -0500'>2020-03-03Don't use $ inside $(())June McEnroe 2020-03-03Remove setoptJune McEnroe 2020-03-03Use getopts in shell scriptsJune McEnroe 2020-02-27Style %T outside of Rs in italicJune McEnroe 2020-02-26Add Fierce Femmes and Notorious LiarsJune McEnroe 2020-02-23Add This Is How You Lose the Time WarJune McEnroe 2020-02-22Add See Ya LaterJune McEnroe 2020-02-20Remove wiki scriptJune McEnroe 2020-02-19Add The Obelisk GateJune McEnroe 2020-02-17Add Four Tet — HandsJune McEnroe 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe 2020-01-28Change scout sensitivity to 1.4June McEnroe 2020-01-28Import shows.txtJune McEnroe