Subject: | Misleading diagnostic message |
I'm getting the following error message while using this module:
'Time::Simple' is not a valid ISO 8601 formated time at bin/parse-irc.pl
line 53
I've attached a patch to this ticket, which should solve the problem
(along with a simple test).
Cheers,
Agent
Subject: | 0.052.patch |
diff -urNp Time-Simple-0.052/lib/Time/Simple.pm Time-Simple-0.052-patched/lib/Time/Simple.pm
--- Time-Simple-0.052/lib/Time/Simple.pm 2007-01-02 16:36:10.078125000 +0800
+++ Time-Simple-0.052-patched/lib/Time/Simple.pm 2007-01-02 16:36:36.296875000 +0800
@@ -134,9 +134,9 @@ sub new {
s/^:// foreach @hms[1..2];
if (not defined $hms[0]){
if ($FATALS){
- croak"'$_[0]' is not a valid ISO 8601 formated time" ;
+ croak"'$_[1]' is not a valid ISO 8601 formated time" ;
} else {
- Carp::cluck("'$_[0]' is not a valid ISO 8601 formated time") if $^W;
+ Carp::cluck("'$_[1]' is not a valid ISO 8601 formated time") if $^W;
return undef;
}
}
diff -urNp Time-Simple-0.052/t/Time-Simple.t Time-Simple-0.052-patched/t/Time-Simple.t
--- Time-Simple-0.052/t/Time-Simple.t 2006-08-03 19:30:18.000000000 +0800
+++ Time-Simple-0.052-patched/t/Time-Simple.t 2007-01-02 16:34:32.796875000 +0800
@@ -1,6 +1,6 @@
our $VERSION = 0.3 ;
-use Test::More tests => 94;
+use Test::More tests => 96;
BEGIN {
use lib '../lib'; # For when this script is run directly
@@ -213,7 +213,10 @@ is(
is($max - $t, $t - $max, 'Always positive');
}
-
-
-
-
+{
+ eval {
+ Time::Simple->new('abc');
+ };
+ ok $@, 'invalid time detected';
+ like $@, qr/'abc' is not a valid ISO 8601 formated time/, 'message ok';
+}