diff options
author | Eric Wong <e@80x24.org> | 2023-12-13 00:50:11 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-12-13 09:01:50 +0000 |
commit | e3444977887f7615cef271341f29f3a87a36eac9 (patch) | |
tree | 3a233a7f19e4fc27d112f6c8090ff58ab0164add /lib/PublicInbox/Hval.pm | |
parent | d465c70450006f2ad435d5a0d48261ac8ebc8fa1 (diff) | |
download | public-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.pm | 6 |
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]); |