summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-31 17:49:41 -0500
committerJune McEnroe <june@causal.agency>2019-12-31 17:49:41 -0500
commitf6d035f92e11e5432da3b9be2758ea619fb3cfbb (patch)
treea5d09ddf84d3d43b810d060ac3c31fa0dc577aff
parentRefactor binding in scoop (diff)
downloadlitterbox-f6d035f92e11e5432da3b9be2758ea619fb3cfbb.tar.gz
litterbox-f6d035f92e11e5432da3b9be2758ea619fb3cfbb.zip
Add strftime format string option
-rw-r--r--scoop.111
-rw-r--r--scoop.c6
2 files changed, 14 insertions, 3 deletions
diff --git a/scoop.1 b/scoop.1
index a9a40c0..2dfdf09 100644
--- a/scoop.1
+++ b/scoop.1
@@ -10,6 +10,7 @@
 .Nm
 .Op Fl gpqv
 .Op Fl D Ar date
+.Op Fl F Ar format
 .Op Fl N Ar network
 .Op Fl T Ar target
 .Op Fl c Ar context
@@ -47,6 +48,16 @@ of the format
 or the keyword
 .Cm now .
 .
+.It Fl F Ar format
+Format timestamps using the
+.Ar format
+string,
+similar to
+.Xr strftime 3 .
+The default format is ISO8601.
+See
+.Lk https://www.sqlite.org/lang_datefunc.html
+.
 .It Fl N Ar network
 Match events from contexts on
 .Ar network .
diff --git a/scoop.c b/scoop.c
index 2a78af8..d8e7607 100644
--- a/scoop.c
+++ b/scoop.c
@@ -29,8 +29,7 @@ static const char *Inner = SQL(
 	SELECT
 		contexts.network,
 		contexts.name AS context,
-		// TODO: Replace with a strftime and option.
-		date(events.time) || 'T' || time(events.time) || 'Z' AS time,
+		strftime(coalesce(:format, '%Y-%m-%dT%H:%M:%SZ'), events.time) AS time,
 		events.type,
 		names.nick,
 		CASE WHEN names.user = '*'
@@ -183,9 +182,10 @@ int main(int argc, char *argv[]) {
 	const char *search = NULL;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "D:N:T:c:d:gh:l:n:pqst:u:v"))) {
+	while (0 < (opt = getopt(argc, argv, "D:F:N:T:c:d:gh:l:n:pqst:u:v"))) {
 		switch (opt) {
 			break; case 'D': binds[n++] = Bind(":date", optarg, 0);
+			break; case 'F': binds[n++] = Bind(":format", optarg, 0);
 			break; case 'N': binds[n++] = Bind(":network", optarg, 0);
 			break; case 'T': binds[n++] = Bind(":target", optarg, 0);
 			break; case 'c': binds[n++] = Bind(":context", optarg, 0);
:23:55 -0500'>2021-02-07Fix cwm window cycling, move big by defaultJune McEnroe 2021-02-07Use class names for Foreground, Background, BorderColorJune McEnroe I'm not really sure what difference this makes, but it seems like the right thing to do to be generic? 2021-02-07Add simple battery status and clock to xsessionJune McEnroe I love how simple this is. 2021-02-07Set cursor theme and sizeJune McEnroe 2021-02-07Use scrot for up -s if no screencaptureJune McEnroe Still missing putting the URL in an X selection. 2021-02-07Enable mouse acceleration in XJune McEnroe 2021-02-07Set colours for Xt and cwmJune McEnroe And increase XTerm internalBorder. 2021-02-07Set urgency on bell in xtermJune McEnroe 2021-02-07Add bindings for brightness controlJune McEnroe Weirdly the Fn key doesn't change how the F row registers... I wonder if I can do something about that. 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 11 is what I use on macOS, but I feel like my eyes are working harder here. 2021-02-07Fully configure and rebind cwmJune McEnroe This is sort of a mix of trying to emulate macOS somewhat for my muscle memory and just rebinding some of the cwm defaults to use 4- rather than M-. 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe cwm still needs a lot more rebinding, and I need to actually look at its other options. xterm definitely still needs some configuration, but I at least managed to get it to use a decent looking font. Very happy that OpenBSD includes Luxi Mono, which is what my usual font, Go Mono, is based on anyway. Still missing is xmodmap and such. 2021-02-06Add xterm output to schemeJune McEnroe