1 # Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use POSIX qw(strftime);
8 use PublicInbox::MsgTime qw(msg_datestamp);
9 my $mime = PublicInbox::Eml->new(<<'EOF');
12 Subject: this is a subject
13 Message-ID: <a@example.com>
14 Date: Fri, 02 Oct 1993 00:00:00 +0000
19 my $ts = msg_datestamp($mime->header_obj);
20 is(strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)), '1993-10-02 00:00:00',
21 'got expected date with 2 digit year');
22 $mime->header_set(Date => 'Fri, 02 Oct 101 01:02:03 +0000');
23 $ts = msg_datestamp($mime->header_obj);
24 is(strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)), '2001-10-02 01:02:03',
25 'got expected date with 3 digit year');