Mathieu wrote:
> 
> 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 ?

---
  use DateTime::TimeZone;

  my $otz;
  eval {
    $otz = new DateTime::TimeZone( name => 'Europ/Paris' );
  };

  unless ( $otz )
  {
      print "Got undef: $@";
  }

  print "And life goes on\n";

---
  Got undef: Invalid time zone name: Europ/Paris at
/usr/local/lib/perl5/site_perl/5.6.1/DateTime/TimeZone.pm line 69.
  And life goes on
---

- Flavio S. Glock

Reply via email to