Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 7212589

Browse files
committed
Follow existing size format notation of 'time' pannel
1 parent 6848325 commit 7212589

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Twig/HumanReadableExtension.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ public function getFilters()
1818
);
1919
}
2020
/**
21-
* @param int $bytes
22-
* @param int $decimals
21+
* @param int $bytes Bytes/Octets
22+
* @param int $decimals Number for decimals to return
23+
* @param bool $octetFormat Use Octet notation instead of Bytes
2324
*
2425
* @return string
2526
*/
26-
public function size_format($bytes, $decimals = 2)
27+
public function size_format($bytes, $decimals = 2, $octetFormat = false)
2728
{
2829
$bytes = (int) $bytes;
2930
$sz = 'BKMGTP';
3031
$factor = floor(( strlen($bytes) - 1 ) / 3);
3132

32-
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)).@$sz[ $factor ].( $factor ? 'o' : '' );
33+
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)).@$sz[ $factor ].( $factor ? ($octetFormat ? 'O' : 'B') : '' );
3334
}
3435

3536
/**

0 commit comments

Comments
 (0)