If the lib.timezone org setting is not a valid timezone, attempting to
use it can result in an internal server error in the OPAC. Let's handle
the error with try/catch instead.
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
if ($context_org) {
$context_org = $context_org->id if ref($context_org);
my $tz = $locale_subs->{get_org_setting}->($context_org,'lib.timezone');
- $date->set_time_zone($tz) if ($tz);
+ if ($tz) {
+ try {
+ $date->set_time_zone($tz);
+ } catch Error with {
+ $logger->warn("Invalid timezone: $z");
+ };
+ }
}
return sprintf(
"%0.2d:%0.2d:%0.2d %0.2d-%0.2d-%0.4d",