Lines 1222-1228
sub get_routing_lists {
Link Here
|
1222 |
|
1222 |
|
1223 |
=head3 get_age |
1223 |
=head3 get_age |
1224 |
|
1224 |
|
1225 |
my $age = $patron->get_age |
1225 |
my $age = $patron->get_age |
1226 |
|
1226 |
|
1227 |
Return the age of the patron |
1227 |
Return the age of the patron |
1228 |
|
1228 |
|
Lines 1230-1248
Return the age of the patron
Link Here
|
1230 |
|
1230 |
|
1231 |
sub get_age { |
1231 |
sub get_age { |
1232 |
my ($self) = @_; |
1232 |
my ($self) = @_; |
1233 |
my $today_str = dt_from_string->strftime("%Y-%m-%d"); |
|
|
1234 |
return unless $self->dateofbirth; |
1235 |
my $dob_str = dt_from_string( $self->dateofbirth )->strftime("%Y-%m-%d"); |
1236 |
|
1233 |
|
1237 |
my ( $dob_y, $dob_m, $dob_d ) = split /-/, $dob_str; |
1234 |
return unless $self->dateofbirth; |
1238 |
my ( $today_y, $today_m, $today_d ) = split /-/, $today_str; |
|
|
1239 |
|
1235 |
|
1240 |
my $age = $today_y - $dob_y; |
1236 |
my $date_of_birth = dt_from_string( $self->dateofbirth ); |
1241 |
if ( $dob_m . $dob_d > $today_m . $today_d ) { |
1237 |
my $today = dt_from_string->truncate( to => 'day' ); |
1242 |
$age--; |
|
|
1243 |
} |
1244 |
|
1238 |
|
1245 |
return $age; |
1239 |
return $today->subtract_datetime( $date_of_birth )->years; |
1246 |
} |
1240 |
} |
1247 |
|
1241 |
|
1248 |
=head3 is_valid_age |
1242 |
=head3 is_valid_age |
1249 |
- |
|
|