From ce3c5ed7f0c8c4426b3717c169674edfe7a16556 Mon Sep 17 00:00:00 2001 From: "jocuri%softhome.net" <> Date: Sun, 16 Jan 2005 21:25:46 +0000 Subject: Patch for bug 277618: Move FormatTimeUnit() out of globals.pl; patch by Max K-A , r=wurblzap, a=myk. --- Bugzilla/BugMail.pm | 6 +++--- Bugzilla/Util.pm | 21 ++++++++++++++++++++- globals.pl | 14 -------------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index da41d4247..41a8c2329 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -182,7 +182,7 @@ sub ProcessOneBug($) { if ($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; SendSQL("SELECT dependson FROM dependencies WHERE @@ -235,8 +235,8 @@ sub ProcessOneBug($) { $what =~ s/^(Attachment )?/Attachment #$attachid / if $attachid; if( $fieldname eq 'estimated_time' || $fieldname eq 'remaining_time' ) { - $old = FormatTimeUnit($old); - $new = FormatTimeUnit($new); + $old = format_time_decimal($old); + $new = format_time_decimal($new); } if ($attachid) { SendSQL("SELECT isprivate FROM attachments diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 125d91164..142866912 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -32,7 +32,8 @@ use base qw(Exporter); html_quote url_quote value_quote xml_quote css_class_quote lsearch max min - trim diff_strings format_time); + trim diff_strings + format_time format_time_decimal); use Bugzilla::Config; @@ -207,6 +208,18 @@ sub format_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; __END__ @@ -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 shown in different formats. +=item C + +Returns a number with 2 digit precision, unless the last digit is a 0. Then it +returns only 1 digit precision. + + =back diff --git a/globals.pl b/globals.pl index 81b99c8ac..dc0a29570 100644 --- a/globals.pl +++ b/globals.pl @@ -1448,20 +1448,6 @@ sub PerformSubsts { 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; - -} ############################################################################### -- cgit v1.2.3-24-g4f1b