https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17699

--- Comment #5 from Jonathan Druart <jonathan.dru...@bugs.koha-community.org> 
---
Just redone some tests and indeed limit seems like to be what we want:

use Modern::Perl;
use Time::Fake;

use Koha::DateUtils;
for my $date ( '2016-03-31', '2016-11-30' ) { 
    my $dt = dt_from_string( $date, 'iso' );
    Time::Fake->offset( $dt->epoch );
    say "=== $date ===";
    say dt_from_string->subtract( months => 1 )->add( months => 1 );
    say dt_from_string->subtract( months => 1, end_of_month => 'limit' )->add(
months => 1 );
    say dt_from_string->subtract( months => 1, end_of_month => 'wrap' )->add(
months => 1 );
    say dt_from_string->subtract( months => 1, end_of_month => 'wrap' )->add(
months => 1 );
}

Returns:
=== 2016-03-31 ===
2016-03-29T00:00:00
2016-03-29T00:00:00 => What we want
2016-04-02T00:00:00
2016-04-02T00:00:00
=== 2016-11-30 ===
2016-12-01T00:00:00
2016-11-30T00:00:00 => What we want
2016-11-30T00:00:00
2016-11-30T00:00:00

Wondering why 'limit' does not work as default...

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
Koha-bugs@lists.koha-community.org
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to