Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3f24ab6b

Von Bernd Bleßmann vor mehr als 8 Jahren hinzugefügt

  • ID 3f24ab6bd54cf3c96f3659dbe499185f7a00c0bf
  • Vorgänger 454d4b8f
  • Nachfolger bd1f0a5a

Berechnung des nächsten Arbeitstages aus oe.pl und OE.pm in DateTime-Helper …

… verschoben, damit der Code nicht doppelt in OE.pm und oe.pl ist und auch von
woanders verwendet werden kann.

Unterschiede anzeigen:

SL/Helper/DateTime.pm
82 82
  return $self->truncate(to => 'month')->add(months => 1)->subtract(days => 1);
83 83
}
84 84

  
85
sub next_workday {
86
  my ($self, %params) = @_;
87

  
88
  my $extra_days = $params{extra_days} // 1;
89
  $self->add(days => $extra_days);
90

  
91
  my $day_of_week = $self->day_of_week;
92
  $self->add(days => (8 - $day_of_week)) if $day_of_week >= 6;
93

  
94
  return $self;
95
}
96

  
85 97
1;
86 98

  
87 99
__END__
......
131 143
Sets the object to the last day of object's month at midnight. Returns
132 144
the object itself.
133 145

  
146
=item C<next_workday %params>
147

  
148
Sets the object to the next workday. The recognized parameter is:
149

  
150
=over 2
151

  
152
=item * C<extra_days> - optional: If C<extra_days> is given, then
153
that amount of days is added to the objects date and if the resulting
154
date is not a workday, the object is set to the next workday.
155
Defaults to 1.
156

  
157
=back
158

  
159
Returns the object itself.
160

  
134 161
=back
135 162

  
136 163
=head1 AUTHOR

Auch abrufbar als: Unified diff