| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More tests => 5; |
| 4 |
use Date::Parse qw(strptime str2time); |
| 5 |
|
| 6 |
# RT#48164: Date::Parse unable to set seconds correctly |
| 7 |
{ |
| 8 |
for my $str ("2008.11.30 22:35 CET", "2008-11-30 22:35 CET") { |
| 9 |
my @t = strptime($str); |
| 10 |
my $t = join ":", map { defined($_) ? $_ : "-" } @t; |
| 11 |
is($t, "-:35:22:30:10:108:3600:20", "RT#48164: seconds parsing for '$str'"); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
# RT#17396: Parse error for french date with 'mars' (march) as month |
| 16 |
{ |
| 17 |
use Date::Language; |
| 18 |
my $dateP = Date::Language->new('French'); |
| 19 |
my $timestamp = $dateP->str2time('4 mars 2005'); |
| 20 |
my ($ss, $mm, $hh, $day, $month, $year, $zone) = localtime $timestamp; |
| 21 |
$month++; |
| 22 |
$year += 1900; |
| 23 |
my $date = "$day/$month/$year"; |
| 24 |
is($date, "4/3/2005", "RT#17396: French 'mars' parsed correctly"); |
| 25 |
} |
| 26 |
|
| 27 |
# RT#51664: Change in str2time behaviour between 1.16 and 1.19 |
| 28 |
{ |
| 29 |
ok(str2time('16 Oct 09') >= 0, "RT#51664: '16 Oct 09' parses to non-negative time"); |
| 30 |
} |
| 31 |
|
| 32 |
# RT#84075: Date::Parse::str2time maps date in 1963 to 2063 |
| 33 |
{ |
| 34 |
my $this_year = 1900 + (gmtime(time))[5]; |
| 35 |
my $target_year = $this_year - 50; |
| 36 |
my $date = "$target_year-01-01 00:00:00 UTC"; |
| 37 |
my $time = str2time($date); |
| 38 |
my $year_parsed_as = 1900 + (gmtime($time))[5]; |
| 39 |
is($year_parsed_as, $target_year, "RT#84075: year $target_year not mapped to future"); |
| 40 |
} |