user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] *view: avoid leading zero in time display of the hour
@ 2015-12-05  2:18 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-12-05  2:18 UTC (permalink / raw)
  To: meta

Avoid the visual noise entirely by using a space instead.

I sometimes have difficulty distinguishing '0' from '8' while
other users may mistake it for an 'O' character.  Most digital
clocks I've seen will omit displaying a leading zero for the
hour, too.

This may also save transfer time by allowing better compression
(since there is a space between the date and time anyways) and
perhaps reduce client rendering time on some displays.

We'll leave the leading zero for minutes since that seems pretty
standard for digital clocks.
---
 lib/PublicInbox/SearchView.pm | 5 ++---
 lib/PublicInbox/View.pm       | 6 ++++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index a15af55..7f79090 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -10,7 +10,6 @@ use PublicInbox::Hval;
 use PublicInbox::View;
 use PublicInbox::MID qw(mid2path mid_clean);
 use Email::MIME;
-use POSIX qw/strftime/;
 our $LIM = 50;
 
 sub sres_top_html {
@@ -69,11 +68,11 @@ sub dump_mset {
 		my $s = PublicInbox::Hval->new_oneline($smsg->subject);
 		my $f = $smsg->from_name;
 		$f = PublicInbox::Hval->new_oneline($f)->as_html;
-		my $d = strftime('%Y-%m-%d %H:%M', gmtime($smsg->ts));
+		my $ts = PublicInbox::View::fmt_ts($smsg->ts);
 		my $mid = PublicInbox::Hval->new_msgid($smsg->mid)->as_href;
 		$$res .= qq{$rank. <b><a\nhref="$mid/">}.
 			$s->as_html . "</a></b>\n";
-		$$res .= "$pfx  - by $f @ $d UTC [$pct%]\n\n";
+		$$res .= "$pfx  - by $f @ $ts UTC [$pct%]\n\n";
 	}
 }
 
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index f34e1f3..2506c95 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -712,9 +712,11 @@ sub missing_thread {
 sub _msg_date {
 	my ($mime) = @_;
 	my $ts = $mime->header('X-PI-TS') || msg_timestamp($mime);
-	POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts));
+	fmt_ts($ts);
 }
 
+sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+
 sub _inline_header {
 	my ($dst, $state, $upfx, $mime, $level) = @_;
 	my $pfx = INDENT x ($level - 1);
@@ -865,7 +867,7 @@ sub dump_topics {
 		$dst .= "$nl$pfx$dot<a\nhref=\"$mid/t/#u\"><b>$subj</b></a>\n";
 
 		my $attr;
-		$ts = POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts));
+		$ts = fmt_ts($ts);
 		if ($n == 1) {
 			$attr = "@ $ts UTC";
 			$n = "";
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-05  2:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-05  2:18 [PATCH] *view: avoid leading zero in time display of the hour Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).