X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FMsgTime.pm;h=bd7ef8117d30fb5ad32aeef4f46c1813edd06fbd;hb=8e81d6f0d44198717ae540421a09824d75c9bb6d;hp=9f4326442dd110d12a40f96595d3b2b2da7461aa;hpb=74fd81670fcc9eaec15a009995e52f9aeefa1494;p=public-inbox.git
diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm
index 9f432644..bd7ef811 100644
--- a/lib/PublicInbox/MsgTime.pm
+++ b/lib/PublicInbox/MsgTime.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2019 all contributors
+# Copyright (C) 2018-2020 all contributors
# License: AGPL-3.0+
# Various date/time-related functions
@@ -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;