remove WebGUI::Utility::commify

This commit is contained in:
Graham Knop 2010-08-20 12:18:04 -05:00
parent 006a5003c2
commit 96004e50ac
4 changed files with 6 additions and 29 deletions

View file

@ -17,6 +17,7 @@ use DateTime;
use Tie::IxHash;
use WebGUI::International;
use WebGUI::Utility;
use Number::Format ();
use WebGUI::HTML;
use POSIX qw(ceil floor);
use Moose;
@ -762,8 +763,8 @@ sub view {
$hash->{'project.description.data'} = $project->{description};
$hash->{'project.startDate.data'} = $project->{startDate}?$datetime->epochToSet($project->{startDate}):$i18n->get("N_A");
$hash->{'project.endDate.data'} = $project->{endDate}?$datetime->epochToSet($project->{endDate}):$i18n->get("N_A");
$hash->{'project.cost.data.int'} = WebGUI::Utility::commify(int($project->{targetBudget}));
$hash->{'project.cost.data.float'} = WebGUI::Utility::commify($project->{targetBudget});
$hash->{'project.cost.data.int'} = Number::Format::format_number($project->{targetBudget}, 0);
$hash->{'project.cost.data.float'} = Number::Format::format_number($project->{targetBudget});
$hash->{'project.complete.data.int'} = int($project->{percentComplete});
$hash->{'project.complete.data.int'} = 100 if($hash->{'project.complete.data.int'} > 100);
$hash->{'project.complete.data.float'} = sprintf("%2.2f",$project->{percentComplete});

View file

@ -16,6 +16,7 @@ use WebGUI::Utility;
use WebGUI::Asset::Wobject;
use Finance::Quote;
use Tie::IxHash;
use Number::Format ();
use Moose;
use WebGUI::Definition::Asset;
@ -110,7 +111,7 @@ sub _appendStockVars {
$hash->{'stocks.volume.millions'} = _na(WebGUI::Utility::round(($hash->{'stocks.volume'}/1000000),2));
$hash->{'stocks.avg_vol'} = _na($data->{$symbol,"avg_vol"});
$hash->{'stocks.bid'} = _na($data->{$symbol,"bid"});
$hash->{'stocks.ask'} = _na(WebGUI::Utility::commify($data->{$symbol,"ask"}));
$hash->{'stocks.ask'} = _na(Number:Format::format_number($data->{$symbol,"ask"}));
$hash->{'stocks.close'} = _na($data->{$symbol,"close"});
$hash->{'stocks.open'} = _na($data->{$symbol,"open"});
$hash->{'stocks.day_range'} = _na($data->{$symbol,"day_range"});

View file

@ -22,7 +22,7 @@ use Tie::IxHash;
use Net::CIDR::Lite;
our @ISA = qw(Exporter);
our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray &isInSubnet
our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &randomizeArray &isInSubnet
&sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round &scalarEquals
);
@ -38,7 +38,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme
=head1 SYNOPSIS
use WebGUI::Utility;
$string = commify($integer);
$boolean = isBetween($value, $first, $second);
$boolean = isIn($value, @array);
$boolean = isInSubnet($ip, \@subnets);
@ -59,25 +58,6 @@ These subroutines are available from this package:
=cut
#-------------------------------------------------------------------
=head2 commify ( integer )
Returns a number with commas applied at each third character.
=head3 integer
Any old number will do.
=cut
sub commify {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}
#-------------------------------------------------------------------
=head2 emailRegex ( )

View file

@ -22,11 +22,6 @@ use Test::Deep;
my $session = WebGUI::Test->session;
# commify
is(WebGUI::Utility::commify(10), "10", 'commify() - no comma needed');
is(WebGUI::Utility::commify(1000), "1,000", 'commify() - single comma');
is(WebGUI::Utility::commify(10000000), "10,000,000", 'commify() - multiple commas');
# isBetween
ok(WebGUI::Utility::isBetween(0,-1,1), 'isBetween() - negative and positive range');
ok(WebGUI::Utility::isBetween(0,1,-1), 'isBetween() - negative and positive range, reversed');