added thousandsSeparator parameter to the AmountHelper methods

This commit is contained in:
Akinwale Ariwodola 2017-06-13 20:05:48 +01:00
parent f48e9f8b46
commit e2a383a064
2 changed files with 5 additions and 5 deletions

View file

@ -63,7 +63,7 @@
<div class="label half-width">Difficulty</div>
<div class="label half-width">Nonce</div>
<div class="value half-width"><?php echo $this->Amount->format($block->Difficulty) ?></div>
<div class="value half-width"><?php echo $this->Amount->format($block->Difficulty, '') ?></div>
<div class="value half-width"><?php echo $block->Nonce ?></div>
<div class="clear spacer"></div>

View file

@ -5,8 +5,8 @@ namespace App\View\Helper;
use Cake\View\Helper;
class AmountHelper extends Helper {
public function format($value) {
$value = number_format($value, 8, '.', ',');
public function format($value, $thousandsSeparator = '') {
$value = number_format($value, 8, '.', $thousandsSeparator);
$dotIdx = strpos($value, '.');
if ($dotIdx !== false) {
$left = substr($value, 0, $dotIdx);
@ -21,13 +21,13 @@ class AmountHelper extends Helper {
return $value;
}
public function formatCurrency($value) {
public function formatCurrency($value, $thousandsSeparator = '') {
$dotIdx = strpos($value, '.');
if ($dotIdx !== false) {
$left = substr($value, 0, $dotIdx);
$right = substr($value, $dotIdx + 1);
$value = number_format($left, 0, '', ',');
$value = number_format($left, 0, '', $thousandsSeparator);
if ((int) $right > 0) {
if (strlen($right) === 1) {
$value .= '.' . $right . '0';