From c633e8536ffec59850f44f8e3d70d7c7c8822f4b Mon Sep 17 00:00:00 2001 From: djfiander Date: Fri, 12 Jun 2009 01:16:55 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13374 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Utils/MFHD/Caption.pm | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm index d6084d537e..ffae61174d 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm @@ -510,6 +510,25 @@ sub match_season { 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 @@ sub match_year { 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 @@ sub match_issue { 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 @@ sub calendar_increment { } } +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; -- 2.11.0