about summary refs log tree commit homepage
path: root/lib/PublicInbox/Hval.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-12-13 00:50:11 +0000
committerEric Wong <e@80x24.org>2023-12-13 09:01:50 +0000
commite3444977887f7615cef271341f29f3a87a36eac9 (patch)
tree3a233a7f19e4fc27d112f6c8090ff58ab0164add /lib/PublicInbox/Hval.pm
parentd465c70450006f2ad435d5a0d48261ac8ebc8fa1 (diff)
downloadpublic-inbox-e3444977887f7615cef271341f29f3a87a36eac9.tar.gz
The musl strftime(3) implementation on AlpineLinux 3.19.0
doesn't support `%k' and `%k' isn't in POSIX, either.  So we
fall back to using the `sprintf' perlop in the user-facing UI
since leading zeroes require needless overhead for my eyes and
brain to parse in the time.
Diffstat (limited to 'lib/PublicInbox/Hval.pm')
-rw-r--r--lib/PublicInbox/Hval.pm6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index b804254a..963dbb71 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -145,7 +145,11 @@ sub to_attr ($) {
 sub ts2str ($) { strftime('%Y%m%d%H%M%S', gmtime($_[0])) };
 
 # human-friendly format
-sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+sub fmt_ts ($) {
+        # strftime %k is not portable and leading zeros in %H slow me down
+        my (undef, $M, $H, $d, $m, $Y) = gmtime $_[0];
+        sprintf '%u-%02u-%02u % 2u:%02u', $Y + 1900, $m + 1, $d, $H, $M;
+}
 
 sub utf8_maybe ($) {
         utf8::decode($_[0]);