Commit ce3c5ed7 authored by jocuri%softhome.net's avatar jocuri%softhome.net

Patch for bug 277618: Move FormatTimeUnit() out of globals.pl; patch by Max K-A…

Patch for bug 277618: Move FormatTimeUnit() out of globals.pl; patch by Max K-A <mkanat@kerio.com>, r=wurblzap, a=myk.
parent a3fa7395
...@@ -182,7 +182,7 @@ sub ProcessOneBug($) { ...@@ -182,7 +182,7 @@ sub ProcessOneBug($) {
if ($values{'qa_contact'}) { if ($values{'qa_contact'}) {
$values{'qa_contact'} = DBID_to_name($values{'qa_contact'}); $values{'qa_contact'} = DBID_to_name($values{'qa_contact'});
} }
$values{'estimated_time'} = FormatTimeUnit($values{'estimated_time'}); $values{'estimated_time'} = format_time_decimal($values{'estimated_time'});
my @dependslist; my @dependslist;
SendSQL("SELECT dependson FROM dependencies WHERE SendSQL("SELECT dependson FROM dependencies WHERE
...@@ -235,8 +235,8 @@ sub ProcessOneBug($) { ...@@ -235,8 +235,8 @@ sub ProcessOneBug($) {
$what =~ s/^(Attachment )?/Attachment #$attachid / if $attachid; $what =~ s/^(Attachment )?/Attachment #$attachid / if $attachid;
if( $fieldname eq 'estimated_time' || if( $fieldname eq 'estimated_time' ||
$fieldname eq 'remaining_time' ) { $fieldname eq 'remaining_time' ) {
$old = FormatTimeUnit($old); $old = format_time_decimal($old);
$new = FormatTimeUnit($new); $new = format_time_decimal($new);
} }
if ($attachid) { if ($attachid) {
SendSQL("SELECT isprivate FROM attachments SendSQL("SELECT isprivate FROM attachments
......
...@@ -32,7 +32,8 @@ use base qw(Exporter); ...@@ -32,7 +32,8 @@ use base qw(Exporter);
html_quote url_quote value_quote xml_quote html_quote url_quote value_quote xml_quote
css_class_quote css_class_quote
lsearch max min lsearch max min
trim diff_strings format_time); trim diff_strings
format_time format_time_decimal);
use Bugzilla::Config; use Bugzilla::Config;
...@@ -207,6 +208,18 @@ sub format_time { ...@@ -207,6 +208,18 @@ sub format_time {
return $time; return $time;
} }
sub format_time_decimal {
my ($time) = (@_);
my $newtime = sprintf("%.2f", $time);
if ($newtime =~ /0\Z/) {
$newtime = sprintf("%.1f", $time);
}
return $newtime;
}
1; 1;
__END__ __END__
...@@ -373,5 +386,11 @@ will be expanded in the future to adjust for user preferences regarding what ...@@ -373,5 +386,11 @@ 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 timezone to display times in. In the future, it may also allow for the time to be
shown in different formats. shown in different formats.
=item C<format_time_decimal($time)>
Returns a number with 2 digit precision, unless the last digit is a 0. Then it
returns only 1 digit precision.
=back =back
...@@ -1448,20 +1448,6 @@ sub PerformSubsts { ...@@ -1448,20 +1448,6 @@ sub PerformSubsts {
return $str; return $str;
} }
sub FormatTimeUnit {
# Returns a number with 2 digit precision, unless the last digit is a 0
# then it returns only 1 digit precision
my ($time) = (@_);
my $newtime = sprintf("%.2f", $time);
if ($newtime =~ /0\Z/) {
$newtime = sprintf("%.1f", $time);
}
return $newtime;
}
############################################################################### ###############################################################################
......
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