From: djfiander Date: Wed, 8 Jul 2009 21:42:54 +0000 (+0000) Subject: Fix calculation of of date correction. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=41fcf445375fea2cfde126a7c9cd9a1bf821b35a;p=evergreen%2Ftadl.git Fix calculation of of date correction. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13540 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm index 8d67b7029a..b2b9ac16b2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm @@ -72,7 +72,7 @@ sub subsequent_day { if (exists $daynames{$pat}) { # dd: published on the given weekday my $dow = $dt->day_of_week; - my $corr = ($dow - $daynames{$pat} + 7) % 7; + my $corr = ($daynames{$pat} - $dow + 7) % 7; if ($dow == $daynames{$pat}) { # the next one is one week hence @@ -276,14 +276,11 @@ sub subsequent_week { # Every week $candidate = $dt->clone; -# printf("# subsequent_week: DateTime->clone() failed\n") -# if !defined($candidate); - if ($dt->day_of_week == $daynames{$day}) { # Current is right day, next one is a week hence $candidate->add(days => 7); } else { - $candidate->add(days => ($dt->day_of_week - $daynames{$day} + 7) % 7); + $candidate->add(days => ($daynames{$day} - $dt->day_of_week + 7) % 7); } } else { # 3rd Friday of the month (eg) @@ -306,6 +303,9 @@ sub subsequent_week { # MMWWdd: published on given weekday of given week of given month my ($month, $week, $day) = ($1, $2, $3); +# printf("# subsequent_week: matched /MMWWdd/: month='%s', week='%s', day='%s'\n", +# $month, $week, $day); + $candidate = DateTime->new(year => $dt->year, month=> $month, day => 1);