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.
-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;
 	}
sg'> 2019-12-31Add scoop IRC output formatJune McEnroe 2019-12-31Add scoop output format optionJune McEnroe 2019-12-31Refactor scoop formatters and group colored outputJune McEnroe 2019-12-31Add strftime format string optionJune McEnroe 2019-12-31Refactor binding in scoopJune McEnroe 2019-12-31Add option to group events by contextJune McEnroe 2019-12-31Add missing includeJune McEnroe 2019-12-31Use standout mode for highlightingJune McEnroe 2019-12-31Rewrite scoop(1) argument descriptionsJune McEnroe 2019-12-31Color both nicks in a changeJune McEnroe 2019-12-31Implement nick-colored outputJune McEnroe 2019-12-31Only enable highlighting on terminal outputJune McEnroe 2019-12-31Set up pager pipeJune McEnroe 2019-12-30Normalize date inputJune McEnroe Mostly this just allows the use of 'now'. 2019-12-30Add initial rough version of scoopJune McEnroe 2019-12-30Join with USING wherever possibleJune McEnroe 2019-12-30Add -D flag to prospective scoop manualJune McEnroe 2019-12-30Order results by ID in outer query in litterboxJune McEnroe 2019-12-30Use X macro for Type enumJune McEnroe 2019-12-30Remove scoop -ABCJune McEnroe I can almost get these to work with an inner and outer SQL query, but when contexts starts overlapping it becomes a disaster, so I'm leavin it out at least for now. 2019-12-30Add limit option for litterbox's search query interfaceJune McEnroe