[Koha-bugs] [Bug 17699] DateTime durations are not correctly subtracted
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Tue Feb 21 02:31:10 CET 2017
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17699
M. Tompsett <mtompset at hotmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mtompset at hotmail.com
Status|Needs Signoff |In Discussion
--- Comment #3 from M. Tompsett <mtompset at hotmail.com> ---
#!/usr/bin/perl -w
use Modern::Perl;
use Data::Dumper;
use List::MoreUtils qw / none /;
use Time::Fake;
BEGIN {
my @paths = split ':', $ENV{'PERL5LIB'};
if (@paths) {
foreach my $path (@paths) {
if (none { $_ eq $path } @INC) {
push @INC, $path;
}
}
}
}
use Koha::DateUtils;
for my $count (1..366) {
Time::Fake->offset(sprintf("-%dd",$count));
my $old_last_month = dt_from_string->add( months => -1 )->truncate( to =>
'day' );
my $wrap_last_month =
dt_from_string->subtract( months => 1, end_of_month => 'wrap'
)->truncate( to => 'day' );
my $preserve_last_month =
dt_from_string->subtract( months => 1, end_of_month => 'preserve'
)->truncate( to => 'day' );
my $limit_last_month =
dt_from_string->subtract( months => 1, end_of_month => 'limit'
)->truncate( to => 'day' );
my $this_day = dt_from_string;
print sprintf("T:%s O:%s W:%s P:%s
L:%s\n",$this_day,$old_last_month,$wrap_last_month,$preserve_last_month,$limit_last_month);
}
I'm thinking 'limit'for month subtraction.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list