From 0fcc20760ab4c49ec7e3b93f9025a9b0b8d2046b Mon Sep 17 00:00:00 2001 From: "jake%bugzilla.org" <> Date: Thu, 28 Nov 2002 00:00:20 +0000 Subject: Bug 67077 - We now include the timezone (as configured in editparams.cgi) on every time we display. r=justdave a=justdave --- Attachment.pm | 10 +---- Bugzilla/Attachment.pm | 10 +---- Bugzilla/Util.pm | 51 +++++++++++++++++++++- CGI.pl | 2 +- attachment.cgi | 4 +- bug_form.pl | 14 +----- checksetup.pl | 1 + defparams.pl | 8 ++++ globals.pl | 9 ++-- request.cgi | 2 +- t/004template.t | 1 + t/007util.t | 17 +++++++- template/en/default/attachment/list.html.tmpl | 2 +- .../en/default/attachment/show-multiple.html.tmpl | 2 +- template/en/default/bug/activity/table.html.tmpl | 2 +- template/en/default/bug/comments.html.tmpl | 2 +- template/en/default/bug/edit.html.tmpl | 5 ++- template/en/default/request/queue.html.tmpl | 2 +- 18 files changed, 100 insertions(+), 44 deletions(-) diff --git a/Attachment.pm b/Attachment.pm index 53690170e..27d7fa2ca 100644 --- a/Attachment.pm +++ b/Attachment.pm @@ -69,8 +69,8 @@ sub query # Retrieve a list of attachments for this bug and write them into an array # of hashes in which each hash represents a single attachment. &::SendSQL(" - SELECT attach_id, creation_ts, mimetype, description, ispatch, - isobsolete, isprivate, submitter_id + SELECT attach_id, DATE_FORMAT(creation_ts, '%Y.%m.%d %H:%i'), + mimetype, description, ispatch, isobsolete, isprivate, submitter_id FROM attachments WHERE bug_id = $bugid ORDER BY attach_id "); my @attachments = (); @@ -81,12 +81,6 @@ sub query $a{'ispatch'}, $a{'isobsolete'}, $a{'isprivate'}, $submitter_id) = &::FetchSQLData(); - # Format the attachment's creation/modification date into a standard - # format (YYYY-MM-DD HH:MM) - if ($a{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { - $a{'date'} = "$1-$2-$3 $4:$5"; - } - # Retrieve a list of flags for this attachment. $a{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a{'attachid'} }); diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 53690170e..27d7fa2ca 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -69,8 +69,8 @@ sub query # Retrieve a list of attachments for this bug and write them into an array # of hashes in which each hash represents a single attachment. &::SendSQL(" - SELECT attach_id, creation_ts, mimetype, description, ispatch, - isobsolete, isprivate, submitter_id + SELECT attach_id, DATE_FORMAT(creation_ts, '%Y.%m.%d %H:%i'), + mimetype, description, ispatch, isobsolete, isprivate, submitter_id FROM attachments WHERE bug_id = $bugid ORDER BY attach_id "); my @attachments = (); @@ -81,12 +81,6 @@ sub query $a{'ispatch'}, $a{'isobsolete'}, $a{'isprivate'}, $submitter_id) = &::FetchSQLData(); - # Format the attachment's creation/modification date into a standard - # format (YYYY-MM-DD HH:MM) - if ($a{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { - $a{'date'} = "$1-$2-$3 $4:$5"; - } - # Retrieve a list of flags for this attachment. $a{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a{'attachid'} }); diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index f87c6fbc6..efd107c0a 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -25,11 +25,13 @@ package Bugzilla::Util; +use Bugzilla::Config; + use base qw(Exporter); @Bugzilla::Util::EXPORT = qw(is_tainted trick_taint detaint_natural html_quote url_quote value_quote lsearch max min - trim); + trim format_time); use strict; @@ -122,6 +124,36 @@ sub trim { return $str; } +# Bug 67077 +sub format_time { + my ($time) = @_; + + my ($year, $month, $day, $hour, $min); + if ($time =~ m/^\d{14}$/) { + # We appear to have a timestamp direct from MySQL + $year = substr($time,0,4); + $month = substr($time,4,2); + $day = substr($time,6,2); + $hour = substr($time,8,2); + $min = substr($time,10,2); + } + elsif ($time =~ m/^(\d{4})\.(\d{2})\.(\d{2}) (\d{2}):(\d{2})(:\d{2})?$/) { + $year = $1; + $month = $2; + $day = $3; + $hour = $4; + $min = $5; + } + else { + warn "Date/Time format ($time) unrecogonzied"; + } + + if (defined $year) { + $time = "$year-$month-$day $hour:$min " . &::Param('timezone'); + } + return $time; +} + 1; __END__ @@ -152,6 +184,9 @@ Bugzilla::Util - Generic utility functions for bugzilla # Functions for trimming variables $val = trim(" abc "); + # Functions for formatting time + format_time($time); + =head1 DESCRIPTION This package contains various utility functions which do not belong anywhere @@ -252,3 +287,17 @@ Removes any leading or trailing whitespace from a string. This routine does not modify the existing string. =back + +=head2 Formatting Time + +=over 4 + +=item C + +Takes a time and appends the timezone as defined in editparams.cgi. This routine +will be expanded in the future to adjust for user preferences regarding what +timezone to display times in. In the future, it may also allow for the time to be +shown in different formats. + +=back + diff --git a/CGI.pl b/CGI.pl index 24f92c072..ef1c16d85 100644 --- a/CGI.pl +++ b/CGI.pl @@ -812,7 +812,7 @@ sub GetBugActivity { SELECT IFNULL(fielddefs.description, bugs_activity.fieldid), fielddefs.name, bugs_activity.attach_id, - bugs_activity.bug_when, + DATE_FORMAT(bugs_activity.bug_when,'%Y.%m.%d %H:%i'), bugs_activity.removed, bugs_activity.added, profiles.login_name FROM bugs_activity LEFT JOIN fielddefs ON diff --git a/attachment.cgi b/attachment.cgi index 6e925e69a..27c2c107c 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -369,8 +369,8 @@ sub viewall if (Param("insidergroup") && !(UserInGroup(Param("insidergroup")))) { $privacy = "AND isprivate < 1 "; } - SendSQL("SELECT attach_id, creation_ts, mimetype, description, - ispatch, isobsolete, isprivate + SendSQL("SELECT attach_id, DATE_FORMAT(creation_ts, '%Y.%m.%d %H:%i'), + mimetype, description, ispatch, isobsolete, isprivate FROM attachments WHERE bug_id = $::FORM{'bugid'} $privacy ORDER BY attach_id"); my @attachments; # the attachments array diff --git a/bug_form.pl b/bug_form.pl index e390ad51e..b4a2ef678 100644 --- a/bug_form.pl +++ b/bug_form.pl @@ -85,8 +85,7 @@ sub show_bug { bug_severity, bugs.component_id, components.name, assigned_to, reporter, bug_file_loc, short_desc, target_milestone, qa_contact, status_whiteboard, - date_format(creation_ts,'%Y-%m-%d %H:%i'), - delta_ts, sum(votes.count), delta_ts calc_disp_date, + DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'), delta_ts, sum(votes.count), estimated_time, remaining_time FROM bugs LEFT JOIN votes USING(bug_id), products, components WHERE bugs.bug_id = $id @@ -111,19 +110,10 @@ sub show_bug { "priority", "bug_severity", "component_id", "component", "assigned_to", "reporter", "bug_file_loc", "short_desc", "target_milestone", "qa_contact", "status_whiteboard", - "creation_ts", "delta_ts", "votes", "calc_disp_date", + "creation_ts", "delta_ts", "votes", "estimated_time", "remaining_time") { $value = shift(@row); - if ($field eq "calc_disp_date") { - # Convert MySQL timestamp (_ts) to datetime format(%Y-%m-%d %H:%i) - $disp_date = substr($value,0,4) . '-'; - $disp_date .= substr($value,4,2) . '-'; - $disp_date .= substr($value,6,2) . ' '; - $disp_date .= substr($value,8,2) . ':'; - $disp_date .= substr($value,10,2); - $value = $disp_date; - } $bug{$field} = defined($value) ? $value : ""; } diff --git a/checksetup.pl b/checksetup.pl index 5f947dabe..101583096 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -968,6 +968,7 @@ END html_linebreak => sub { return $_; }, url_quote => sub { return $_; }, csv => sub { return $_; }, + time => sub { return $_; }, }, }) || die ("Could not create Template Provider: " . Template::Provider->error() . "\n"); diff --git a/defparams.pl b/defparams.pl index ae0923295..3e4807dc2 100644 --- a/defparams.pl +++ b/defparams.pl @@ -230,6 +230,14 @@ sub check_netmask { default => '/' }, + { + name => 'timezone', + desc => 'The timezone that your SQL server lives in. If set to "" then' . + 'the timezone can\'t be displayed with the timestamps.', + type => 't', + default => '', + }, + { name => 'enablequips', desc => 'Controls the appearance of quips at the top of buglists.