From 615cfb88c1aae1f8372b323e9c53a84d8c9146fe Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 27 Aug 2008 07:32:11 +0000 Subject: Bug 182238: Allow users to choose what time zone to display times in - Patch by Frédéric Buclin r/a=mkanat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/User.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index ccee85755..7f59b749c 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -50,6 +50,7 @@ use Bugzilla::Classification; use Bugzilla::Field; use Scalar::Util qw(blessed); +use DateTime::TimeZone; use base qw(Bugzilla::Object Exporter); @Bugzilla::User::EXPORT = qw(is_available_username @@ -349,6 +350,22 @@ sub settings { return $self->{'settings'}; } +sub timezone { + my $self = shift; + + if (!defined $self->{timezone}) { + my $tz = $self->settings->{timezone}->{value}; + if ($tz eq 'local') { + # The user wants the local timezone of the server. + $self->{timezone} = Bugzilla->local_timezone; + } + else { + $self->{timezone} = DateTime::TimeZone->new(name => $tz); + } + } + return $self->{timezone}; +} + sub flush_queries_cache { my $self = shift; @@ -1884,6 +1901,11 @@ value - the value of this setting for this user. Will be the same is_default - a boolean to indicate whether the user has chosen to make a preference for themself or use the site default. +=item C + +Returns the timezone used to display dates and times to the user, +as a DateTime::TimeZone object. + =item C Returns an arrayref of L objects representing -- cgit v1.2.3-24-g4f1b