From 90d6b22cd769aa766edb441c454505bb6f558b32 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Fri, 29 Nov 2013 11:40:09 +0100 Subject: [PATCH] MT#3917 Inflate db timestamps to localtime --- lib/NGCP/Schema/InflateColumn/DateTime/EpochMicro.pm | 3 ++- lib/NGCP/Schema/InflateColumn/DateTime/EpochMilli.pm | 3 ++- lib/NGCP/Schema/InflateColumn/DateTime/EpochString.pm | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/NGCP/Schema/InflateColumn/DateTime/EpochMicro.pm b/lib/NGCP/Schema/InflateColumn/DateTime/EpochMicro.pm index 9ebf52ee..41912a2e 100644 --- a/lib/NGCP/Schema/InflateColumn/DateTime/EpochMicro.pm +++ b/lib/NGCP/Schema/InflateColumn/DateTime/EpochMicro.pm @@ -33,7 +33,8 @@ sub _inflate_to_datetime { unless $info->{data_type} eq "decimal" || (exists $info->{inflate_datetime} && $info->{inflate_datetime} eq 'epoch_micro'); - return DateTime->from_epoch(epoch => $value); + my $tz = DateTime::TimeZone->new( name => 'local' ); + return DateTime->from_epoch(epoch => $value, time_zone => $tz); } sub _deflate_from_datetime { diff --git a/lib/NGCP/Schema/InflateColumn/DateTime/EpochMilli.pm b/lib/NGCP/Schema/InflateColumn/DateTime/EpochMilli.pm index 7d8e530f..265b1bb5 100644 --- a/lib/NGCP/Schema/InflateColumn/DateTime/EpochMilli.pm +++ b/lib/NGCP/Schema/InflateColumn/DateTime/EpochMilli.pm @@ -33,7 +33,8 @@ sub _inflate_to_datetime { unless $info->{data_type} eq "decimal" || (exists $info->{inflate_datetime} && $info->{inflate_datetime} eq 'epoch_milli'); - return DateTime->from_epoch(epoch => $value); + my $tz = DateTime::TimeZone->new( name => 'local' ); + return DateTime->from_epoch(epoch => $value, time_zone => $tz); } sub _deflate_from_datetime { diff --git a/lib/NGCP/Schema/InflateColumn/DateTime/EpochString.pm b/lib/NGCP/Schema/InflateColumn/DateTime/EpochString.pm index f7007b06..fc219447 100644 --- a/lib/NGCP/Schema/InflateColumn/DateTime/EpochString.pm +++ b/lib/NGCP/Schema/InflateColumn/DateTime/EpochString.pm @@ -33,7 +33,8 @@ sub _inflate_to_datetime { unless $info->{ data_type } eq "varchar" || (exists $info->{ inflate_datetime } && $info->{ inflate_datetime } eq 'epoch_string'); - return DateTime->from_epoch( epoch => int($value) ); + my $tz = DateTime::TimeZone->new( name => 'local' ); + return DateTime->from_epoch(epoch => $value, time_zone => $tz); } sub _deflate_from_datetime {