Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/HTTP/Date.pm
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ sub parse_date ($) {
(?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?[0-9][0-9]?:?(:?[0-9][0-9])?
([-+]?[0-9][0-9]?:?(?:[0-9][0-9])?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$
/x
Expand Down
13 changes: 12 additions & 1 deletion t/date.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings;

use Test::More tests => 152;
use Test::More tests => 156;
use HTTP::Date;

# test str2time for supported dates. Test cases with 2 digit year
Expand Down Expand Up @@ -198,6 +198,17 @@ use HTTP::Date qw(parse_date);
my @d = parse_date("Jan 1 2001");
is_deeply( \@d, [2001, 1, 1, 0, 0, 0, undef] );

# A malformed timezone with a doubled colon must be rejected, not silently
# captured as the timezone. RT #101378 / GH #7.
is_deeply( [ parse_date("1996-02-29 12:00:00 -01::00") ],
[], 'malformed timezone -01::00 is rejected' );

# Well-formed timezone variants must still parse, returning the timezone intact.
for my $tz ('-01:00', '-0100', '-01') {
my @d = parse_date("1996-02-29 12:00:00 $tz");
is( $d[6], $tz, "timezone $tz still accepted" );
}

# This test will break around year 2070
is( parse_date("03-Feb-20"), "2020-02-03 00:00:00" );

Expand Down
Loading