]> Sergey Matveev's repositories - public-inbox.git/blob - t/time.t
No ext_urls
[public-inbox.git] / t / time.t
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>
3 use strict;
4 use warnings;
5 use Test::More;
6 use POSIX qw(strftime);
7 use PublicInbox::Eml;
8 use PublicInbox::MsgTime qw(msg_datestamp);
9 my $mime = PublicInbox::Eml->new(<<'EOF');
10 From: a@example.com
11 To: b@example.com
12 Subject: this is a subject
13 Message-ID: <a@example.com>
14 Date: Fri, 02 Oct 1993 00:00:00 +0000
15
16 hello world
17 EOF
18
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');
26
27 done_testing();