From 5f3046879e1aa713e95b46795fc49c9f83923750 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 17 Dec 2016 12:04:10 +0000 Subject: searchmsg: remove locale-dependency for ->date strftime is locale-dependent, which can cause surprising failures for some users. --- lib/PublicInbox/SearchMsg.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/SearchMsg.pm') diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm index 5779d1e2..4c65fbe0 100644 --- a/lib/PublicInbox/SearchMsg.pm +++ b/lib/PublicInbox/SearchMsg.pm @@ -7,12 +7,10 @@ package PublicInbox::SearchMsg; use strict; use warnings; use Search::Xapian; -use POSIX qw//; use Date::Parse qw/str2time/; use PublicInbox::MID qw/mid_clean/; use PublicInbox::Address; our $PFX2TERM_RE = undef; -use POSIX qw(strftime); sub new { my ($class, $mime) = @_; @@ -72,13 +70,21 @@ sub subject ($) { __hdr($_[0], 'subject') } sub to ($) { __hdr($_[0], 'to') } sub cc ($) { __hdr($_[0], 'cc') } +# no strftime, that is locale-dependent +my @DoW = qw(Sun Mon Tue Wed Thu Fri Sat); +my @MoY = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); + sub date ($) { my ($self) = @_; my $date = __hdr($self, 'date'); return $date if defined $date; my $ts = $self->{ts}; return unless defined $ts; - $self->{date} = strftime('%a, %d %b %Y %T +0000', gmtime($ts)); + my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($ts); + $self->{date} = "$DoW[$wday], ". + sprintf("%02d $MoY[$mon] %04d %02d:%02d:%02d +0000", + $mday, $year+1900, $hour, $min, $sec); + } sub from ($) { -- cgit v1.2.3-24-ge0c7