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

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jun 11 21:16:57 EDT 2009


Author: djfiander
Date: 2009-06-11 21:16:55 -0400 (Thu, 11 Jun 2009)
New Revision: 13374

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
Log:
Untested code for generating next dates for all patterns
specified in the standard. Now to write the code that calls the
generators to find the correct "next" issue from the current one.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-06-11 20:43:07 UTC (rev 13373)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-06-12 01:16:55 UTC (rev 13374)
@@ -510,6 +510,25 @@
     return ($pat eq $date[1]);
 }
 
+sub subsequent_season {
+    my $pat = shift;
+    my $cur = shift;
+
+    return undef if (($pat < 21) || ($pat > 24));
+
+    if ($cur->[1] >= $pat) {
+	# current season is on or past pattern season in this year,
+	# advance to next year
+	$cur->[0] += 1;
+    }
+    # Either we've advanced to the next year or the current season
+    # is before the pattern season in the current year. Either way,
+    # all that remains is to set the season properly
+    $cur->[1] = $pat;
+
+    return $cur;
+}
+
 sub match_year {
     my $pat = shift;
     my @date = @_;
@@ -518,6 +537,14 @@
     return 0;
 }
 
+sub subsequent_year {
+    my $pat = shift;
+    my $cur = shift;
+
+    # XXX WRITE ME
+    return undef;
+}
+
 sub match_issue {
     my $pat = shift;
     my @date = @_;
@@ -528,6 +555,14 @@
     return 0;
 }
 
+sub subsequent_issue {
+    my $pat = shift;
+    my $cur = shift;
+
+    # Issue generation is handled separately
+    return undef;
+}
+
 my %dispatch = (
 		'd' => \&match_day,
 		'e' => \&match_issue, # not really a "chron" code
@@ -734,6 +769,15 @@
     }
 }
 
+my %generators = (
+		  'd' => \&subsequent_day,
+		  'e' => \&subsequent_issue, # not a chron code
+		  'w' => \&subsequent_week,
+		  'm' => \&subsequent_month,
+		  's' => \&subsequent_season,
+		  'y' => \&subsequent_year,
+);
+
 sub next_date {
     my $self = shift;
     my $next = shift;



More information about the open-ils-commits mailing list