From 7716fce2531ee451df9c3d7b66caa71dd4cfaa94 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 24 May 2011 15:00:33 +0100 Subject: [PATCH] Bug 5549 : Add a timezone object to C4::Context Will be required by rolling loans to get correct times NB the setting of the TZ in mysql has not been changed as this appears to rely on $ENV{TZ} being undefined --- C4/Context.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/C4/Context.pm b/C4/Context.pm index 0417c45075..67d31ee947 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -104,6 +104,7 @@ use XML::Simple; use C4::Boolean; use C4::Debug; use POSIX (); +use DateTime::TimeZone; =head1 NAME @@ -384,6 +385,7 @@ sub new { $self->{"userenv"} = undef; # User env $self->{"activeuser"} = undef; # current active user $self->{"shelves"} = undef; + $self->{tz} = undef; # local timezone object bless $self, $class; return $self; @@ -1112,6 +1114,24 @@ sub get_versions { } +=head2 tz + + C4::Context->tz + + Returns a DateTime::TimeZone object for the system timezone + +=cut + +sub tz { + my $self = shift; + if (!defined $context->{tz}) { + $context->{tz} = DateTime::TimeZone->new(name => 'local'); + } + return $context->{tz}; +} + + + 1; __END__ -- 2.39.5