1 # Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use_ok 'PublicInbox::MIME';
7 use PublicInbox::MsgTime qw(msg_datestamp);
8 my $mime = PublicInbox::MIME->create(
10 From => 'a@example.com',
11 To => 'test@example.com',
12 Subject => 'this is a subject',
13 'Message-ID' => '<a-mid@b>',
14 Date => 'Fri, 02 Oct 93 00:00:00 +0000',
16 body => "hello world\n",
19 my $ts = msg_datestamp($mime->header_obj);
20 use POSIX qw(strftime);
21 is(strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)), '1993-10-02 00:00:00',
22 'got expected date with 2 digit year');
23 $mime->header_set(Date => 'Fri, 02 Oct 101 01:02:03 +0000');
24 $ts = msg_datestamp($mime->header_obj);
25 is(strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)), '2001-10-02 01:02:03',
26 'got expected date with 3 digit year');