summaryrefslogtreecommitdiffstats
path: root/Bugzilla/User.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r--Bugzilla/User.pm22
1 files changed, 22 insertions, 0 deletions
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<timezone>
+
+Returns the timezone used to display dates and times to the user,
+as a DateTime::TimeZone object.
+
=item C<groups>
Returns an arrayref of L<Bugzilla::Group> objects representing