X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FMsgTime.pm;h=920e8f8a4e7d81f9aec43b0177f39652854f0b60;hb=4da62f284003d75abe7cb35594414eb2224f42bc;hp=8eee9a7586922c0fb302421c4c195b4540793fd2;hpb=95bdac7f09c69036efed537a4d03d5bdd2ae4eb6;p=public-inbox.git diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm index 8eee9a75..920e8f8a 100644 --- a/lib/PublicInbox/MsgTime.pm +++ b/lib/PublicInbox/MsgTime.pm @@ -95,7 +95,7 @@ sub str2date_zone ($) { $sign = '+' if $off == 0; $zone = sprintf('%s%02d%02d', $sign, $tz_hh, $tz_mm); - # Time::Zone and Date::Parse are part of the same distibution, + # Time::Zone and Date::Parse are part of the same distribution, # and we need Time::Zone to deal with tz names like "EDT" } elsif (eval { require Date::Parse }) { $ts = Date::Parse::str2time($date); @@ -104,7 +104,8 @@ sub str2date_zone ($) { # off is the time zone offset in seconds from GMT my ($ss,$mm,$hh,$day,$month,$year,$off) = Date::Parse::strptime($date); - return undef unless(defined $off); + return unless defined($year); + $off //= 0; # Compute the time zone from offset my $sign = ($off < 0) ? '-' : '+'; @@ -166,21 +167,21 @@ sub msg_date_only ($) { } # Favors Received header for sorting globally -sub msg_timestamp ($) { - my ($hdr) = @_; # Email::MIME::Header +sub msg_timestamp ($;$) { + my ($hdr, $fallback) = @_; # Email::MIME::Header my $ret; $ret = msg_received_at($hdr) and return time_response($ret); $ret = msg_date_only($hdr) and return time_response($ret); - wantarray ? (time, '+0000') : time; + time_response([ $fallback // time, '+0000' ]); } # Favors the Date: header for display and sorting within a thread -sub msg_datestamp ($) { - my ($hdr) = @_; # Email::MIME::Header +sub msg_datestamp ($;$) { + my ($hdr, $fallback) = @_; # Email::MIME::Header my $ret; $ret = msg_date_only($hdr) and return time_response($ret); $ret = msg_received_at($hdr) and return time_response($ret); - wantarray ? (time, '+0000') : time; + time_response([ $fallback // time, '+0000' ]); } 1;