diff options
author | Eric Wong <e@80x24.org> | 2016-12-17 12:04:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-12-17 22:40:04 +0000 |
commit | 5f3046879e1aa713e95b46795fc49c9f83923750 (patch) | |
tree | 93369ade5e6fcefc6eb9f58054bb70452f99ccb4 /lib/PublicInbox/SearchMsg.pm | |
parent | 7bf8dbcf615cc26f622f5a69192995dfa738a595 (diff) | |
download | public-inbox-5f3046879e1aa713e95b46795fc49c9f83923750.tar.gz |
searchmsg: remove locale-dependency for ->date
strftime is locale-dependent, which can cause surprising failures for some users.
Diffstat (limited to 'lib/PublicInbox/SearchMsg.pm')
-rw-r--r-- | lib/PublicInbox/SearchMsg.pm | 12 |
1 files changed, 9 insertions, 3 deletions
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 ($) { |