X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FUI%2Fbytecount.pm;h=d278dbecc86b7625c7e4a89a9d7d6d490a2bc960;hb=083d1fef19686b9b72f1b92e72a4fa56a3f392a9;hp=38aa1dfd62449cf50eb34b98afbd891af3918826;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1;p=freeside.git diff --git a/FS/FS/UI/bytecount.pm b/FS/FS/UI/bytecount.pm index 38aa1dfd6..d278dbecc 100644 --- a/FS/FS/UI/bytecount.pm +++ b/FS/FS/UI/bytecount.pm @@ -42,20 +42,21 @@ sub bytecount_unexact { Accepts a number (digits and a decimal point) possibly followed by k, m, g, or t (and an optional 'b') in either case. Returns a pure number representing -the input or the input itself if unparsable. +the input or the input itself if unparsable. Discards commas as noise. =cut sub parse_bytecount { my $bc = shift; return $bc if (($bc =~ tr/.//) > 1); - $bc =~ /^\s*([\d.]*)\s*([kKmMgGtT]?)[bB]?\s*$/ or return $bc; + $bc =~ /^\s*([,\d.]*)\s*([kKmMgGtT]?)[bB]?\s*$/ or return $bc; my $base = $1; + $base =~ tr/,//d; return $bc unless length $base; my $exponent = index ' kmgt', lc($2); return $bc if ($exponent < 0 && $2); $exponent = 0 if ($exponent < 0); - return $base * 1024 ** $exponent; + return int($base * 1024 ** $exponent); #bytecounts are integer values } =item display_bytecount AMOUNT