Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ffae956c

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID ffae956c7cc34001662a0081cd587ceda0903abe
  • Vorgänger 7c5f4e40
  • Nachfolger d093f01c

Presenter: Funktion format_man_days()

Unterschiede anzeigen:

SL/Presenter/Text.pm
5 5
use parent qw(Exporter);
6 6

  
7 7
use Exporter qw(import);
8
our @EXPORT = qw(simple_format truncate);
8
our @EXPORT = qw(format_man_days simple_format truncate);
9 9

  
10 10
use Carp;
11 11

  
......
32 32
  return '<p>' . $text;
33 33
}
34 34

  
35
sub format_man_days {
36
  my ($self, $value, %params) = @_;
37

  
38
  return '---' if $params{skip_zero} && !$value;
39

  
40
  return $self->escape($::locale->text('#1 h', $::form->format_amount(\%::myconfig, $value, 2))) if 8.0 > $value;
41

  
42
  $value     /= 8.0;
43
  my $output  = $::locale->text('#1 MD', int($value));
44
  my $rest    = ($value - int($value)) * 8.0;
45
  $output    .= ' ' . $::locale->text('#1 h', $::form->format_amount(\%::myconfig, $rest)) if $rest > 0.0;
46

  
47
  return $self->escape($output);
48
}
49

  
35 50
1;
36 51
__END__
37 52

  
......
53 68

  
54 69
=over 4
55 70

  
71
=item C<format_man_days $value, [%params]>
72

  
73
C<$value> is interpreted to mean a number of hours (for C<$value> < 8)
74
/ man days (if >= 8). Returns a translated, human-readable version of
75
it, e.g. C<2 PT 2 h> for the value C<18> and German.
76

  
77
If the parameter C<skip_zero> is trueish then C<---> is returned
78
instead of the normal formatting if C<$value> equals 0.
79

  
56 80
=item C<truncate $text, [%params]>
57 81

  
58 82
Returns the C<$text> truncated after a certain number of

Auch abrufbar als: Unified diff