-# Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Various date/time-related functions
if ($date =~ /(?:[A-Za-z]+,?\s+)? # day-of-week
([0-9]+),?\s+ # dd
([A-Za-z]+)\s+ # mon
- ([0-9]{2,})\s+ # YYYY or YY (or YYY :P)
+ ([0-9]{2,4})\s+ # YYYY or YY (or YYY :P)
([0-9]+)[:\.] # HH:
((?:[0-9]{2})|(?:\s?[0-9])) # MM
(?:[:\.]((?:[0-9]{2})|(?:\s?[0-9])))? # :SS
$ts = timegm($ss // 0, $mm, $hh, $dd, $mon, $yyyy);
+ # 4-digit dates in non-spam from 1900s and 1910s exist in
+ # lore archives
+ return if $ts < 0;
+
# Compute the time offset from [+-]HHMM
$tz //= 0;
my ($tz_hh, $tz_mm);
# 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) ? '-' : '+';