Subject: | [PATCH] can't override TZ detection in ::Local (_load_subclass is broken) |
My $^O is 'hpux'. I wrote my own DateTime::TimeZone::Local::hpux to
workaround RT#44721 but it is not loaded. Instead
DateTime::TimeZone::Local::Unix is used.
The problem is that in DateTime::TimeZone::Local _load_subclass always
load DateTime::TimeZone::Local::Unix if $^O is not in in %subclass.
This makes adding a $^O specific subclass impossible, which was the
point of this code.
The broken line is:
my $os_name = shift || $subclass{ $^O } || 'Unix';
It should be:
my $os_name = shift || $subclass{ $^O } || $^O;
Defaulting to 'Unix' is handled in the following lines.
Current code (0.86):
-------8<-------8<-------8<-------8<-------8<-------8<-------
sub _load_subclass
{
my $class = shift;
my $os_name = shift || $subclass{ $^O } || 'Unix';
my $subclass = $class . '::' . $os_name;
return $subclass if $subclass->can('Methods');
eval "use $subclass";
if ( my $e = $@ )
{
if ( $e =~ /locate.+$os_name/ )
{
$subclass = $class . '::' . 'Unix';
eval "use $subclass";
die $@ if $@;
}
else
{
die $e;
}
}
return $subclass;
}
-------8<-------8<-------8<-------8<-------8<-------8<-------