Mostly mplement issues with combined dates (eg, May/June). Still don't do combined...
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 19 Mar 2009 00:51:10 +0000 (00:51 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 19 Mar 2009 00:51:10 +0000 (00:51 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12589 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t

index b5a1113..b506886 100755 (executable)
@@ -337,10 +337,20 @@ sub match_year {
     my @date = @_;
 
     # XXX WRITE ME
+    return 0;
+}
+
+sub match_issue {
+    my $pat = shift;
+    my @date = @_;
+
+    # XXX WRITE ME
+    return 0;
 }
 
 my %dispatch = (
                'd' => \&match_day,
+               'e' => \&match_issue, # not really a "chron" code
                'w' => \&match_week,
                'm' => \&match_month,
                's' => \&match_season,
@@ -351,7 +361,9 @@ sub regularity_match {
     my $pubcode = shift;
     my @date = @_;
 
-    foreach my $regularity ($self->{_mfhdc_PATTERN}->{y}) {
+    return 0 if !exists $self->{_mfhdc_PATTERN}->{y};
+
+    foreach my $regularity (@{$self->{_mfhdc_PATTERN}->{y}}) {
        next unless $regularity =~ m/^$pubcode/;
 
        my $chroncode= substr($regularity, 1, 1);
@@ -359,6 +371,7 @@ sub regularity_match {
 
        # XXX WRITE ME
        foreach my $pat (@pats) {
+           $pat =~ s|/.+||;    # If it's a combined date, match the start
            if ($dispatch{$chroncode}->($pat, @date)) {
                return 1;
            }
index b5b6bef..bd23795 100755 (executable)
@@ -206,12 +206,6 @@ my %increments = (
                  # x => completely irregular
 );
 
-sub is_combined {
-    my $str = shift;
-
-    return $str =~ m;.+/.+;
-}
-
 sub incr_date {
     my $incr = shift;
     my @new = @_;
@@ -286,8 +280,8 @@ sub next_date {
        $new[$i] = $cur[$i] = $next->{$keys[$i]} if exists $next->{$keys[$i]};
     }
 
-    if (is_combined($new[-1])) {
-       $new[-1] =~ s/^[^\/]+//;
+    if ($new[-1] =~ m;.+/.+;) {
+       $new[-1] =~ s|^[^/]+/||;
     }
 
     # If $frequency is not one of the standard codes defined in %increments
@@ -308,6 +302,14 @@ sub next_date {
        while ($caption->is_omitted(@new)) {
            @new = incr_date($increments{$freq}, @new);
        }
+
+       if ($caption->is_combined(@new)) {
+           my @second_date = incr_date($increments{$freq}, @new);
+
+           # I am cheating: This code assumes that only the smallest
+           # time increment is combined. So, no "Apr 15/May 1" allowed.
+           @new[-1] = @new[-1] . '/' . @second_date[-1];
+       }
     }
 
     for my $i (0..$#new) {
index 51581ef..7996fb0 100644 (file)
@@ -138,25 +138,25 @@ __END__
 
 245 00 $aMonthly, issue no. restarts, Calendar change: Jan, Combined issue: Jan/Feb
 853 20 $87$av.$bno.$u11$vr$i(year)$j(month)$wm$x01$ycm01/02
-863 41 $87.1$a1$b11$i1990$j12$x|a2|b1|i1991|j01/02$zTODO End of year, end of vol.
-863 41 $87.2$a2$b1$i1991$j01/02$x|a2|b2|i1991|j03$zTODO Beginning of year, beginning of vol.
+863 41 $87.1$a1$b11$i1990$j12$x|a2|b1|i1991|j01/02$z End of year, end of vol.
+863 41 $87.2$a2$b1$i1991$j01/02$x|a2|b2|i1991|j03$z Beginning of year, beginning of vol.
 
 245 00 $aMonthly, iss no. restarts, Calendar change: Jan, Combined iss: Nov/Dec
 853 20 $88$av.$bno.$u11$vr$i(year)$j(month)$wm$x01$ycm11/12
-863 41 $88.1$a1$b10$i1990$j10$x|a1|b11|i1990|j11/12$zTODO end of year, end of vol.
-863 41 $88.2$a1$b11$i1990$j11/12$x|a2|b1|i1991|j01$zTODO wrap vol at year end
+863 41 $88.1$a1$b10$i1990$j10$x|a1|b11|i1990|j11/12$z end of year, end of vol.
+863 41 $88.2$a1$b11$i1990$j11/12$x|a2|b1|i1991|j01$z wrap vol at year end
 
 245 00 $aMonthly, iss no. restarts, Cal. change: Jan, Combined iss: Jan/Feb, Nov/Dec
 853 20 $89$av.$bno.$u10$vr$i(year)$j(month)$wm$x01$ycm01/02,11/12
-863 41 $89.1$a1$b1$i1990$j01/02$x|a1|b2|i1990|j03$zTODO beg. of year, beg. of vol.
-863 41 $89.2$a1$b9$i1990$j10$x|a1|b10|i1990|j11/12$zTODO end of year, end of vol.
-863 41 $89.3$a1$b10$i1990$j11/12$x|a2|b1|i1991|j01/02$zTODO zwrap vol at year end
+863 41 $89.1$a1$b1$i1990$j01/02$x|a1|b2|i1990|j03$z beg. of year, beg. of vol.
+863 41 $89.2$a1$b9$i1990$j10$x|a1|b10|i1990|j11/12$z end of year, end of vol.
+863 41 $89.3$a1$b10$i1990$j11/12$x|a2|b1|i1991|j01/02$z zwrap vol at year end
 
 245 00 $aMonthly, iss no. restarts, Cal. change: Jan, Combined iss: May/Jun, Jul/Aug
 853 20 $810$av.$bno.$u10$vr$i(year)$j(month)$wm$x01$ycm05/06,07/08
-863 41 $810.1$a1$b4$i1990$j04$x|a1|b5|i1990|j05/06$zTODO next iss is combined.
-863 41 $810.2$a1$b5$i1990$j05/06$x|a1|b6|i1990|j07/08$zTODO combined to combined
-863 41 $810.3$a1$b6$i1990$j07/08$x|a1|b7|i1990|j09$zTODO combined to reg
+863 41 $810.1$a1$b4$i1990$j04$x|a1|b5|i1990|j05/06$z next iss is combined.
+863 41 $810.2$a1$b5$i1990$j05/06$x|a1|b6|i1990|j07/08$z combined to combined
+863 41 $810.3$a1$b6$i1990$j07/08$x|a1|b7|i1990|j09$z combined to reg
 
 245 00 $aMonthly, issue no. restarts, Calendar change: Jan, Combined issue: 1/2 Jan/Feb 
 853 20 $811$av.$bno.$u12$vr$i(year)$j(month)$wm$x01$ycm01/02$yce21/2