summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-04-27 19:02:07 -0400
committerJune McEnroe <june@causal.agency>2021-04-27 19:02:07 -0400
commit0e7a232b4fec24afc880a7f1c79f54103b4a694f (patch)
tree651c8c48610bf7153e88da5340cc7dc895f349ec
parentUse QueryCap for select (diff)
downloadlitterbox-0e7a232b4fec24afc880a7f1c79f54103b4a694f.tar.gz
litterbox-0e7a232b4fec24afc880a7f1c79f54103b4a694f.zip
Interpret -D, -a, -b as local time with -L
-rw-r--r--scoop.110
-rw-r--r--scoop.c38
2 files changed, 41 insertions, 7 deletions
diff --git a/scoop.1 b/scoop.1
index 51ad6c7..1a66040 100644
--- a/scoop.1
+++ b/scoop.1
@@ -1,4 +1,4 @@
-.Dd May 20, 2020
+.Dd April 27, 2021
 .Dt SCOOP 1
 .Os
 .
@@ -68,7 +68,13 @@ see
 The default format is ISO 8601.
 .
 .It Fl L
-Output timestamps in local time.
+Output timestamps in local time
+and interpret timestamps in
+.Fl D ,
+.Fl a
+and
+.Fl b
+as local time.
 .
 .It Fl N Ar network
 Match events from
diff --git a/scoop.c b/scoop.c
index 95fb794..6c2957b 100644
--- a/scoop.c
+++ b/scoop.c
@@ -364,9 +364,19 @@ int main(int argc, char *argv[]) {
 				append(
 					where,
 					SQL(
-						AND events.time >= strftime('%s', :date, 'start of day')
-						AND events.time
-							< strftime('%s', :date, 'start of day', '+1 day')
+						AND events.time >=
+						CASE WHEN :local THEN
+							strftime('%s', :date, 'start of day', 'utc')
+						ELSE
+							strftime('%s', :date, 'start of day')
+						END
+						AND events.time <
+						CASE WHEN :local THEN
+							strftime('%s', :date, 'start of day', '+1 day',
+								'utc')
+						ELSE
+							strftime('%s', :date, 'start of day', '+1 day')
+						END
 					)
 				);
 				binds[n++] = Bind(":date", optarg, 0);
@@ -389,11 +399,29 @@ int main(int argc, char *argv[]) {
 				binds[n++] = Bind(":target", optarg, 0);
 			}
 			break; case 'a': {
-				append(where, SQL(AND events.time >= strftime('%s', :after)));
+				append(
+					where,
+					SQL(
+						AND events.time >=
+						CASE WHEN :local
+						THEN strftime('%s', :after, 'utc')
+						ELSE strftime('%s', :after)
+						END
+					)
+				);
 				binds[n++] = Bind(":after", optarg, 0);
 			}
 			break; case 'b': {
-				append(where, SQL(AND events.time < strftime('%s', :before)));
+				append(
+					where,
+					SQL(
+						AND events.time <
+						CASE WHEN :local
+						THEN strftime('%s', :before, 'utc')
+						ELSE strftime('%s', :before)
+						END
+					)
+				);
 				binds[n++] = Bind(":before", optarg, 0);
 			}
 			break; case 'c': {
Rewrite glitch from new pngoJune McEnroe 2022-07-26Update Care with time-to-ID and piercingsJune McEnroe 2022-07-26Add -w to upJune McEnroe 2022-07-13Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe There is not that much distinct stuff here anymore. 2022-07-03Add The Bone Shard EmperorJune McEnroe Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length. 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio. 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe Absolutely indiscriminately. 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe