mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 19:34:31 +02:00
Added a field for edit the mass of a part.
This commit is contained in:
parent
016c2889ba
commit
e7cc53f046
9 changed files with 231 additions and 30 deletions
|
@ -75,12 +75,32 @@ class SIFormatter
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param float $value
|
||||
* @param string $unit
|
||||
* @param int $decimals
|
||||
* @return array
|
||||
*/
|
||||
public function convertValue(float $value) : array
|
||||
{
|
||||
//Choose the prefix to use
|
||||
$tmp = $this->getPrefixByMagnitude($this->getMagnitude($value));
|
||||
|
||||
$ret = array(
|
||||
'value' => $value / $tmp[0],
|
||||
'prefix_magnitude' => log10($tmp[0]),
|
||||
'prefix' => $tmp[1]
|
||||
);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given value to a string, using the given options
|
||||
* @param float $value The value that should be converted
|
||||
* @param string $unit The unit that should be appended after the prefix
|
||||
* @param int $decimals The number of decimals (after decimal dot) that should be outputed.
|
||||
* @return string
|
||||
*/
|
||||
public function format(float $value, string $unit = '', int $decimals = 2)
|
||||
public function format(float $value, string $unit = '', int $decimals = 2) : string
|
||||
{
|
||||
[$divisor, $symbol] = $this->getPrefixByMagnitude($this->getMagnitude($value));
|
||||
$value /= $divisor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue