Author: spadkins
Date: Tue Nov 30 11:47:00 2010
New Revision: 14557
Modified:
p5ee/trunk/App-Widget/lib/App/Widget.pm
Log:
if necessary inhibit commas and percents in formated values
Modified: p5ee/trunk/App-Widget/lib/App/Widget.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/Widget.pm (original)
+++ p5ee/trunk/App-Widget/lib/App/Widget.pm Tue Nov 30 11:47:00 2010
@@ -514,12 +514,14 @@
sub format {
&App::sub_entry if ($App::trace);
- my ($self, $value, $format_options, $values) = @_;
+ my ($self, $value, $format_options, $values, $options) = @_;
if ($format_options->{relationship} eq "rank") {
return $value;
}
+ $options = {} if (!$options);
+
my $formatted_value = $value;
if (! defined $formatted_value) {
@@ -572,6 +574,7 @@
}
}
}
+
my $negated = (($paren || $sign) && $value < 0);
if ($negated) {
$formatted_value = -$formatted_value;
@@ -589,7 +592,7 @@
}
else {
$formatted_value = int($formatted_value);
- if ($int =~ /,/) {
+ if ($int =~ /,/ && !$options->{inhibit_comma}) {
$formatted_value =~ s/([0-9])([0-9][0-9][0-9])$/$1,$2/;
while ($formatted_value =~
s/([0-9])([0-9][0-9][0-9]),/$1,$2,/) {
# keep doing it until it's not found
@@ -624,7 +627,9 @@
}
}
if ($pct) {
- $formatted_value = $formatted_value . "%";
+ if (!$options->{inhibit_pct}) {
+ $formatted_value = $formatted_value . "%";
+ }
}
}
}