From a8b18c65bfd47c845e641fb0fff9587f4122bf9d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 23 Sep 2015 09:11:43 +0200 Subject: [PATCH] DateTime: neue Funktion end_of_month Setzt $self auf den Start des letzten Tags eines Monats. --- SL/Helper/DateTime.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SL/Helper/DateTime.pm b/SL/Helper/DateTime.pm index 138a8f3f4..547c4b94b 100644 --- a/SL/Helper/DateTime.pm +++ b/SL/Helper/DateTime.pm @@ -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). The legacy name C is still supported. +=item C + +Sets the object to the last day of object's month at midnight. Returns +the object itself. + =back =head1 AUTHOR -- 2.20.1