Skip Menu |

This queue is for tickets about the Time-Piece CPAN distribution.

Report information
The Basics
Id: 91124
Status: new
Priority: 0/
Queue: Time-Piece

People
Owner: Nobody in particular
Requestors: bohica [...] ntlworld.com
Cc:
AdminCc:

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



Subject: report "garbage at end of string in strptime" from caller's perspective
$ perl -MTime::Piece -le 'print $Time::Piece::VERSION;$a = Time::Piece->strptime("2013 garbage", "%Y");' 1.23 garbage at end of string in strptime: garbage at /home/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/i686-linux/Time/Piece.pm line 469. It would be much nicer if Time::Piece reported this error from the perspective of the caller instead of in Time::Piece itself. It is of no real use to know it fell over in Time::Piece. This changed strptime does it for me: sub strptime { my $time = shift; my $string = shift; my $format = @_ ? shift(@_) : "%a, %d %b %Y %H:%M:%S %Z"; my (@vals, $warning); { local $SIG{__WARN__} = sub {$warning = shift}; @vals = _strptime($string, $format); } carp($warning) if $warning; # warn(sprintf("got vals: %d-%d-%d %d:%d:%d\n", reverse(@vals))); return scalar $time->_mktime(\@vals, (ref($time) ? $time->[c_islocal] : 0)); } Martin -- Martin J. Evans Wetherby, UK