Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f5d11325

Von Sven Schöling vor etwa 3 Jahren hinzugefügt

  • ID f5d11325588b7b7c7bed5a3aaeeb5f842ad18b17
  • Vorgänger 71450c6a
  • Nachfolger d67d3e74

Number: Konvertierung in Basiseinheit für format_number_units

Unterschiede anzeigen:

SL/Helper/Number.pm
use strict;
use Exporter qw(import);
use List::Util qw(max min);
use List::UtilsBy qw(rev_nsort_by);
use Config;
our @EXPORT_OK = qw(
......
return _format_number($amount, $places, %params);
}
$amount *= $unit_from->convert_to(1, $unit_to);
$amount *= $unit_from->factor;
my $conv_units = $unit_from->convertible_units($all_units);
# unline AM::convertible_uits, this one doesn't sort by default
my @conv_units = rev_nsort_by { $_->factor // 0 } @{ $unit_from->convertible_units($all_units) };
if (!scalar @{ $conv_units }) {
if (!scalar @conv_units) {
return _format_number($amount, $places, %params) . " " . $unit_to->name;
}
my @values;
my $num;
for my $unit (@$conv_units) {
for my $unit (@conv_units) {
my $last = $unit->name eq $unit_to->name;
if (!$last) {
$num = int($amount / $unit->factor);

Auch abrufbar als: Unified diff