Skip to content

Commit

Permalink
support dates with reversed day/month
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed May 11, 2017
1 parent 0acee89 commit 43e8b29
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/CPAN/Changes/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,13 @@ our $_UNKNOWN_DATE = qr{
}xi;

our $_LOCALTIME_DATE = qr{
(?:$_SHORT_DAY\s+)?
($_SHORT_MONTH)\s+
(?:
(?:$_SHORT_DAY\s+)?
($_SHORT_MONTH)\s+
|
($_SHORT_MONTH)\s+
(?:$_SHORT_DAY\s+)
)
(\d{1,2})\s+ # date
(?: ([\d:]+)\s+ )? # time
(?: ([A-Z]+)\s+ )? # timezone
Expand Down Expand Up @@ -311,10 +316,10 @@ sub _split_date {
# handle localtime-like timestamps
elsif ( $note =~ s{^($_LOCALTIME_DATE)}{} ) {
$date = $1;
$parsed_date = sprintf( '%d-%02d-%02d', $6, 1+$months{lc $2}, $3 );
if ($4) {
# unfortunately ignores TZ data ($5)
$parsed_date .= sprintf( 'T%sZ', $4 );
$parsed_date = sprintf( '%d-%02d-%02d', $7, 1+$months{lc($2 || $3)}, $4 );
if ($5) {
# unfortunately ignores TZ data ($6)
$parsed_date .= sprintf( 'T%sZ', $5 );
}
}

Expand Down

0 comments on commit 43e8b29

Please sign in to comment.