DateTime: neue Funktion end_of_month
[kivitendo-erp.git] / SL / Helper / DateTime.pm
index 138a8f3..547c4b9 100644 (file)
@@ -77,6 +77,11 @@ sub subtract_businessdays {
   $self->add_business_duration(%params);
 }
 
+sub end_of_month {
+  my ($self) = @_;
+  return $self->truncate(to => 'month')->add(months => 1)->subtract(days => 1);
+}
+
 1;
 
 __END__
@@ -121,6 +126,11 @@ component (as opposed to L<to_kivitendo>).
 
 The legacy name C<from_lxoffice> is still supported.
 
+=item C<end_of_month>
+
+Sets the object to the last day of object's month at midnight. Returns
+the object itself.
+
 =back
 
 =head1 AUTHOR