TT#41402 normalize tzdata timezone names for perl DateTime

Change-Id: I7e90ce6b29f7cc4aa0520cd2539e78687f7001a2
changes/33/22733/2
Rene Krenn 8 years ago
parent 3303cfdc42
commit 1a7aca8c11

@ -3,7 +3,7 @@ use strict;
use warnings; use warnings;
use HTTP::Status qw(:constants); use HTTP::Status qw(:constants);
use NGCP::Panel::Utils::DateTime qw();
sub get_owner_data { sub get_owner_data {
my ($self, $c, $schema, $source, $optional_for_admin_reseller) = @_; my ($self, $c, $schema, $source, $optional_for_admin_reseller) = @_;
@ -112,7 +112,7 @@ sub apply_owner_timezone {
} else { } else {
# shouldnt go here. # shouldnt go here.
} }
$result->set_time_zone($tz->name) if $tz; $result->set_time_zone(NGCP::Panel::Utils::DateTime::normalize_db_tz_name($tz->name)) if $tz;
} }
return $result; return $result;
} }

@ -28,6 +28,18 @@ sub is_valid_timezone_name {
} }
} }
sub normalize_db_tz_name {
my $tz = shift;
if (defined $tz) {
if (lc($tz) eq 'localtime') {
$tz = 'local';
} elsif (lc($tz) eq 'system') {
$tz = 'local';
} # else { ... additional cases
}
return $tz;
}
sub current_local { sub current_local {
if ($is_fake_time) { if ($is_fake_time) {
return DateTime->from_epoch(epoch => Time::Warp::time, return DateTime->from_epoch(epoch => Time::Warp::time,

Loading…
Cancel
Save