X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=Koha%2FCheckout.pm;h=a1a67d66bb51c603f8027b512606febd86634d44;hb=7ecd9e330481389d523da27f962e8e5242c1bbfa;hp=358f41c356bfcf0f498519a2f9e08239e369c2c9;hpb=7276a38c2b67b7ef48b85f544527648b358efa6d;p=srvgit diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index 358f41c356..a1a67d66bb 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -1,6 +1,7 @@ package Koha::Checkout; # Copyright ByWater Solutions 2015 +# Copyright 2016 Koha Development Team # # This file is part of Koha. # @@ -22,6 +23,8 @@ use Modern::Perl; use Carp; use Koha::Database; +use DateTime; +use Koha::DateUtils; use base qw(Koha::Object); @@ -35,6 +38,27 @@ Koha::Checkout - Koha Checkout object class =cut +=head3 is_overdue + +my $is_overdue = $checkout->is_overdue( [ $reference_dt ] ); + +Return 1 if the checkout is overdue. + +A reference date can be passed, in this case it will be used, otherwise today +will be the reference date. + +=cut + +sub is_overdue { + my ( $self, $dt ) = @_; + $dt ||= DateTime->now( time_zone => C4::Context->tz ); + my $is_overdue = + DateTime->compare( dt_from_string( $self->date_due, 'sql' ), $dt ) == -1 + ? 1 + : 0; + return $is_overdue; +} + =head3 type =cut @@ -47,6 +71,8 @@ sub _type { Kyle M Hall +Jonathan Druart + =cut 1;