mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°330 Improve \ormDocument::GetFormattedSize
* Fix typo in method name (many thanks @jbostoen !) * Use \utils::BytesToFriendlyFormat
This commit is contained in:
@@ -591,18 +591,21 @@ class utils
|
||||
* Format a value into a more friendly format (KB, MB, GB, TB) instead a juste a Bytes amount.
|
||||
*
|
||||
* @param float $value
|
||||
* @param int $iPrecision
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function BytesToFriendlyFormat($value)
|
||||
public static function BytesToFriendlyFormat($value, $iPrecision = 0)
|
||||
{
|
||||
$sReturn = '';
|
||||
$iPrecision = 0;
|
||||
// Kilobytes
|
||||
if ($value >= 1024)
|
||||
{
|
||||
$sReturn = 'K';
|
||||
$value = $value / 1024;
|
||||
$iPrecision = 1;
|
||||
if ($iPrecision === 0) {
|
||||
$iPrecision = 1;
|
||||
}
|
||||
}
|
||||
// Megabytes
|
||||
if ($value >= 1024)
|
||||
|
||||
Reference in New Issue
Block a user