[open-ils-commits] r13540 - trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD (djfiander)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jul 8 17:42:58 EDT 2009
Author: djfiander
Date: 2009-07-08 17:42:54 -0400 (Wed, 08 Jul 2009)
New Revision: 13540
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm
Log:
Fix calculation of of date correction.
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm 2009-07-08 21:40:00 UTC (rev 13539)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm 2009-07-08 21:42:54 UTC (rev 13540)
@@ -72,7 +72,7 @@
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 @@
# 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 @@
# 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);
More information about the open-ils-commits
mailing list