Skip Menu |

This queue is for tickets about the Util-SelfDestruct CPAN distribution.

Report information
The Basics
Id: 118194
Status: new
Priority: 0/
Queue: Util-SelfDestruct

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.21
Fixed in: (no value)



Subject: _mungeDateTime fails to parse October dates
Today (2015-10-01) the test suite fails: # Failed test at t/01tests.t line 34. # Failed test at t/01tests.t line 41. # Failed test at t/01tests.t line 45. # Failed test at t/01tests.t line 47. # Looks like you failed 4 tests of 12. t/01tests.t ......... Dubious, test returned 4 (wstat 1024, 0x400) Failed 4/12 subtests Seems that some dates are not parsed correctly: $ perl -Mblib -e 'require Util::SelfDestruct; warn Util::SelfDestruct::_mungeDateTime("20161002")' Warning: something's wrong at -e line 1. $ perl -Mblib -e 'require Util::SelfDestruct; warn Util::SelfDestruct::_mungeDateTime("20160902")' 20160902000000 at -e line 1. Looking at the regexp in _mungeDateTime it seems that $isodate =~ /^\s*(19\d{2}|2\d{3})(0[1-9]|1[12])(0[1-9]|[12][0-9]|3[01]) should be $isodate =~ /^\s*(19\d{2}|2\d{3})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])
On 2016-10-01 02:33:07, SREZIC wrote: Show quoted text
> Today (2015-10-01) the test suite fails: > > # Failed test at t/01tests.t line 34. > > # Failed test at t/01tests.t line 41. > > # Failed test at t/01tests.t line 45. > > # Failed test at t/01tests.t line 47. > # Looks like you failed 4 tests of 12. > t/01tests.t ......... Dubious, test returned 4 (wstat 1024, 0x400) > Failed 4/12 subtests > > > Seems that some dates are not parsed correctly: > > $ perl -Mblib -e 'require Util::SelfDestruct; warn > Util::SelfDestruct::_mungeDateTime("20161002")' > Warning: something's wrong at -e line 1. > $ perl -Mblib -e 'require Util::SelfDestruct; warn > Util::SelfDestruct::_mungeDateTime("20160902")' > 20160902000000 at -e line 1. > > > Looking at the regexp in _mungeDateTime it seems that > > $isodate =~ /^\s*(19\d{2}|2\d{3})(0[1-9]|1[12])(0[1-9]|[12][0- > 9]|3[01]) > > should be > > $isodate =~ /^\s*(19\d{2}|2\d{3})(0[1-9]|1[012])(0[1-9]|[12][0- > 9]|3[01])
Here's a formal patch: diff --git a/lib/Util/SelfDestruct.pm b/lib/Util/SelfDestruct.pm index 3a21b18..6811c33 100644 --- a/lib/Util/SelfDestruct.pm +++ b/lib/Util/SelfDestruct.pm @@ -178,7 +178,7 @@ sub _mungeDateTime { (my $isodate = $str) =~ s/\D//g; if ((length($str) - length($isodate) < 10) && (my ($year,$mon,$mday,$hour,$min,$sec) = - $isodate =~ /^\s*(19\d{2}|2\d{3})(0[1-9]|1[12])(0[1-9]|[12][0-9]|3[01]) + $isodate =~ /^\s*(19\d{2}|2\d{3})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]) (?:([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9]))?\s*$/x)) { if (defined $hour) { return $isodate;