[open-ils-commits] r13462 - in trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD: . test (djfiander)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jun 24 21:50:14 EDT 2009


Author: djfiander
Date: 2009-06-24 21:50:12 -0400 (Wed, 24 Jun 2009)
New Revision: 13462

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t
Log:
Now supports generating dates of combined issues (eg, "May/June").
More test cases are needed, though.

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-06-24 20:40:08 UTC (rev 13461)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-06-25 01:50:12 UTC (rev 13462)
@@ -336,8 +336,8 @@
     my @keys = @_;
     my @cur;
     my @new;
+    my @newend; # only used for combined issues
     my $incr;
-    my @candidate;
 
     my $reg = $self->{_mfhdc_REGULARITY};
     my $pattern = $self->{_mfhdc_PATTERN};
@@ -368,7 +368,8 @@
 	    }
 
 	    foreach my $pat (@pats) {
-		@candidate = $genfunc->($pat, @cur);
+		my @candidate = $genfunc->($pat, @cur);
+
 		while ($self->is_omitted(@candidate)) {
 # 		    printf("# pubpat omitting date '%s'\n",
 # 			   join('/', @candidate));
@@ -386,6 +387,37 @@
 		}
 	    }
 	}
+
+	# Now check for combined issues, like "May/June"
+	foreach my $combpat (@{$pattern->{y}->{c}}) {
+	    my $chroncode = substr($combpat, 0, 1);
+	    my $genfunc = MFHD::Date::generator($chroncode);
+	    my @pats = split(/,/, substr($combpat, 1));
+
+	    foreach my $combined (@pats) {
+		my ($start, $end) = split('/', $combined, 2);
+		my @candidate = $genfunc->($start, @cur);
+
+		# We don't need to check for omitted issues because
+		# combined issues are always published. OR ARE THEY????
+		if (!defined($new[0])
+		    || !on_or_after($candidate[0], $candidate[1], $new[0], $new[1])) {
+		    # Haven't found a next issue at all yet, or
+		    # this one is before the best guess so far
+		    @new = @candidate;
+		    @newend = $genfunc->($end, @cur);
+		}
+	    }
+	}
+
+	if (defined($newend[0])) {
+	    # The best match was a combined issue
+	    foreach my $i (0..$#new) {
+		# don't combine identical fields
+		next if $new[$i] eq $newend[$i];
+		$new[$i] .= '/' . $newend[$i];
+	    }
+	}
     } else {
 	# There is no $y publication pattern defined, so use
 	# the $w frequency to figure out the next date

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t	2009-06-24 20:40:08 UTC (rev 13461)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t	2009-06-25 01:50:12 UTC (rev 13462)
@@ -213,7 +213,7 @@
 
 245 00 $aBimonthly, published 5 times with combined summer issue: Feb, Apr, June/Aug, Oct, Dec
 853 20 $820$av.$bno.$u5$vr$i(year)$j(month)$wb$x02$ypm02,04,10,12$ycm06/08
-863 41 $820.1$a1$b2$i1990$j04$x|a1|b3|i1990|j06/08$zTODO From Apr to Jun/Aug
+863 41 $820.1$a1$b2$i1990$j04$x|a1|b3|i1990|j06/08$zFrom Apr to Jun/Aug
 863 41 $820.2$a1$b3$i1990$j06/08$x|a1|b4|i1990|j10$zFrom Jun/Aug to Oct
 863 41 $820.3$a1$b5$i1990$j12$x|a2|b1|i1991|j02$zWrap at end of year/vol.
 



More information about the open-ils-commits mailing list