File: 050-date.t

package info (click to toggle)
libhttp-headers-actionpack-perl 0.09-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 364 kB
  • sloc: perl: 2,614; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 886 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Fatal;

BEGIN {
    use_ok('HTTP::Headers::ActionPack::DateHeader');
}

sub test_date {
    my $h = shift;

    isa_ok($h, 'HTTP::Headers::ActionPack::DateHeader');

    is( $h->day, 'Mon', '... got the day');
    is( $h->month, 'Apr', '... got the month');
    is( $h->year, 2012, '... got the year');
    is( $h->hour, 14, '... got the hour');
    is( $h->minute, 14, '... got the minute');
    is( $h->second, 19, '... got the second');

    is( $h->as_string, 'Mon, 23 Apr 2012 14:14:19 GMT', '... got the expected string');
}

test_date(
    HTTP::Headers::ActionPack::DateHeader->new_from_string('Mon, 23 Apr 2012 14:14:19 GMT')
);

test_date(
    HTTP::Headers::ActionPack::DateHeader->new(
        scalar Time::Piece->gmtime( HTTP::Date::str2time( 'Mon, 23 Apr 2012 14:14:19 GMT' ) )
    )
);

done_testing;