File: past.t

package info (click to toggle)
libtime-format-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 248 kB
  • ctags: 34
  • sloc: perl: 522; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download
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

# Test cases for bug reported by Will "Coke" Coleda

use strict;
use Test::More;
use Time::Format;

my $have_module = eval { require 'DateTime::Format::ISO8601'; 1; };


# Input string, output string
my @tuples = (
              ['2009-04-15T01:58:17.010760Z', 'April 15, 2009 @ 1:58'],
              ['2009-04-15T13:58:17.010760Z', 'April 15, 2009 @ 1:58'],
             );

# The above array contains all of the tests this unit will run.
my $num_tests = 2 * scalar(@tuples);
plan tests => $num_tests;

SKIP:
{
    skip 'DateTime::Format::ISO8601 required for this test', $num_tests
        unless $have_module;

    my $time_format = 'Month d, yyyy @ H:mm';

    my $index = 0;
    foreach my $pair (@tuples)
    {
        my ($input, $expected) = @$pair;
        my $dt = DateTime::Format::ISO8601->parse_datetime($input);

        is $time{$time_format,       $dt}, $expected, "Test case $index (hash)";
        is time_format($time_format, $dt), $expected, "Test case $index (func)";
        ++$index;
    }
}