Commit 3cb97fb8 by Vincent

updated formatting

parent d12c8d58
...@@ -426,22 +426,22 @@ class Formatter extends Component ...@@ -426,22 +426,22 @@ class Formatter extends Component
public function asSize($value, $verbose=false) public function asSize($value, $verbose=false)
{ {
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
$position = 0; $position = 0;
do { do {
if ($value < $this->sizeFormat['base']) { if ($value < $this->sizeFormat['base']) {
break; break;
} }
$value = $value / $this->sizeFormat['base']; $value = $value / $this->sizeFormat['base'];
$position++; $position++;
} while ($position < count($units)); } while ($position < count($units));
$value = round($value, $this->sizeFormat['decimals']); $value = round($value, $this->sizeFormat['decimals']);
$formattedValue = isset($this->sizeFormat['decimalSeparator']) ? str_replace('.', $this->sizeFormat['decimalSeparator'], $value) : $value; $formattedValue = isset($this->sizeFormat['decimalSeparator']) ? str_replace('.', $this->sizeFormat['decimalSeparator'], $value) : $value;
$params = ['n' => $formattedValue]; $params = ['n' => $formattedValue];
switch($position) switch($position)
{ {
case 0: case 0:
return $verbose ? Yii::t('yii','{n, plural, =1{# byte} other{# bytes}}', $params) : Yii::t('yii', '{n} B', $params); return $verbose ? Yii::t('yii','{n, plural, =1{# byte} other{# bytes}}', $params) : Yii::t('yii', '{n} B', $params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment