From 55596ef8c29ae876c718946d54de787f32033db0 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Thu, 28 Aug 2008 04:26:13 +0000 Subject: Bug 399070: Remove the 'timezone' parameter - 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/Config/Common.pm | 11 +---------- Bugzilla/Config/Core.pm | 7 ------- Bugzilla/Template.pm | 5 ++--- Bugzilla/Util.pm | 20 ++++++++++---------- Bugzilla/WebService/Bugzilla.pm | 4 ++-- 5 files changed, 15 insertions(+), 32 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm index 39fc114d6..d105d9db8 100644 --- a/Bugzilla/Config/Common.pm +++ b/Bugzilla/Config/Common.pm @@ -35,7 +35,6 @@ package Bugzilla::Config::Common; use strict; use Socket; -use Time::Zone; use Bugzilla::Util; use Bugzilla::Constants; @@ -49,7 +48,7 @@ use base qw(Exporter); check_sslbase check_priority check_severity check_platform check_opsys check_shadowdb check_urlbase check_webdotbase check_netmask check_user_verify_class check_image_converter - check_mail_delivery_method check_notification check_timezone check_utf8 + check_mail_delivery_method check_notification check_utf8 check_bug_status check_smtp_auth ); @@ -327,14 +326,6 @@ sub check_notification { return ""; } -sub check_timezone { - my $tz = shift; - unless (defined(tz_offset($tz))) { - return "must be empty or a legal timezone name, such as PDT or JST"; - } - return ""; -} - sub check_smtp_auth { my $username = shift; if ($username) { diff --git a/Bugzilla/Config/Core.pm b/Bugzilla/Config/Core.pm index b307dd7f5..6d413b965 100644 --- a/Bugzilla/Config/Core.pm +++ b/Bugzilla/Config/Core.pm @@ -87,13 +87,6 @@ sub get_param_list { default => '/' }, - { - name => 'timezone', - type => 't', - default => '', - checker => \&check_timezone - }, - { name => 'utf8', type => 'b', diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 76ff9f11d..dbf52a97b 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -45,7 +45,6 @@ use Bugzilla::Template::Parser; use Cwd qw(abs_path); use MIME::Base64; -# for time2str - replace by TT Date plugin?? use Date::Format (); use File::Basename qw(dirname); use File::Find; @@ -605,10 +604,10 @@ sub create { # Format a time for display (more info in Bugzilla::Util) time => [ sub { - my ($context, $format) = @_; + my ($context, $format, $timezone) = @_; return sub { my $time = shift; - return format_time($time, $format); + return format_time($time, $format, $timezone); }; }, 1 diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index a8c595a05..9ff810b4f 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -51,6 +51,7 @@ use Bugzilla::Constants; use Date::Parse; use Date::Format; use DateTime; +use DateTime::TimeZone; use Text::Wrap; # This is from the perlsec page, slightly modified to remove a warning @@ -397,7 +398,7 @@ sub wrap_hard { } sub format_time { - my ($date, $format) = @_; + my ($date, $format, $timezone) = @_; # If $format is undefined, try to guess the correct date format. if (!defined($format)) { @@ -429,8 +430,9 @@ sub format_time { # Use the timezone specified by the server. time_zone => Bugzilla->local_timezone}); - # Now display the date using the user's timezone. - $dt->set_time_zone(Bugzilla->user->timezone); + # Now display the date using the given timezone, + # or the user's timezone if none is given. + $dt->set_time_zone($timezone || Bugzilla->user->timezone); $date = $dt->strftime($format); } else { @@ -875,15 +877,13 @@ A string. =item C -Takes a time, converts it to the desired format and appends the timezone -as defined in editparams.cgi, if desired. This routine will be expanded -in the future to adjust for user preferences regarding what timezone to -display times in. +Takes a time and converts it to the desired format and timezone. +If no format is given, the routine guesses the correct one and returns +an empty array if it cannot. If no timezone is given, the user's timezone +is used, as defined in his preferences. This routine is mainly called from templates to filter dates, see -"FILTER time" in Templates.pm. In this case, $format is undefined and -the routine has to "guess" the date format that was passed to $dbh->sql_date_format(). - +"FILTER time" in L. =item C diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm index af64f4e3a..5196834df 100755 --- a/Bugzilla/WebService/Bugzilla.pm +++ b/Bugzilla/WebService/Bugzilla.pm @@ -23,7 +23,7 @@ use base qw(Bugzilla::WebService); use Bugzilla::Constants; use Bugzilla::Hook; -use Time::Zone; +use DateTime; # Basic info that is needed before logins use constant LOGIN_EXEMPT => { @@ -51,7 +51,7 @@ sub extensions { sub timezone { my $self = shift; - my $offset = tz_offset(); + my $offset = Bugzilla->local_timezone->offset_for_datetime(DateTime->now()); $offset = (($offset / 60) / 60) * 100; $offset = sprintf('%+05d', $offset); return { timezone => $self->type('string', $offset) }; -- cgit v1.2.3-24-g4f1b