Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3782216a

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 3782216af1ff4f28e79fae256a28d07a9399920d
  • Vorgänger dcf6e20c
  • Nachfolger 9beafdda

_as_percent-Helper: Zwei Nachkommastellen anzeigen

Unterschiede anzeigen:

SL/DB/Helper/Attr.pm
30 30
sub _make_by_type {
31 31
  my ($package, $name, $type) = @_;
32 32
  _as_number ($package, $name, places => -2) if $type =~ /numeric | real | float/xi;
33
  _as_percent($package, $name, places =>  0) if $type =~ /numeric | real | float/xi;
33
  _as_percent($package, $name, places =>  2) if $type =~ /numeric | real | float/xi;
34 34
  _as_number ($package, $name, places =>  0) if $type =~ /int/xi;
35 35
  _as_date   ($package, $name)               if $type =~ /date | timestamp/xi;
36 36
}
t/helper/attr.t
34 34
is($o->marge_percent_as_percent('40'), '40');
35 35
is($o->marge_percent, 0.40);
36 36
is($o->marge_percent_as_percent, '40');
37
is($o->marge_percent_as_percent('22,4'), '22');
37
is($o->marge_percent_as_percent('22,4'), '22,40');
38 38
is($o->marge_percent, 0.224);
39 39
is($o->marge_percent_as_percent, '22');
40 40
is($o->marge_percent(0.231), 0.231);

Auch abrufbar als: Unified diff