Revert r19162 for now, pending further conversation in #Evergreen
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 12 Jan 2011 15:52:37 +0000 (15:52 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 12 Jan 2011 15:52:37 +0000 (15:52 +0000)
about the right way to address this.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19166 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm

index 1a1f4cd..34c85d9 100644 (file)
@@ -167,7 +167,7 @@ sub nth_week_of_month {
         );
     } else {
         # count backwards
-        $nth_day->subtract(days => ($dow - $day + 7) % 7);
+        $nth_day->subtract(days => ($day - $dow + 7) % 7);
 
         # 99: last week of month, 98: second last, etc.
         for (my $i = 99 - $week; $i > 0; $i--) {
@@ -196,10 +196,15 @@ sub check_date {
     if (!defined $day) {
         # MMWW
         return (
-            ($dt->month == $month) && (
-                $dt->week_of_month ==
-                    nth_week_of_month($dt, $weekno, $day)->week_of_month
-            )
+            ($dt->month == $month)
+              && (
+                ($dt->week_of_month == $weekno)
+                || (
+                    $weekno >= 97
+                    && ($dt->week_of_month ==
+                        nth_week_of_month($dt, $weekno, $day)->week_of_month)
+                )
+              )
         );
     }