PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/XML-FeedPP/t/31_two_digit_date.t

http://xml-treepp.googlecode.com/
Unknown | 58 lines | 55 code | 3 blank | 0 comment | 0 complexity | 9678dbdb23678e0c7a0aaa1f32463123 MD5 | raw file
 1# ----------------------------------------------------------------
 2    use strict;
 3    use Test::More tests => 21;
 4    BEGIN { use_ok('XML::FeedPP') };
 5# ----------------------------------------------------------------
 6=rfc733
 7
 8date        =  1*2DIGIT ["-"] month         ; day month year
 9               ["-"] (2DIGIT /4DIGIT)       ;  e.g. 20 Aug [19]77
10
11see also:
12http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503260
13
14=cut
15# ----------------------------------------------------------------
16{
17    my $rfc2822_2dy = {
18        '300032400'     =>  'Thu, 05 Jul 79 14:20:00 GMT',
19        '500032400'     =>  'Tue, 05 Nov 85 09:53:20 GMT',
20        '700032400'     =>  'Sun, 08 Mar 92 05:26:40 GMT',
21        '900032400'     =>  'Fri, 10 Jul 98 01:00:00 GMT',
22        '1100032400'    =>  'Tue, 09 Nov 04 20:33:20 GMT',
23        '1300032400'    =>  'Sun, 13 Mar 11 16:06:40 GMT',
24        '1500032400'    =>  'Fri, 14 Jul 17 11:40:00 GMT',
25        '1700032400'    =>  'Wed, 15 Nov 23 07:13:20 GMT',
26        '1900032400'    =>  'Mon, 18 Mar 30 02:46:40 GMT',
27        '2100032400'    =>  'Fri, 18 Jul 36 22:20:00 GMT',
28    };
29    my $w3cdtf = {
30        '300032400'     =>  '1979-07-05T14:20:00Z',
31        '500032400'     =>  '1985-11-05T09:53:20Z',
32        '700032400'     =>  '1992-03-08T05:26:40Z',
33        '900032400'     =>  '1998-07-10T01:00:00Z',
34        '1100032400'    =>  '2004-11-09T20:33:20Z',
35        '1300032400'    =>  '2011-03-13T16:06:40Z',
36        '1500032400'    =>  '2017-07-14T11:40:00Z',
37        '1700032400'    =>  '2023-11-15T07:13:20Z',
38        '1900032400'    =>  '2030-03-18T02:46:40Z',
39        '2100032400'    =>  '2036-07-18T22:20:00Z',
40    };
41    foreach my $key ( sort {$a<=>$b} keys %$rfc2822_2dy ) {
42        my $try1 = $rfc2822_2dy->{$key};
43        my $chk1 = $w3cdtf->{$key};
44        my $out1 = XML::FeedPP::Util::rfc1123_to_w3cdtf( $try1 );
45        $out1 =~ s/[\+\-]00:00$/Z/;
46        my $name = ( $try1 =~ /, (.*) \d+:/ )[0];
47        is( $out1, $chk1, 'rfc1123/w3cdtf '.$try1 );
48    }
49    foreach my $key ( sort {$a<=>$b} keys %$rfc2822_2dy ) {
50        my $try1 = $rfc2822_2dy->{$key};
51        my $out1 = XML::FeedPP::Util::rfc1123_to_epoch( $try1 );
52        my $name = ( $try1 =~ /, (.*) \d+:/ )[0];
53        is( $out1, $key, 'rfc1123/epoch '.$try1 );
54    }
55}
56# ----------------------------------------------------------------
57;1;
58# ----------------------------------------------------------------