[open-ils-commits] r19162 - trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jan 11 19:24:52 EST 2011


Author: senator
Date: 2011-01-11 19:24:51 -0500 (Tue, 11 Jan 2011)
New Revision: 19162

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm
Log:
Serials: Fix a problem with chronology prediction when there's
a subfield $y in a caption/pattern with a weekly chronology code

Illustrative 853 tag:
 $2$0$8$1$a$v.$b$no.$u$50$v$r$i$(year)$j$(month)$k$(day)$w$w$x$01$y$ow1198,1204
Holding (863) tag:
 $4$1$8$1$a$1$b$39$i$2011$j$09$k$26$x$AUTOGEN

Before this commit, you get a run of predictions that look like this:
v.1:no.40(2011:Oct.03)
v.1:no.41(2011:Oct.10)
v.1:no.42(2011:Oct.17)
v.1:no.43(2011:Oct.24)
v.1:no.44(2011:Oct.31)
v.1:no.45(2011:Nov.07)
v.1:no.46(2011:Nov.21)
v.1:no.47(2011:Nov.28)
v.1:no.48(2011:Dec.05)
v.1:no.49(2011:Dec.12)
v.1:no.50(2011:Dec.26)
v.2:no.1(2012:Jan.02)

Which I'm pretty sure is wrong.  The next-to-last week in November should have
been skipped, and the fourth week in December should have been skipped.  I think
the week number should be defined in terms of the day of the week on which this
weekly serial is published, so fourth week means fourth Monday in this case (?).

With this commit, you get a run of predictions that look like:
v.1:no.40(2011:Oct.03)
v.1:no.41(2011:Oct.10)
v.1:no.42(2011:Oct.17)
v.1:no.43(2011:Oct.24)
v.1:no.44(2011:Oct.31)
v.1:no.45(2011:Nov.07)
v.1:no.46(2011:Nov.14)
v.1:no.47(2011:Nov.28)
v.1:no.48(2011:Dec.05)
v.1:no.49(2011:Dec.12)
v.1:no.50(2011:Dec.19)
v.2:no.1(2012:Jan.02)

Which seems correct to me. I'm going to consult with others before backporting
this to rel_2_0, however.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm	2011-01-11 23:18:43 UTC (rev 19161)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Date.pm	2011-01-12 00:24:51 UTC (rev 19162)
@@ -167,7 +167,7 @@
         );
     } else {
         # count backwards
-        $nth_day->subtract(days => ($day - $dow + 7) % 7);
+        $nth_day->subtract(days => ($dow - $day + 7) % 7);
 
         # 99: last week of month, 98: second last, etc.
         for (my $i = 99 - $week; $i > 0; $i--) {
@@ -196,15 +196,10 @@
     if (!defined $day) {
         # MMWW
         return (
-            ($dt->month == $month)
-              && (
-                ($dt->week_of_month == $weekno)
-                || (
-                    $weekno >= 97
-                    && ($dt->week_of_month ==
-                        nth_week_of_month($dt, $weekno, $day)->week_of_month)
-                )
-              )
+            ($dt->month == $month) && (
+                $dt->week_of_month ==
+                    nth_week_of_month($dt, $weekno, $day)->week_of_month
+            )
         );
     }
 



More information about the open-ils-commits mailing list