summary refs log tree commit diff
path: root/.bin/clock.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-01-19 17:06:24 -0500
committerJune McEnroe <june@causal.agency>2017-01-19 17:06:24 -0500
commita445cd3134656695f4f60c941ba85dea9a1821d2 (patch)
tree4763c7067ee4791ac8a6ad925d03bb6b4f377a5b /.bin/clock.c
parentInclude host in tmux status line (diff)
downloadsrc-a445cd3134656695f4f60c941ba85dea9a1821d2.tar.gz
src-a445cd3134656695f4f60c941ba85dea9a1821d2.zip
Add fuzzy clock
Diffstat (limited to '')
-rwxr-xr-x.bin/clock.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/.bin/clock.c b/.bin/clock.c
new file mode 100755
index 00000000..9eb4dc23
--- /dev/null
+++ b/.bin/clock.c
@@ -0,0 +1,28 @@
+#if 0
+exec cc -Wall -Wextra -pedantic $@ -o $(dirname $0)/clock $0
+#endif
+
+#include <time.h>
+#include <stdio.h>
+#include <sysexits.h>
+#include <err.h>
+
+int main() {
+    time_t timestamp = time(NULL);
+    if (timestamp < 0) err(EX_OSERR, "time");
+
+    struct tm *clock = localtime(&timestamp);
+    if (!clock) err(EX_OSERR, "localtime");
+
+    switch ((clock->tm_min + 5) / 10) {
+        case 0: printf("...%02d...\n", clock->tm_hour); break;
+        case 1: printf("..%02d....\n", clock->tm_hour); break;
+        case 2: printf(".%02d.....\n", clock->tm_hour); break;
+        case 3: printf("%02d....%02d\n", clock->tm_hour, clock->tm_hour + 1); break;
+        case 4: printf(".....%02d.\n", clock->tm_hour + 1); break;
+        case 5: printf("....%02d..\n", clock->tm_hour + 1); break;
+        case 6: printf("...%02d...\n", clock->tm_hour + 1); break;
+    }
+
+    return 0;
+}
w=1'>ui-shared: restrict to 15 levelsJason A. Donenfeld 2019-02-23ui-diff,ui-tag: don't use htmlf with non-formatted stringsChris Mayo 2019-02-23ui-ssdiff: resolve HTML5 validation errorsChris Mayo 2019-01-03filters: migrate from luacrypto to luaosslJason A. Donenfeld 2019-01-02ui-shared: fix broken sizeof in title setting and rewriteJason A. Donenfeld 2018-12-09git: update to v2.20.0Christian Hesse 2018-11-25ui-blame: set repo for sbJason A. Donenfeld 2018-11-25auth-filter: pass url with query string attachedJason A. Donenfeld 2018-11-21git: use xz compressed archive for downloadChristian Hesse 2018-10-12git: update to v2.19.1Christian Hesse 2018-09-11ui-ssdiff: ban strcat()Christian Hesse 2018-09-11ui-ssdiff: ban strncpy()Christian Hesse 2018-09-11ui-shared: ban strcat()Christian Hesse 2018-09-11ui-patch: ban sprintf()Christian Hesse 2018-09-11ui-log: ban strncpy()Christian Hesse 2018-09-11ui-log: ban strcpy()Christian Hesse 2018-09-11parsing: ban sprintf()Christian Hesse 2018-09-11parsing: ban strncpy()Christian Hesse 2018-08-28filters: generate anchor links from markdownChristian Hesse 2018-08-03Bump version.Jason A. Donenfeld 2018-08-03clone: fix directory traversalJason A. Donenfeld 2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev