summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authorjocuri%softhome.net <>2005-01-16 22:25:46 +0100
committerjocuri%softhome.net <>2005-01-16 22:25:46 +0100
commitce3c5ed7f0c8c4426b3717c169674edfe7a16556 (patch)
tree180fa447e85db8e843ccbf9c25870924a16c7686 /Bugzilla/Util.pm
parenta3fa7395909a57c7811c2c82d7e5c2dc033d01de (diff)
downloadbugzilla-ce3c5ed7f0c8c4426b3717c169674edfe7a16556.tar.gz
bugzilla-ce3c5ed7f0c8c4426b3717c169674edfe7a16556.tar.xz
Patch for bug 277618: Move FormatTimeUnit() out of globals.pl; patch by Max K-A <mkanat@kerio.com>, r=wurblzap, a=myk.
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm21
1 files changed, 20 insertions, 1 deletions
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<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