The proper usage is

DateTime::TimeZone->is_valid_name($name)

not

DateTime::TimeZone::is_valid_name

You need to call it as a method, and you need to pass the name to check.


On Mon, Jun 1, 2015 at 8:10 AM, Chris Welch <welch.ch...@gmail.com> wrote:

> Hi
>
> I'm sure I'm doing something completely stupid, but am baffled with these
> results I'm getting.  I'm getting a user to select a timezone and the
> is_valid_name check is *always* coming back false - for my example I'm
> using 'Europe/London', but I've tried a few in different categories with
> the same result.
>
> Testing I've done:
>
> my $timezone_name = "Europe/London";
> printf( "Is %s valid? %d\n", $tz_name, DateTime::TimeZone::is_valid_name
> ); # Prints Is Europe/London valid? 0
>
> This is in contrast to my own tests, where I mimic what is_valid_name is
> doing:
>
> my $tz = try {
>   local $SIG{__DIE__};
>   DateTime::TimeZone->new( name => $tz_name );
> };
>
> print $tz && $tz->isa('DateTime::TimeZone') ? 1 : 0; # Prints 1
>
> I can't see why one would print 1 and the other 0, as as far as I can
> tell, they're essentially doing the same thing - but there must be
> *something* different!  Obviously I could use my test in the production
> environment, but then I still wouldn't understand why the results are
> different and aside from the fact that I'd like to understand why, that may
> lead to unexpected results in future.
>
> Thanks
>
>
> Chris
>

Reply via email to