unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [Patch] Update 24-hour times to use two digits for the hour
@ 2020-06-05 20:22 Varun Varada
  2020-06-05 22:03 ` Eric Wong
  0 siblings, 1 reply; 7+ messages in thread
From: Varun Varada @ 2020-06-05 20:22 UTC (permalink / raw)
  To: meta

Hello,

Here is a patch to update the timestamps displayed to have 2 digits
for the hour when since it is using the 24-hour clock:

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 0bc2b06e..def138c6 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -178,7 +178,7 @@ sub nr_to_s ($$$) {
 }

 # human-friendly format
-sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+sub fmt_ts ($) { strftime('%Y-%m-%d %H:%M', gmtime($_[0])) }

 # Displays the text of of the message for /$INBOX/$MSGID/[Tt]/ endpoint
 # this is already inside a <pre>
diff --git a/lib/PublicInbox/WwwStatic.pm b/lib/PublicInbox/WwwStatic.pm
index 3c933156..c3b29c49 100644
--- a/lib/PublicInbox/WwwStatic.pm
+++ b/lib/PublicInbox/WwwStatic.pm
@@ -294,12 +294,12 @@ sub dir_response ($$$) {
  } else {
  next;
  }
- # 54 = 80 - (SP length(strftime(%Y-%m-%d %k:%M)) SP human_size)
+ # 54 = 80 - (SP length(strftime(%Y-%m-%d %H:%M)) SP human_size)
  $hsize = sprintf('% 8s', $hsize);
  my $pad = 54 - length($name);
  $pad = 1 if $pad <= 0;
  $entry .= qq(<a\nhref="$href">$name</a>) . (' ' x $pad);
- $mtime = strftime('%Y-%m-%d %k:%M', gmtime($mtime));
+ $mtime = strftime('%Y-%m-%d %H:%M', gmtime($mtime));
  $entry .= $mtime . $hsize;
  }

diff --git a/xt/msgtime_cmp.t b/xt/msgtime_cmp.t
index 95d7c64b..6f4ca198 100644
--- a/xt/msgtime_cmp.t
+++ b/xt/msgtime_cmp.t
@@ -36,7 +36,7 @@ sub quiet_is_deeply ($$$$$) {
  ($old->[0] != $cur->[0]) ||
  ($old->[1] != $cur->[1]))) {
  for ($cur, $old) {
- $_->[2] = strftime('%Y-%m-%d %k:%M:%S', gmtime($_->[0]))
+ $_->[2] = strftime('%Y-%m-%d %H:%M:%S', gmtime($_->[0]))
  }
  is_deeply($cur, $old, "$func $oid");
  diag('got: ', explain($cur));


Regards,
Varun

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-06 21:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 20:22 [Patch] Update 24-hour times to use two digits for the hour Varun Varada
2020-06-05 22:03 ` Eric Wong
2020-06-05 22:48   ` Varun Varada
2020-06-05 23:27     ` Eric Wong
2020-06-06  0:11       ` Varun Varada
2020-06-06  0:27         ` Eric Wong
2020-06-06 21:27     ` Dmitry Alexandrov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).