Hi,
 i'm looking for a way to find out if a timezone is valid.
If i want to check a timezone using this module i instanciate
an object with the provided name:
 my $otz = new DateTime::TimeZone( name => 'Europe/Paris' );
This name is valid so no problem, but if i try:
 my $otz = new DateTime::TimeZone( name => 'Europ/Paris' );
the module dies and so my script.

I've modified the DateTime::TimeZone module so that it returns
undef when the timezone name is not valid.

Is this the proper way to do it, or is there a simple solution
to my problem i didn't spotted ? If it's the proper way is there
any chance it will be included in a future release ?

Thanks.

Mat

--- TimeZone-0.2502.pm  2003-10-02 12:48:00.000000000 +0200
+++ TimeZone-0.2503.pm  2003-10-02 12:28:42.000000000 +0200
@@ -66,7 +66,10 @@
     my $real_class = "DateTime::TimeZone::$subclass";

     eval "require $real_class";
-    die "Invalid time zone name: $p{name}" if ( $@ );
+    if ( $@ ) {
+     print STDERR "Invalid time zone name: $p{name}\n";
+     return    undef;
+    }

     return $real_class->instance( name => $p{name}, is_olson => 1 );
 }



Reply via email to