summary refs log tree commit diff
path: root/bin
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
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 'bin')
-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;
 	}
le='2019-02-24 14:45:32 -0500'>2019-02-24Use setopt in upJune McEnroe 2019-02-24Add setoptJune McEnroe 2019-02-20Match make targets as TagJune McEnroe 2019-02-20Use $PWD in html.sh to pass absolute path to manJune McEnroe 2019-02-20Factor out html.sh and produce html for all sourcesJune McEnroe 2019-02-20Add Dirk Gently's Holistic Detective AgencyJune McEnroe 2019-02-20Move /opt/pkg after /usr in PATHJune McEnroe 2019-02-20Set man_hard_wrap in nvimJune McEnroe 2019-02-18Use hi -o anchor in upJune McEnroe 2019-02-18Don't match nested parentheses in Tag for CJune McEnroe 2019-02-18Match whitespace between * [] {}June McEnroe 2019-02-18Fix function-like #define regexJune McEnroe 2019-02-18Match Tag in RustJune McEnroe 2019-02-18Match sh functions as TagJune McEnroe 2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe 2019-02-18Match statics and typedefs as TagJune McEnroe 2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe 2019-02-17Always split spans after newlinesJune McEnroe 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe