DateTime setting invalid zone.

[email protected] (Bill Moseley) Tue, 12 Mar 2013 19:34:20 -0700
Newsgroups perl.datetime
Message-ID <CAKhN_m6tcZOFNEaOCuhNUJc+ou+bPLVLD3nqg9VFmm0vp-zuGQ@mail.gmail.com>
So, I found some old that wrapped a set_time_zone in an eval.

my $dt = DateTime->new(
    year => 2013,
    month => 3,
    day => 10,
    hour => 2,
    minute => 4,
    time_zone => 'floating',
);

eval { $dt->set_time_zone( 'America/Los_Angeles' ); };

print "$dt " . $dt->time_zone . "\n";


The code was using the eval to check if the timezone set failed, and if it
did went on to do something else with $dt (like set to UTC).   But, it
seems like even if it fails the time zone gets set.  The above returns this
invalid time:

2013-03-10T02:04:00
DateTime::TimeZone::America::Los_Angeles=HASH(0x7fc4c2aafc90)

My question is should DateTime associate that timezone to $dt if the
set_time_zone call actually throws an exception?


-- 
Bill Moseley
[email protected]