| 12
 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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 
 | #!/usr/bin/perl
use strict;
use warnings;
use boolean qw(true);
use Test::MockTime::HiRes qw(set_fixed_time);
use DateTime::Format::Natural;
use DateTime::Format::Natural::Test ':set';
use Test::More;
my $date = join '.', map $time{$_}, qw(day month year);
my $time = join ':', map $time{$_}, qw(hour minute second);
set_fixed_time(
    "$date $time",
    '%d.%m.%Y %H:%M:%S',
);
my @simple = (
    { '01:13:07.999' => '25.11.2006 01:13:07.999' },
    { '01:13:08.000' => '24.11.2006 01:13:08.000' },
    { '01:13:08.001' => '24.11.2006 01:13:08.001' },
);
_run_tests(3, [ [ \@simple ] ], \&compare);
sub compare
{
    my $aref = shift;
    foreach my $href (@$aref) {
        my $key = (keys %$href)[0];
        foreach my $string ($case_strings->($key)) {
            compare_strings($string, $href->{$key});
        }
    }
}
sub compare_strings
{
    my ($string, $result) = @_;
    my $parser = DateTime::Format::Natural->new(prefer_future => true);
    my $dt = $parser->parse_datetime($string);
    if ($parser->success) {
        is(_result_string_hires($dt), $result, _message($string));
    }
    else {
        fail(_message($string));
    }
}
 |