summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-01-16 11:47:45 -0500
committerJune McEnroe <june@causal.agency>2020-01-16 11:47:45 -0500
commitaa6ae879cc5ba876d38499070859512af8edc4d7 (patch)
treef12d152be449300744684b73b47a45db8e079653
parentRemove note about usernames for pounce (diff)
downloadlitterbox-aa6ae879cc5ba876d38499070859512af8edc4d7.tar.gz
litterbox-aa6ae879cc5ba876d38499070859512af8edc4d7.zip
Add scoop flag for local time
Diffstat (limited to '')
-rw-r--r--scoop.19
-rw-r--r--scoop.c16
2 files changed, 20 insertions, 5 deletions
diff --git a/scoop.1 b/scoop.1
index 0d41c12..af03b6e 100644
--- a/scoop.1
+++ b/scoop.1
@@ -1,4 +1,4 @@
-.Dd January 4, 2020
+.Dd January 16, 2020
 .Dt SCOOP 1
 .Os
 .
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl gpqv
+.Op Fl Lgpqv
 .Op Fl D Ar date
 .Op Fl F Ar format
 .Op Fl N Ar network
@@ -69,7 +69,10 @@ similar to
 .Xr strftime 3 ,
 see
 .Aq Lk https://www.sqlite.org/lang_datefunc.html .
-The default format is ISO8601.
+The default format is ISO 8601.
+.
+.It Fl L
+Output timestamps in local time.
 .
 .It Fl N Ar network
 Match events from
diff --git a/scoop.c b/scoop.c
index 006a416..7fb9e28 100644
--- a/scoop.c
+++ b/scoop.c
@@ -227,7 +227,18 @@ static const char *Inner = SQL(
 	SELECT
 		contexts.network,
 		contexts.name AS context,
-		strftime(coalesce(:format, '%Y-%m-%dT%H:%M:%SZ'), events.time) AS time,
+		CASE WHEN :local THEN
+			strftime(
+				coalesce(:format, '%Y-%m-%dT%H:%M:%S'),
+				events.time,
+				'localtime'
+			)
+		ELSE
+			strftime(
+				coalesce(:format, '%Y-%m-%dT%H:%M:%SZ'),
+				events.time
+			)
+		END AS time,
 		events.type,
 		names.nick,
 		names.user,
@@ -365,11 +376,12 @@ int main(int argc, char *argv[]) {
 	const char *where = NULL;
 
 	int opt;
-	const char *Opts = "D:F:N:T:a:b:c:d:f:gh:l:m:n:pqst:u:vw:";
+	const char *Opts = "D:F:LN:T:a:b:c:d:f:gh:l:m:n:pqst:u:vw:";
 	while (0 < (opt = getopt(argc, argv, Opts))) {
 		switch (opt) {
 			break; case 'D': binds[n++] = Bind(":date", optarg, 0);
 			break; case 'F': binds[n++] = Bind(":format", optarg, 0);
+			break; case 'L': binds[n++] = Bind(":local", NULL, 1);
 			break; case 'N': binds[n++] = Bind(":network", optarg, 0);
 			break; case 'T': binds[n++] = Bind(":target", optarg, 0);
 			break; case 'a': binds[n++] = Bind(":after", optarg, 0);