about summary refs log tree commit diff
path: root/bitutil.c
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-21 00:03:24 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-21 00:06:24 +0200
commit875a5ce6222fa1027dc134b73c5cd6e8c06c1e4a (patch)
tree39bceb66616964571c0c23ac0acd3046195c8779 /bitutil.c
parentcada2ed89e5a0b68e2cfd002bf707107fb6d7111 (diff)
feat(timeutil): output proper RFC3339 format for atom
Previously, since we used strftime %z it'd output an offset as +HHMM
while RFC3339 requires +HH:MM. Currently we implement outputting this
manually which proved to be non-trivial because of the tzset() API.
This probably should be improved in the future since I suspect it
produces incorrect results in some edge cases.
Diffstat (limited to 'bitutil.c')
-rw-r--r--bitutil.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/bitutil.c b/bitutil.c
new file mode 100644
index 0000000..8b2807f
--- /dev/null
+++ b/bitutil.c
@@ -0,0 +1,25 @@
+char nibble_hex(short h) {
+    switch(h) {
+        case 0:
+        case 1:
+        case 2:
+        case 3:
+        case 4:
+        case 5:
+        case 6:
+        case 7:
+        case 8:
+        case 9:
+            return (h + 48);
+        case 10:
+        case 11:
+        case 12:
+        case 13:
+        case 14:
+        case 15:
+            return (h + 55);
+        default:
+            return 0;
+    }
+}
+