@@ -, +, @@ far future adjusted in Jonathan's patch. I am moving the compare to the floating timezone (as was done in my original patch). This removes a hardcoded 9999. date with the expiry date. The comparison is now done in the floating timezone. If the expiry date is before the due date, it is returned in the user context's timezone. to loan period of 21 hours. Test checking out with a manual due date /time just before today 23:59 and after that. In the second case the due date/time should become today 23:59 (note that 23:59 is not shown on the checkout form). --- C4/Circulation.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -767,11 +767,11 @@ sub CanBookBeIssued { if ( !defined $borrower->{dateexpiry} || $borrower->{'dateexpiry'} eq '0000-00-00') { $issuingimpossible{EXPIRED} = 1; } else { - my $expiry_dt = dt_from_string( $borrower->{dateexpiry}, 'sql' ); + my $expiry_dt = dt_from_string( $borrower->{dateexpiry}, 'sql', 'floating' ); $expiry_dt->truncate( to => 'day'); my $today = $now->clone()->truncate(to => 'day'); - - if ($expiry_dt->year < 9999 && DateTime->compare($today, $expiry_dt) == 1) { + $today->set_time_zone( 'floating' ); + if ( DateTime->compare($today, $expiry_dt) == 1 ) { $issuingimpossible{EXPIRED} = 1; } } @@ -3448,10 +3448,13 @@ sub CalcDateDue { # if ReturnBeforeExpiry ON the datedue can't be after borrower expirydate if ( C4::Context->preference('ReturnBeforeExpiry') ) { - my $expiry_dt = dt_from_string( $borrower->{dateexpiry}, 'iso' ); - $expiry_dt->set( hour => 23, minute => 59); - if ( DateTime->compare( $datedue, $expiry_dt ) == 1 ) { - $datedue = $expiry_dt->clone; + my $expiry_dt = dt_from_string( $borrower->{dateexpiry}, 'iso', 'floating'); + if( $expiry_dt ) { #skip empty expiry date.. + $expiry_dt->set( hour => 23, minute => 59); + my $d1= $datedue->clone->set_time_zone('floating'); + if ( DateTime->compare( $d1, $expiry_dt ) == 1 ) { + $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); + } } } --