Commit 55596ef8 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 399070: Remove the 'timezone' parameter - Patch by Fré©ric Buclin…

Bug 399070: Remove the 'timezone' parameter - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent ef56c491
...@@ -35,7 +35,6 @@ package Bugzilla::Config::Common; ...@@ -35,7 +35,6 @@ package Bugzilla::Config::Common;
use strict; use strict;
use Socket; use Socket;
use Time::Zone;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Constants; use Bugzilla::Constants;
...@@ -49,7 +48,7 @@ use base qw(Exporter); ...@@ -49,7 +48,7 @@ use base qw(Exporter);
check_sslbase check_priority check_severity check_platform check_sslbase check_priority check_severity check_platform
check_opsys check_shadowdb check_urlbase check_webdotbase check_opsys check_shadowdb check_urlbase check_webdotbase
check_netmask check_user_verify_class check_image_converter 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 check_bug_status check_smtp_auth
); );
...@@ -327,14 +326,6 @@ sub check_notification { ...@@ -327,14 +326,6 @@ sub check_notification {
return ""; 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 { sub check_smtp_auth {
my $username = shift; my $username = shift;
if ($username) { if ($username) {
......
...@@ -88,13 +88,6 @@ sub get_param_list { ...@@ -88,13 +88,6 @@ sub get_param_list {
}, },
{ {
name => 'timezone',
type => 't',
default => '',
checker => \&check_timezone
},
{
name => 'utf8', name => 'utf8',
type => 'b', type => 'b',
default => '0', default => '0',
......
...@@ -45,7 +45,6 @@ use Bugzilla::Template::Parser; ...@@ -45,7 +45,6 @@ use Bugzilla::Template::Parser;
use Cwd qw(abs_path); use Cwd qw(abs_path);
use MIME::Base64; use MIME::Base64;
# for time2str - replace by TT Date plugin??
use Date::Format (); use Date::Format ();
use File::Basename qw(dirname); use File::Basename qw(dirname);
use File::Find; use File::Find;
...@@ -605,10 +604,10 @@ sub create { ...@@ -605,10 +604,10 @@ sub create {
# Format a time for display (more info in Bugzilla::Util) # Format a time for display (more info in Bugzilla::Util)
time => [ sub { time => [ sub {
my ($context, $format) = @_; my ($context, $format, $timezone) = @_;
return sub { return sub {
my $time = shift; my $time = shift;
return format_time($time, $format); return format_time($time, $format, $timezone);
}; };
}, },
1 1
......
...@@ -51,6 +51,7 @@ use Bugzilla::Constants; ...@@ -51,6 +51,7 @@ use Bugzilla::Constants;
use Date::Parse; use Date::Parse;
use Date::Format; use Date::Format;
use DateTime; use DateTime;
use DateTime::TimeZone;
use Text::Wrap; use Text::Wrap;
# This is from the perlsec page, slightly modified to remove a warning # This is from the perlsec page, slightly modified to remove a warning
...@@ -397,7 +398,7 @@ sub wrap_hard { ...@@ -397,7 +398,7 @@ sub wrap_hard {
} }
sub format_time { sub format_time {
my ($date, $format) = @_; my ($date, $format, $timezone) = @_;
# If $format is undefined, try to guess the correct date format. # If $format is undefined, try to guess the correct date format.
if (!defined($format)) { if (!defined($format)) {
...@@ -429,8 +430,9 @@ sub format_time { ...@@ -429,8 +430,9 @@ sub format_time {
# Use the timezone specified by the server. # Use the timezone specified by the server.
time_zone => Bugzilla->local_timezone}); time_zone => Bugzilla->local_timezone});
# Now display the date using the user's timezone. # Now display the date using the given timezone,
$dt->set_time_zone(Bugzilla->user->timezone); # or the user's timezone if none is given.
$dt->set_time_zone($timezone || Bugzilla->user->timezone);
$date = $dt->strftime($format); $date = $dt->strftime($format);
} }
else { else {
...@@ -875,15 +877,13 @@ A string. ...@@ -875,15 +877,13 @@ A string.
=item C<format_time($time)> =item C<format_time($time)>
Takes a time, converts it to the desired format and appends the timezone Takes a time and converts it to the desired format and timezone.
as defined in editparams.cgi, if desired. This routine will be expanded If no format is given, the routine guesses the correct one and returns
in the future to adjust for user preferences regarding what timezone to an empty array if it cannot. If no timezone is given, the user's timezone
display times in. is used, as defined in his preferences.
This routine is mainly called from templates to filter dates, see This routine is mainly called from templates to filter dates, see
"FILTER time" in Templates.pm. In this case, $format is undefined and "FILTER time" in L<Bugzilla::Template>.
the routine has to "guess" the date format that was passed to $dbh->sql_date_format().
=item C<format_time_decimal($time)> =item C<format_time_decimal($time)>
......
...@@ -23,7 +23,7 @@ use base qw(Bugzilla::WebService); ...@@ -23,7 +23,7 @@ use base qw(Bugzilla::WebService);
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Hook; use Bugzilla::Hook;
use Time::Zone; use DateTime;
# Basic info that is needed before logins # Basic info that is needed before logins
use constant LOGIN_EXEMPT => { use constant LOGIN_EXEMPT => {
...@@ -51,7 +51,7 @@ sub extensions { ...@@ -51,7 +51,7 @@ sub extensions {
sub timezone { sub timezone {
my $self = shift; my $self = shift;
my $offset = tz_offset(); my $offset = Bugzilla->local_timezone->offset_for_datetime(DateTime->now());
$offset = (($offset / 60) / 60) * 100; $offset = (($offset / 60) / 60) * 100;
$offset = sprintf('%+05d', $offset); $offset = sprintf('%+05d', $offset);
return { timezone => $self->type('string', $offset) }; return { timezone => $self->type('string', $offset) };
......
...@@ -204,18 +204,17 @@ foreach my $chart (@charts) { ...@@ -204,18 +204,17 @@ foreach my $chart (@charts) {
# Utilities # Utilities
################################################################################ ################################################################################
local our @weekday= qw( Sun Mon Tue Wed Thu Fri Sat );
sub DiffDate { sub DiffDate {
my ($datestr) = @_; my ($datestr) = @_;
my $date = str2time($datestr); my $date = str2time($datestr);
my $age = time() - $date; my $age = time() - $date;
my ($s,$m,$h,$d,$mo,$y,$wd)= localtime $date;
if( $age < 18*60*60 ) { if( $age < 18*60*60 ) {
$date = sprintf "%02d:%02d:%02d", $h,$m,$s; $date = format_time($datestr, '%H:%M:%S');
} elsif( $age < 6*24*60*60 ) { } elsif( $age < 6*24*60*60 ) {
$date = sprintf "%s %02d:%02d", $weekday[$wd],$h,$m; $date = format_time($datestr, '%a %H:%M');
} else { } else {
$date = sprintf "%04d-%02d-%02d", 1900+$y,$mo+1,$d; $date = format_time($datestr, '%Y-%m-%d');
} }
return $date; return $date;
} }
...@@ -1077,16 +1076,12 @@ while (my @row = $buglist_sth->fetchrow_array()) { ...@@ -1077,16 +1076,12 @@ while (my @row = $buglist_sth->fetchrow_array()) {
$bug->{'changeddate'} =~ $bug->{'changeddate'} =~
s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/$1-$2-$3 $4:$5:$6/; s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/$1-$2-$3 $4:$5:$6/;
# Put in the change date as a time, so that the template date plugin $bug->{'changedtime'} = $bug->{'changeddate'}; # for iCalendar and Atom
# can format the date in any way needed by the template. ICS and Atom $bug->{'changeddate'} = DiffDate($bug->{'changeddate'});
# have specific, and different, date and time formatting.
$bug->{'changedtime'} = str2time($bug->{'changeddate'}, Bugzilla->params->{'timezone'});
$bug->{'changeddate'} = DiffDate($bug->{'changeddate'});
} }
if ($bug->{'opendate'}) { if ($bug->{'opendate'}) {
# Put in the open date as a time for the template date plugin. $bug->{'opentime'} = $bug->{'opendate'}; # for iCalendar
$bug->{'opentime'} = str2time($bug->{'opendate'}, Bugzilla->params->{'timezone'});
$bug->{'opendate'} = DiffDate($bug->{'opendate'}); $bug->{'opendate'} = DiffDate($bug->{'opendate'});
} }
......
...@@ -147,18 +147,6 @@ ...@@ -147,18 +147,6 @@
<varlistentry> <varlistentry>
<term> <term>
timezone
</term>
<listitem>
<para>
Timezone of server. The timezone is displayed with timestamps. If
this parameter is left blank, the timezone is not displayed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
utf8 utf8
</term> </term>
<listitem> <listitem>
......
...@@ -426,6 +426,7 @@ while (my ($query) = $sth->fetchrow_array) { ...@@ -426,6 +426,7 @@ while (my ($query) = $sth->fetchrow_array) {
push @{$vars->{'available_queries'}}, $query; push @{$vars->{'available_queries'}}, $query;
} }
$vars->{'token'} = issue_session_token('edit_whine'); $vars->{'token'} = issue_session_token('edit_whine');
$vars->{'local_timezone'} = Bugzilla->local_timezone->short_name_for_datetime(DateTime->now());
$template->process("whine/schedule.html.tmpl", $vars) $template->process("whine/schedule.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -571,8 +571,7 @@ sub process_bug { ...@@ -571,8 +571,7 @@ sub process_bug {
my $comments; my $comments;
$comments .= "\n\n--- Bug imported by $exporter_login "; $comments .= "\n\n--- Bug imported by $exporter_login ";
$comments .= time2str( "%Y-%m-%d %H:%M", time ) . " "; $comments .= format_time(localtime(time()), '%Y-%m-%d %H:%M %Z') . " ";
$comments .= $params->{'timezone'};
$comments .= " ---\n\n"; $comments .= " ---\n\n";
$comments .= "This bug was previously known as _bug_ $bug_fields{'bug_id'} at "; $comments .= "This bug was previously known as _bug_ $bug_fields{'bug_id'} at ";
$comments .= $urlbase . "show_bug.cgi?id=" . $bug_fields{'bug_id'} . "\n"; $comments .= $urlbase . "show_bug.cgi?id=" . $bug_fields{'bug_id'} . "\n";
......
...@@ -60,10 +60,6 @@ ...@@ -60,10 +60,6 @@
"all sites served by this web server or virtual host to read " _ "all sites served by this web server or virtual host to read " _
"$terms.Bugzilla cookies.", "$terms.Bugzilla cookies.",
timezone => "The timezone that your database server lives in, " _
"such as UTC, PDT or JST. If set to '', " _
"then the timezone will not be displayed with the timestamps.",
utf8 => "Use UTF-8 (Unicode) encoding for all text in ${terms.Bugzilla}. New " _ utf8 => "Use UTF-8 (Unicode) encoding for all text in ${terms.Bugzilla}. New " _
"installations should set this to true to avoid character encoding " _ "installations should set this to true to avoid character encoding " _
"problems. <strong>Existing databases should set this to true " _ "problems. <strong>Existing databases should set this to true " _
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# Frédéric Buclin <LpSolit@gmail.com> # Frédéric Buclin <LpSolit@gmail.com>
#%] #%]
[% USE date %]
[% PROCESS "global/field-descs.none.tmpl" %] [% PROCESS "global/field-descs.none.tmpl" %]
[% title = "Time Summary " %] [% title = "Time Summary " %]
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#%] #%]
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% USE date %]
[% DEFAULT title = "$terms.Bugzilla $terms.Bugs" %] [% DEFAULT title = "$terms.Bugzilla $terms.Bugs" %]
...@@ -37,9 +36,8 @@ ...@@ -37,9 +36,8 @@
<link rel="self" type="application/atom+xml" <link rel="self" type="application/atom+xml"
href="[% urlbase FILTER html %]buglist.cgi? href="[% urlbase FILTER html %]buglist.cgi?
[%- urlquerypart FILTER xml %]"/> [%- urlquerypart FILTER xml %]"/>
<updated>[% date.format(format=>"%Y-%m-%dT%H:%M:%SZ", <updated>[% bugs.nsort('changedtime').last.changedtime FILTER time("%Y-%m-%dT%H:%M:%SZ", "UTC")
time=>bugs.nsort('changedtime').last.changedtime, FILTER xml %]</updated>
gmt=>1) FILTER xml %]</updated>
<id>[% urlbase FILTER html %]buglist.cgi?[% urlquerypart FILTER xml %]</id> <id>[% urlbase FILTER html %]buglist.cgi?[% urlquerypart FILTER xml %]</id>
[% FOREACH bug = bugs %] [% FOREACH bug = bugs %]
...@@ -52,8 +50,7 @@ ...@@ -52,8 +50,7 @@
<author> <author>
<name>[% bug.reporter_realname FILTER xml %]</name> <name>[% bug.reporter_realname FILTER xml %]</name>
</author> </author>
<updated>[% date.format(format=>"%Y-%m-%dT%H:%M:%SZ",time=>bug.changedtime, <updated>[% bug.changedtime FILTER time("%Y-%m-%dT%H:%M:%SZ", "UTC") FILTER xml %]</updated>
gmt=>1) FILTER xml %]</updated>
<summary type="html"> <summary type="html">
[%# Filter out the entire block, so that we don't need to escape the html code out %] [%# Filter out the entire block, so that we don't need to escape the html code out %]
[% FILTER xml %] [% FILTER xml %]
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#%] #%]
[% PROCESS "global/field-descs.none.tmpl" %] [% PROCESS "global/field-descs.none.tmpl" %]
[% USE date %]
[% colsepchar = user.settings.csv_colsepchar.value %] [% colsepchar = user.settings.csv_colsepchar.value %]
...@@ -35,7 +34,7 @@ bug_id ...@@ -35,7 +34,7 @@ bug_id
[% colsepchar %] [% colsepchar %]
[% IF column == "opendate" OR column == "changeddate" %] [% IF column == "opendate" OR column == "changeddate" %]
[% rawcolumn = column.replace("date", "time") %] [% rawcolumn = column.replace("date", "time") %]
[% bug.$column = date.format(bug.$rawcolumn, "%Y-%m-%d %H:%M:%S") %] [% bug.$column = bug.$rawcolumn FILTER time("%Y-%m-%d %H:%M:%S") %]
[% ELSIF column == 'bug_status' %] [% ELSIF column == 'bug_status' %]
[% bug.$column = get_status(bug.$column) %] [% bug.$column = get_status(bug.$column) %]
[% ELSIF column == 'resolution' %] [% ELSIF column == 'resolution' %]
......
...@@ -31,7 +31,7 @@ BEGIN:VTODO ...@@ -31,7 +31,7 @@ BEGIN:VTODO
[%+ PROCESS ics_status bug_status = bug.bug_status +%] [%+ PROCESS ics_status bug_status = bug.bug_status +%]
[%+ PROCESS ics_dtstamp +%] [%+ PROCESS ics_dtstamp +%]
[% IF bug.changeddate %] [% IF bug.changeddate %]
[%+ time2str("%Y%m%dT%H%M%SZ", bug.changedtime, "UTC") FILTER ics('LAST-MODIFIED') +%] [%+ bug.changedtime FILTER time("%Y%m%dT%H%M%SZ", "UTC") FILTER ics('LAST-MODIFIED') +%]
[% END %] [% END %]
[% IF bug.percentage_complete %] [% IF bug.percentage_complete %]
[%+ bug.percentage_complete FILTER format('%d') FILTER ics('PERCENT-COMPLETE') +%] [%+ bug.percentage_complete FILTER format('%d') FILTER ics('PERCENT-COMPLETE') +%]
...@@ -65,11 +65,11 @@ END:VCALENDAR ...@@ -65,11 +65,11 @@ END:VCALENDAR
[% END %] [% END %]
[% BLOCK ics_dtstart %] [% BLOCK ics_dtstart %]
[% time2str("%Y%m%dT%H%M%SZ", bug.opentime, "UTC") FILTER ics('DTSTART') %] [% bug.opentime FILTER time("%Y%m%dT%H%M%SZ", "UTC") FILTER ics('DTSTART') %]
[% END %] [% END %]
[% BLOCK ics_dtstamp %] [% BLOCK ics_dtstamp %]
[% time2str("%Y%m%dT%H%M%SZ", currenttime, "UTC") FILTER ics('DTSTAMP') %] [% currenttime FILTER time("%Y%m%dT%H%M%SZ", "UTC") FILTER ics('DTSTAMP') %]
[% END %] [% END %]
[% BLOCK ics_status %] [% BLOCK ics_status %]
......
...@@ -71,11 +71,7 @@ ...@@ -71,11 +71,7 @@
</p> </p>
<p> <p>
[% IF Param("timezone") %] All times are server local time ([% local_timezone FILTER html %]).
All times are server local time ([% Param("timezone") FILTER upper %]).
[% ELSE %]
All times are server local time.
[% END %]
</p> </p>
<form method="post" action="editwhines.cgi"> <form method="post" action="editwhines.cgi">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment