DateTime::TimeZone::is_valid_name check fails, own checks work okay

[email protected] (Chris Welch) Mon, 1 Jun 2015 13:10:50 +0100
Newsgroups perl.datetime
Message-ID <CAAee2CP7pOSJ92N40Js9xnZrwRFCq_8mxW30nqKR=_jaxP5WGQ@mail.gmail.com>
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