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/Util.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Bugzilla/Util.pm') 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 -- cgit v1.2.3-24-g4f1b