Avoid expire dates far in the future on invalid DoB's by assuming no
students are younger than 2 years old for the purposes of calculating
the expire date.
Note, this does not affect the stored DoB. We store whatever is sent.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
my $now_year = DateTime->now->year;
my $expire_year = $now_year + (18 - ($now_year - $year));
+ # Invalid DoB's can lead to expire_date's far in the future.
+ # If a student's birth year puts them at less than 2 years old,
+ # modify the year to make them appear 2 years old for calculating
+ # the expire year. We retain the provided day and month.
+ $expire_year = ($now_year + 16) if ($expire_year - $now_year) > 16;
+
# if dob occurs after july 1, expire date will occur the following year.
$expire_year++ if ($mon > 7) or ($mon == 7 and $day > 1);