if ($duedate && ref $duedate ne 'DateTime') {
$duedate = dt_from_string($duedate);
}
- my $now = DateTime->now( time_zone => C4::Context->tz() );
+ my $now = dt_from_string();
unless ( $duedate ) {
my $issuedate = $now->clone();
}
}
- my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
+ my $issuedate = dt_from_string();
my $calendar = Koha::Calendar->new( branchcode => $branchcode );
# $issuedate defaults to today.
if ( !defined $issuedate ) {
- $issuedate = DateTime->now( time_zone => C4::Context->tz() );
+ $issuedate = dt_from_string();
}
else {
if ( ref $issuedate ne 'DateTime' ) {
$item_object->holdingbranch(C4::Context->userenv->{'branch'});
$item_object->itemlost(0);
$item_object->onloan($datedue->ymd());
- $item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here
+ $item_object->datelastborrowed( dt_from_string()->ymd() );
$item_object->store({log_action => 0});
ModDateLastSeen( $item_object->itemnumber );
return ( 0, 'overdue');
}
- if ( $issue->auto_renew && $patron->autorenewal ) {
+ if ( $issue->auto_renew && $patron->autorenew_checkouts ) {
if ( $patron->category->effective_BlockExpiredPatronOpacActions and $patron->is_expired ) {
return ( 0, 'auto_account_expired' );
$soonestrenewal->truncate( to => 'day' );
}
- if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
+ if ( $soonestrenewal > dt_from_string() )
{
- return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenewal;
+ return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenew_checkouts;
return ( 0, "too_soon" );
}
- elsif ( $issue->auto_renew && $patron->autorenewal ) {
+ elsif ( $issue->auto_renew && $patron->autorenew_checkouts ) {
$auto_renew = 1;
}
}
# Fallback for automatic renewals:
# If norenewalbefore is undef, don't renew before due date.
- if ( $issue->auto_renew && !$auto_renew ) {
+ if ( $issue->auto_renew && !$auto_renew && $patron->autorenew_checkouts ) {
my $now = dt_from_string;
if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){
$auto_renew = 1;
my $itemnumber = shift or return;
my $branch = shift;
my $datedue = shift;
- my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
+ my $lastreneweddate = shift || dt_from_string();
my $skipfinecalc = shift;
my $item_object = Koha::Items->find($itemnumber) or return;
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
dt_from_string( $issue->date_due, 'sql' ) :
- DateTime->now( time_zone => C4::Context->tz());
+ dt_from_string();
$datedue = CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
}
# LOCK TABLES is not transaction-safe and implicitly commits any active transaction before attempting to lock the tables.
# If the LOCK/UNLOCK statements are executed from tests, the current transaction will be committed.
# To avoid that we need to guess if this code is execute from tests or not (yes it is a bit hacky)
- my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_NO_TABLE_LOCKS};
+ my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_TESTING};
for my $mtt (@transports) {
my $letter = C4::Letters::GetPreparedLetter (
$datedue = $startdate->clone;
}
} else {
- $datedue =
- DateTime->now( time_zone => C4::Context->tz() )
- ->truncate( to => 'minute' );
+ $datedue = dt_from_string()->truncate( to => 'minute' );
}
}
#Get how many days the borrower has to reach the age restriction
- my @Today = split /-/, DateTime->today->ymd();
+ my @Today = split /-/, dt_from_string()->ymd();
my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today);
#Negative days means the borrower went past the age restriction age
return ($restriction_year, $daysToAgeRestriction);