From ccaca87c2037c4b67943f6f49ab9e88bb471e45e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 Aug 2021 14:00:51 +0200 Subject: [PATCH] Bug 28931: Use EXPORT_OK from Koha::AuthUtils --- C4/Acquisition.pm | 4 +-- C4/Barcodes/annual.pm | 8 ++--- C4/Barcodes/hbyymmincr.pm | 8 ++--- C4/Circulation.pm | 12 +++---- C4/Items.pm | 4 +-- C4/Letters.pm | 2 +- C4/Members.pm | 2 +- C4/Reports/Guided.pm | 4 +-- C4/Reserves.pm | 2 +- C4/Search/History.pm | 2 +- C4/Stats.pm | 2 +- C4/Suggestions.pm | 2 +- Koha/Account/Line.pm | 4 +-- Koha/Acquisition/Order.pm | 6 ++-- Koha/Acquisition/Orders.pm | 2 +- Koha/Authority/MergeRequests.pm | 4 +-- Koha/BackgroundJob.pm | 2 +- Koha/BackgroundJob/BatchUpdateAuthority.pm | 4 +-- Koha/BackgroundJob/BatchUpdateBiblio.pm | 4 +-- Koha/Biblio.pm | 4 +-- Koha/Checkout.pm | 2 +- Koha/Checkouts.pm | 4 +-- Koha/Club/Enrollment.pm | 2 +- Koha/DateUtils.pm | 16 ++++++--- Koha/Hold.pm | 2 +- Koha/Item.pm | 6 ++-- Koha/Item/Transfer.pm | 6 ++-- Koha/Objects.pm | 2 +- Koha/Old/Checkouts.pm | 2 +- Koha/Patron.pm | 16 ++++----- Koha/Patron/Category.pm | 2 +- Koha/Patron/Discharge.pm | 6 ++-- Koha/Patrons.pm | 8 ++--- Koha/Quotes.pm | 2 +- Koha/StockRotationItem.pm | 2 +- Koha/Virtualshelf.pm | 6 ++-- Koha/Virtualshelfshare.pm | 4 +-- Koha/pdfformat/layout2pages.pm | 2 +- Koha/pdfformat/layout2pagesde.pm | 2 +- Koha/pdfformat/layout3pages.pm | 2 +- Koha/pdfformat/layout3pagesfr.pm | 2 +- acqui/duplicate_orders.pl | 4 +-- acqui/histsearch.pl | 4 +-- acqui/neworderempty.pl | 2 +- acqui/orderreceive.pl | 2 +- acqui/parcels.pl | 4 +-- admin/aqbudgetperiods.pl | 4 +-- admin/aqcontract.pl | 2 +- cataloguing/addbiblio.pl | 2 +- cataloguing/additem.pl | 2 +- cataloguing/value_builder/barcode.pl | 2 +- cataloguing/value_builder/barcode_manual.pl | 2 +- cataloguing/value_builder/dateaccessioned.pl | 2 +- circ/circulation.pl | 2 +- circ/pendingreserves.pl | 2 +- circ/reserveratios.pl | 2 +- circ/transferstoreceive.pl | 2 +- circ/waitingreserves.pl | 2 +- members/memberentry.pl | 4 +-- misc/add_date_fields_to_marc_records.pl | 2 +- misc/cronjobs/archive_purchase_suggestions.pl | 2 +- misc/cronjobs/gather_print_notices.pl | 4 +-- misc/cronjobs/serialsUpdate.pl | 2 +- misc/cronjobs/staticfines.pl | 2 +- opac/opac-memberentry.pl | 2 +- opac/opac-showreviews.pl | 4 +-- opac/opac-suggestions.pl | 2 +- opac/sco/sco-main.pl | 2 +- reports/cash_register_stats.pl | 8 ++--- reserve/request.pl | 2 +- serials/serials-collection.pl | 4 +-- serials/serials-edit.pl | 2 +- serials/showpredictionpattern.pl | 2 +- serials/subscription-renew.pl | 2 +- suggestion/suggestion.pl | 16 ++++----- svc/hold/resume | 2 +- svc/hold/suspend | 2 +- svc/members/search | 2 +- svc/renew | 2 +- t/DateUtils.t | 2 +- t/db_dependent/Acquisition/NewOrder.t | 2 +- t/db_dependent/Authority/MergeRequests.t | 2 +- t/db_dependent/Circulation.t | 34 +++++++++---------- .../IssuingRules/maxsuspensiondays.t | 4 +-- .../Circulation/MarkIssueReturned.t | 2 +- t/db_dependent/Circulation/Returns.t | 2 +- .../Circulation/SwitchOnSiteCheckouts.t | 4 +-- t/db_dependent/Circulation/issue.t | 6 ++-- t/db_dependent/Circulation/transfers.t | 6 ++-- t/db_dependent/Contract.t | 2 +- t/db_dependent/Hold.t | 2 +- t/db_dependent/Holds.t | 4 +-- t/db_dependent/HoldsQueue.t | 4 +-- t/db_dependent/ILSDI_Services.t | 2 +- t/db_dependent/Items.t | 2 +- .../Items/AutomaticItemModificationByAge.t | 2 +- t/db_dependent/Koha/Account.t | 2 +- t/db_dependent/Koha/Acquisition/Basket.t | 8 ++--- t/db_dependent/Koha/Acquisition/Booksellers.t | 4 +-- t/db_dependent/Koha/Acquisition/Budgets.t | 2 +- t/db_dependent/Koha/Acquisition/Invoice.t | 4 +-- t/db_dependent/Koha/Acquisition/Order.t | 10 +++--- t/db_dependent/Koha/AdditionalContents.t | 4 +-- t/db_dependent/Koha/BackgroundJobs.t | 2 +- t/db_dependent/Koha/Biblios.t | 2 +- t/db_dependent/Koha/Charges/Fees.t | 2 +- t/db_dependent/Koha/Checkouts.t | 4 +-- t/db_dependent/Koha/Checkouts/ReturnClaim.t | 2 +- t/db_dependent/Koha/Club/Enrollment.t | 2 +- t/db_dependent/Koha/Club/Hold.t | 4 +-- t/db_dependent/Koha/Item.t | 4 +-- t/db_dependent/Koha/Item/Transfer.t | 10 +++--- t/db_dependent/Koha/Item/Transfers.t | 8 ++--- t/db_dependent/Koha/ItemTypes.t | 2 +- t/db_dependent/Koha/Object.t | 2 +- t/db_dependent/Koha/Objects.t | 2 +- t/db_dependent/Koha/Patron.t | 2 +- t/db_dependent/Koha/Patron/Consents.t | 2 +- t/db_dependent/Koha/Patrons.t | 8 ++--- t/db_dependent/Koha/Pseudonymization.t | 8 ++--- t/db_dependent/Koha/Quotes.t | 6 ++-- t/db_dependent/Letters.t | 4 +-- t/db_dependent/Letters/TemplateToolkit.t | 2 +- t/db_dependent/Members/IssueSlip.t | 6 ++-- t/db_dependent/Patrons.t | 2 +- t/db_dependent/Reserves.t | 6 ++-- t/db_dependent/SIP/Message.t | 6 ++-- t/db_dependent/SIP/Transaction.t | 4 +-- t/db_dependent/Search/History.t | 4 +-- t/db_dependent/Serials.t | 4 +-- t/db_dependent/Serials/Claims.t | 2 +- t/db_dependent/Suggestions.t | 8 ++--- t/db_dependent/Template/Plugin/KohaDates.t | 2 +- t/db_dependent/Upload.t | 2 +- t/db_dependent/Virtualshelves.t | 4 +-- t/db_dependent/api/v1/return_claims.t | 2 +- t/lib/Koha/BackgroundJob/BatchTest.pm | 4 +-- t/lib/TestBuilder.pm | 10 +++--- tools/batchMod.pl | 2 +- tools/cleanborrowers.pl | 8 ++--- tools/holidays.pl | 2 +- tools/inventory.pl | 4 +-- 142 files changed, 286 insertions(+), 280 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 3d74f847a69..0fd3b00bf57 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1373,7 +1373,7 @@ sub ModReceiveOrder { my $dbh = C4::Context->dbh; $datereceived = output_pref( { - dt => ( $datereceived ? dt_from_string( $datereceived ) : dt_from_string ), + dt => ( $datereceived ? dt_from_string( $datereceived ) : dt_from_string() ), dateformat => 'iso', dateonly => 1, } @@ -2689,7 +2689,7 @@ sub CloseInvoice { Reopen an invoice -Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string, dateonly=>1, otputpref=>'iso' })) +Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string(), dateonly=>1, otputpref=>'iso' })) =cut diff --git a/C4/Barcodes/annual.pm b/C4/Barcodes/annual.pm index 0d7e05ae00a..6ce21ec02aa 100644 --- a/C4/Barcodes/annual.pm +++ b/C4/Barcodes/annual.pm @@ -45,10 +45,10 @@ sub db_max { $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg unless ($iso) { warn "Failed to create 'iso' Dates object with input '$input'. Reverting to today's date."; - $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # failover back to today + $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # failover back to today } } else { - $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); } my $year = substr($iso,0,4); # YYYY $sth->execute("$year-%"); @@ -58,7 +58,7 @@ sub db_max { sub initial () { my $self = shift; - return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1); + return substr(output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1); } sub parse { @@ -78,7 +78,7 @@ sub width { sub process_head { my ($self,$head,$whole,$specific) = @_; $specific and return $head; # if this is built off an existing barcode, just return the head unchanged. - return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY- + return substr(output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY- } sub new_object { diff --git a/C4/Barcodes/hbyymmincr.pm b/C4/Barcodes/hbyymmincr.pm index bd345a6d62d..e0265af6111 100644 --- a/C4/Barcodes/hbyymmincr.pm +++ b/C4/Barcodes/hbyymmincr.pm @@ -47,10 +47,10 @@ sub db_max { $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg unless ($iso) { warn "Failed to create 'iso' Dates object with input '$input'. Reverting to today's date."; - $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # failover back to today + $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # failover back to today } } else { - $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); } my $year = substr($iso,2,2); # i.e. "08" for 2008 my $andtwo = $width+2; @@ -67,7 +67,7 @@ sub db_max { sub initial { my $self = shift; # FIXME: populated branch? - my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" + my $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" warn "HBYYMM Barcode was not passed a branch, default is blank" if ( $self->branch eq '' ); my $width = WIDTH; return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1); @@ -101,7 +101,7 @@ sub process_head { # (self,head,whole,specific) my ($self,$head,$whole,$specific) = @_; $specific and return $head; # if this is built off an existing barcode, just return the head unchanged. $head =~ s/\d{4}$//; # else strip the old yymm - my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" + my $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" return $head . substr($iso,2,2) . substr($iso,5,2); } diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 03332f3836f..3711d85822e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1502,7 +1502,7 @@ sub AddIssue { # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) $transfer->set( { - datearrived => dt_from_string, + datearrived => dt_from_string(), tobranch => C4::Context->userenv->{branch}, comments => 'Forced branchtransfer' } @@ -2802,7 +2802,7 @@ sub CanBookBeRenewed { $maximum_renewal_date->add( $issuing_rule->{lengthunit} => $issuing_rule->{no_auto_renewal_after} ); - my $now = dt_from_string; + my $now = dt_from_string(); if ( $now >= $maximum_renewal_date ) { return ( 0, "auto_too_late" ); } @@ -2810,7 +2810,7 @@ sub CanBookBeRenewed { if ( defined $issuing_rule->{no_auto_renewal_after_hard_limit} and $issuing_rule->{no_auto_renewal_after_hard_limit} ne "" ) { # If no_auto_renewal_after_hard_limit is >= today, it's also too late for renewal - if ( dt_from_string >= dt_from_string( $issuing_rule->{no_auto_renewal_after_hard_limit} ) ) { + if ( dt_from_string() >= dt_from_string( $issuing_rule->{no_auto_renewal_after_hard_limit} ) ) { return ( 0, "auto_too_late" ); } } @@ -2854,7 +2854,7 @@ sub CanBookBeRenewed { # Fallback for automatic renewals: # If norenewalbefore is undef, don't renew before due date. if ( $issue->auto_renew && $auto_renew eq "no" && $patron->autorenew_checkouts ) { - my $now = dt_from_string; + my $now = dt_from_string(); if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){ $auto_renew = "ok"; } else { @@ -3245,7 +3245,7 @@ sub GetSoonestRenewDate { } ); - my $now = dt_from_string; + my $now = dt_from_string(); return $now unless $issuing_rule; if ( defined $issuing_rule->{norenewalbefore} @@ -3586,7 +3586,7 @@ sub updateWrongTransfer { # first step: cancel the original transfer my $item = Koha::Items->find($itemNumber); my $transfer = $item->get_transfer; - $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store(); + $transfer->set({ datecancelled => dt_from_string(), cancellation_reason => 'WrongTransfer' })->store(); # second step: create a new transfer to the right location my $new_transfer = $item->request_transfer( diff --git a/C4/Items.pm b/C4/Items.pm index 7f83736ace6..305e6b00e71 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -395,7 +395,7 @@ The last optional parameter allows for passing skip_record_index through to the sub ModDateLastSeen { my ( $itemnumber, $leave_item_lost, $params ) = @_; - my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); my $item = Koha::Items->find($itemnumber); $item->datelastseen($today); @@ -1610,7 +1610,7 @@ sub PrepareItemrecordDisplay { } else { $defaultvalue =~ s/"/"/g; # get today date & replace <>, <>, <
> if provided in the default value - my $today_dt = dt_from_string; + my $today_dt = dt_from_string(); my $year = $today_dt->strftime('%Y'); my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); diff --git a/C4/Letters.pm b/C4/Letters.pm index 87b82624c61..2a9b86d36d6 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1820,7 +1820,7 @@ sub _get_tt_params { } } - $params->{today} = output_pref({ dt => dt_from_string, dateformat => 'iso' }); + $params->{today} = output_pref({ dt => dt_from_string(), dateformat => 'iso' }); return $params; } diff --git a/C4/Members.pm b/C4/Members.pm index 210a9ea0de3..f89b4739168 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -557,7 +557,7 @@ sub IssueSlip { ); } else { - my $today = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string ); + my $today = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string() ); # Checkouts due in the future my $checkouts = $pending_checkouts->search({ date_due => { '>' => $today } }); my @checkouts; my @overdues; diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index 6611393ca05..b4e3089049b 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -624,7 +624,7 @@ sub save_report { my $public = $fields->{public}; $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ - my $now = dt_from_string; + my $now = dt_from_string(); my $report = Koha::Report->new( { borrowernumber => $borrowernumber, @@ -658,7 +658,7 @@ sub update_sql { $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ my $report = Koha::Reports->find($id); - $report->last_modified(dt_from_string); + $report->last_modified(dt_from_string()); $report->savedsql($sql); $report->report_name($name); $report->notes($notes); diff --git a/C4/Reserves.pm b/C4/Reserves.pm index f2ee4639797..9c5edc16472 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -195,7 +195,7 @@ sub AddReserve { my $non_priority = $params->{non_priority}; $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) - or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); + or output_pref({ dt => dt_from_string(), dateonly => 1, dateformat => 'iso' }); $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' }); diff --git a/C4/Search/History.pm b/C4/Search/History.pm index df36cb0fbc7..1e8c57194f8 100644 --- a/C4/Search/History.pm +++ b/C4/Search/History.pm @@ -43,7 +43,7 @@ sub add_to_session { my $type = $params->{type} || 'biblio'; # To a cookie (the user is not logged in) - my $now = dt_from_string; + my $now = dt_from_string(); my $id = $now->year . $now->month . $now->day . $now->hour . $now->minute . $now->second . int(rand(100)); my @recent_searches = get_from_session( { cgi => $cgi } ); push @recent_searches, { diff --git a/C4/Stats.pm b/C4/Stats.pm index 1b883d2de18..4c80c1f5af6 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -127,7 +127,7 @@ sub UpdateStats { my $dtf = Koha::Database->new->schema->storage->datetime_parser; my $statistic = Koha::Statistic->new( { - datetime => $dtf->format_datetime( dt_from_string ), + datetime => $dtf->format_datetime( dt_from_string() ), branch => $branch, type => $type, value => $amount, diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index ba72a1888ad..5c18c21ec5e 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -397,7 +397,7 @@ sub NewSuggestion { $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; - $suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; + $suggestion->{suggesteddate} = dt_from_string() unless $suggestion->{suggesteddate}; delete $suggestion->{branchcode} if $suggestion->{branchcode} eq ''; diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index c0964fc006d..3606347fddc 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -1068,7 +1068,7 @@ sub store { $max //= 0; $self->credit_number($max + 1); } elsif ($AutoCreditNumber eq 'annual') { - my $now = dt_from_string; + my $now = dt_from_string(); my $prefix = sprintf('%d-', $now->year); my $max = $rs->search({ -and => [ @@ -1083,7 +1083,7 @@ sub store { my $userenv = C4::Context->userenv; if ($userenv) { my $branch = $userenv->{branch}; - my $now = dt_from_string; + my $now = dt_from_string(); my $prefix = sprintf('%s%d%02d', $branch, $now->year, $now->month); my $pattern = $prefix; $pattern =~ s/([\?%_])/\\$1/g; diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index 090920d92c1..179f65c57fa 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -87,7 +87,7 @@ sub store { } $self->quantityreceived(0) unless $self->quantityreceived; - $self->entrydate(dt_from_string) unless $self->entrydate; + $self->entrydate(dt_from_string()) unless $self->entrydate; $self->ordernumber(undef) unless $self->ordernumber; $self = $self->SUPER::store( $self ); @@ -428,8 +428,8 @@ sub duplicate_to { { undef $order_info->{$field}; } - $order_info->{placed_on} = dt_from_string; - $order_info->{entrydate} = dt_from_string; + $order_info->{placed_on} = dt_from_string(); + $order_info->{entrydate} = dt_from_string(); $order_info->{orderstatus} = 'new'; $order_info->{quantityreceived} = 0; while ( my ( $field, $value ) = each %$default_values ) { diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm index b2496260a98..a99d81be696 100644 --- a/Koha/Acquisition/Orders.pm +++ b/Koha/Acquisition/Orders.pm @@ -79,7 +79,7 @@ sub filter_by_lates { push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date($estimated_to) ]; } if ( defined $estimated_from and not defined $estimated_to ) { - push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date(dt_from_string) ]; + push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date(dt_from_string()) ]; } $self->search( diff --git a/Koha/Authority/MergeRequests.pm b/Koha/Authority/MergeRequests.pm index 481118e0f57..3241dbadbc2 100644 --- a/Koha/Authority/MergeRequests.pm +++ b/Koha/Authority/MergeRequests.pm @@ -62,14 +62,14 @@ sub cron_cleanup { my $remove_days = $params->{remove_days} || 30; my $parser = Koha::Database->new->schema->storage->datetime_parser; - my $dt = dt_from_string; + my $dt = dt_from_string(); $dt->subtract( hours => $reset_hours ); $class_or_self->search({ done => 2, timestamp => { '<' => $parser->format_datetime($dt) }, })->update({ done => 0 }); - $dt = dt_from_string; + $dt = dt_from_string(); $dt->subtract( days => $remove_days ); $class_or_self->search({ done => 1, diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index c303fa175ec..57f87214ee3 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -110,7 +110,7 @@ sub enqueue { type => $job_type, size => $job_size, data => $json_args, - enqueued_on => dt_from_string, + enqueued_on => dt_from_string(), borrowernumber => $borrowernumber, } )->store; diff --git a/Koha/BackgroundJob/BatchUpdateAuthority.pm b/Koha/BackgroundJob/BatchUpdateAuthority.pm index 5969a1311d5..0b10ec68cb3 100644 --- a/Koha/BackgroundJob/BatchUpdateAuthority.pm +++ b/Koha/BackgroundJob/BatchUpdateAuthority.pm @@ -62,7 +62,7 @@ sub process { } my $job_progress = 0; - $job->started_on(dt_from_string) + $job->started_on(dt_from_string()) ->progress($job_progress) ->status('started') ->store; @@ -107,7 +107,7 @@ sub process { $job_data->{messages} = \@messages; $job_data->{report} = $report; - $job->ended_on(dt_from_string) + $job->ended_on(dt_from_string()) ->data(encode_json $job_data); $job->status('finished') if $job->status ne 'cancelled'; $job->store; diff --git a/Koha/BackgroundJob/BatchUpdateBiblio.pm b/Koha/BackgroundJob/BatchUpdateBiblio.pm index 9371e2212ff..2a11b860004 100644 --- a/Koha/BackgroundJob/BatchUpdateBiblio.pm +++ b/Koha/BackgroundJob/BatchUpdateBiblio.pm @@ -64,7 +64,7 @@ sub process { # Then we will start from scratch and so double process the same records my $job_progress = 0; - $job->started_on(dt_from_string) + $job->started_on(dt_from_string()) ->progress($job_progress) ->status('started') ->store; @@ -112,7 +112,7 @@ sub process { $job_data->{messages} = \@messages; $job_data->{report} = $report; - $job->ended_on(dt_from_string) + $job->ended_on(dt_from_string()) ->data(encode_json $job_data); $job->status('finished') if $job->status ne 'cancelled'; $job->store; diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 26ee7abd960..58c80ea32f4 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -61,7 +61,7 @@ Overloaded I method to set default values sub store { my ( $self ) = @_; - $self->datecreated( dt_from_string ) unless $self->datecreated; + $self->datecreated( dt_from_string() ) unless $self->datecreated; return $self->SUPER::store; } @@ -461,7 +461,7 @@ sub current_holds { my ($self) = @_; my $dtf = Koha::Database->new->schema->storage->datetime_parser; return $self->holds( - { reservedate => { '<=' => $dtf->format_date(dt_from_string) } } ); + { reservedate => { '<=' => $dtf->format_date(dt_from_string()) } } ); } =head3 biblioitem diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index cc001942485..568ea531345 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -174,7 +174,7 @@ sub claim_returned { borrowernumber => $self->borrowernumber, notes => $params->{notes}, created_by => $params->{created_by}, - created_on => dt_from_string, + created_on => dt_from_string(), } )->store(); diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm index 76a3b9e6868..15a7dfdb88c 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -56,7 +56,7 @@ sub calculate_dropbox_date { } ); my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); - my $today = dt_from_string; + my $today = dt_from_string(); my $dropbox_date = $calendar->addDuration( $today, -1 ); return $dropbox_date; @@ -73,7 +73,7 @@ Checks in every due issue which itemtype has automatic_checkin enabled sub automatic_checkin { my ($self, $params) = @_; - my $current_date = dt_from_string; + my $current_date = dt_from_string(); my $dtf = Koha::Database->new->schema->storage->datetime_parser; my $due_checkouts = $self->search( diff --git a/Koha/Club/Enrollment.pm b/Koha/Club/Enrollment.pm index e9e434bc176..4b9e8433afd 100644 --- a/Koha/Club/Enrollment.pm +++ b/Koha/Club/Enrollment.pm @@ -82,7 +82,7 @@ sub is_canceled { my ( $self ) = @_; return 0 unless $self->date_canceled; - my $today = dt_from_string; + my $today = dt_from_string(); my $date_canceled = dt_from_string( $self->date_canceled ); return DateTime->compare($date_canceled, $today) < 1; diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 9b599e3c6d5..f5becf04056 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -21,11 +21,17 @@ use DateTime; use C4::Context; use Koha::Exceptions; -use base 'Exporter'; - -our @EXPORT = ( - qw( dt_from_string output_pref format_sqldatetime ) -); +use vars qw(@ISA @EXPORT_OK); +BEGIN { + require Exporter; + @ISA = qw(Exporter); + + @EXPORT_OK = qw( + dt_from_string + output_pref + format_sqldatetime + ); +} =head1 DateUtils diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 0aa9eab133c..725fa9a116b 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -62,7 +62,7 @@ my $age = $hold->age( $use_calendar ); sub age { my ( $self, $use_calendar ) = @_; - my $today = dt_from_string; + my $today = dt_from_string(); my $age; if ( $use_calendar ) { diff --git a/Koha/Item.pm b/Koha/Item.pm index 60d80a5c3eb..e1741782a65 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -89,7 +89,7 @@ sub store { $self->itype($self->biblio->biblioitem->itemtype); } - my $today = dt_from_string; + my $today = dt_from_string(); my $action = 'create'; unless ( $self->in_storage ) { #AddItem @@ -461,7 +461,7 @@ sub request_transfer { my $transfer = Koha::Item::Transfer->new( { itemnumber => $self->itemnumber, - daterequested => dt_from_string, + daterequested => dt_from_string(), frombranch => $self->holdingbranch, tobranch => $params->{to}->branchcode, reason => $params->{reason}, @@ -793,7 +793,7 @@ sub current_holds { itemnumber => $self->itemnumber, suspend => 0, -or => [ - reservedate => { '<=' => $dtf->format_date(dt_from_string) }, + reservedate => { '<=' => $dtf->format_date(dt_from_string()) }, waitingdate => { '!=' => undef }, ], }; diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm index 286e0fd276f..474b6f2ce14 100644 --- a/Koha/Item/Transfer.pm +++ b/Koha/Item/Transfer.pm @@ -103,7 +103,7 @@ sub transit { $self->set( { frombranch => $self->item->holdingbranch, - datesent => dt_from_string, + datesent => dt_from_string(), } )->store; @@ -139,7 +139,7 @@ sub receive { Koha::Exceptions::Item::Transfer::OnLoan->throw() if ($self->item->checkout); # Update the arrived date - $self->set({ datearrived => dt_from_string })->store; + $self->set({ datearrived => dt_from_string() })->store; ModDateLastSeen( $self->item->itemnumber ); return $self; @@ -165,7 +165,7 @@ sub cancel { # Update the cancelled date $self->set( - { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } ) + { datecancelled => dt_from_string(), cancellation_reason => $params->{reason} } ) ->store; return $self; diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 3ee0a55742d..4dfda537a2e 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -276,7 +276,7 @@ sub filter_by_last_update { my $dtf = Koha::Database->new->schema->storage->datetime_parser; if ( exists $params->{days} ) { - my $dt = Koha::DateUtils::dt_from_string(); + my $dt = dt_from_string(); my $operator = $days_inclusive ? '<=' : '<'; $conditions->{$operator} = $dtf->format_date( $dt->subtract( days => $params->{days} ) ); } diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm index ec8b2239076..ec0d20ce204 100644 --- a/Koha/Old/Checkouts.pm +++ b/Koha/Old/Checkouts.pm @@ -27,7 +27,7 @@ sub filter_by_todays_checkins { my ( $self ) = @_; my $dtf = Koha::Database->new->schema->storage->datetime_parser; - my $today = dt_from_string; + my $today = dt_from_string(); my $today_start = $today->clone->set( hour => 0, minute => 0, second => 0 ); my $today_end = $today->clone->set( hour => 23, minute => 59, second => 59 ); $today_start = $dtf->format_datetime( $today_start ); diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 941dace0df8..4a45abdcdbd 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -218,7 +218,7 @@ sub store { # Add enrollment date if it isn't already there unless ( $self->dateenrolled ) { - $self->dateenrolled(dt_from_string); + $self->dateenrolled(dt_from_string()); } # Set the privacy depending on the patron's category @@ -747,7 +747,7 @@ sub is_debarred { return unless $self->debarred; return $self->debarred if $self->debarred =~ '^9999' - or dt_from_string( $self->debarred ) > dt_from_string; + or dt_from_string( $self->debarred ) > dt_from_string(); return; } @@ -890,12 +890,12 @@ sub renew_account { my ($self) = @_; my $date; if ( C4::Context->preference('BorrowerRenewalPeriodBase') eq 'combination' ) { - $date = ( dt_from_string gt dt_from_string( $self->dateexpiry ) ) ? dt_from_string : dt_from_string( $self->dateexpiry ); + $date = ( dt_from_string() gt dt_from_string( $self->dateexpiry ) ) ? dt_from_string() : dt_from_string( $self->dateexpiry ); } else { $date = C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry' ? dt_from_string( $self->dateexpiry ) - : dt_from_string; + : dt_from_string(); } my $expiry_date = $self->category->get_expiry_date($date); @@ -1120,7 +1120,7 @@ sub get_overdues { my $dtf = Koha::Database->new->schema->storage->datetime_parser; return $self->checkouts->search( { - 'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) }, + 'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string()) }, }, { prefetch => { item => { biblio => 'biblioitems' } }, @@ -1152,7 +1152,7 @@ Return the age of the patron sub get_age { my ($self) = @_; - my $today_str = dt_from_string->strftime("%Y-%m-%d"); + my $today_str = dt_from_string()->strftime("%Y-%m-%d"); return unless $self->dateofbirth; my $dob_str = dt_from_string( $self->dateofbirth )->strftime("%Y-%m-%d"); @@ -1648,7 +1648,7 @@ sub lock { my ( $self, $params ) = @_; $self->login_attempts( ADMINISTRATIVE_LOCKOUT ); if( $params->{expire} ) { - $self->dateexpiry( dt_from_string->subtract(days => 1) ); + $self->dateexpiry( dt_from_string()->subtract(days => 1) ); } $self->store; if( $params->{remove} ) { @@ -1703,7 +1703,7 @@ sub _anonymize_column { } elsif( $type =~ /integer|int$|float|dec|double/ ) { $val = $nullable ? undef : 0; } elsif( $type =~ /date|time/ ) { - $val = $nullable ? undef : dt_from_string; + $val = $nullable ? undef : dt_from_string(); } $self->$col($val); } diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm index 892d00c2ae2..22f19214dbf 100644 --- a/Koha/Patron/Category.pm +++ b/Koha/Patron/Category.pm @@ -105,7 +105,7 @@ sub default_messaging { sub get_expiry_date { my ($self, $date ) = @_; if ( $self->enrolmentperiod ) { - $date ||= dt_from_string; + $date ||= dt_from_string(); $date = dt_from_string( $date ) unless ref $date; return $date->add( months => $self->enrolmentperiod, end_of_month => 'limit' ); } else { diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm index 8ad1696bc5d..3b497a2be5f 100644 --- a/Koha/Patron/Discharge.pm +++ b/Koha/Patron/Discharge.pm @@ -66,7 +66,7 @@ sub request { my $rs = Koha::Database->new->schema->resultset('Discharge'); return $rs->create({ borrower => $borrowernumber, - needed => dt_from_string, + needed => dt_from_string(), }); } @@ -92,12 +92,12 @@ sub discharge { my $rs = Koha::Database->new->schema->resultset('Discharge'); my $discharge = $rs->search({ borrower => $borrowernumber }, { order_by => { -desc => 'needed' }, rows => 1 }); if( $discharge->count > 0 ) { - $discharge->update({ validated => dt_from_string }); + $discharge->update({ validated => dt_from_string() }); } else { $rs->create({ borrower => $borrowernumber, - validated => dt_from_string, + validated => dt_from_string(), }); } } diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index 4f2b55956a7..c774df8d50b 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -112,8 +112,8 @@ sub search_upcoming_membership_expires { delete $params->{after}; my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0; - my $date_before = dt_from_string->add( days => $days - $before ); - my $date_after = dt_from_string->add( days => $days + $after ); + my $date_before = dt_from_string()->add( days => $days - $before ); + my $date_after = dt_from_string()->add( days => $days + $after ); my $dtf = Koha::Database->new->schema->storage->datetime_parser; $params->{dateexpiry} = { @@ -137,7 +137,7 @@ sub search_patrons_to_anonymise { my ( $class, $params ) = @_; my $older_than_date = $params->{before}; my $library = $params->{library}; - $older_than_date = $older_than_date ? dt_from_string($older_than_date) : dt_from_string; + $older_than_date = $older_than_date ? dt_from_string($older_than_date) : dt_from_string(); $library ||= ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch} ) ? C4::Context->userenv->{branch} @@ -174,7 +174,7 @@ sub anonymise_issue_history { my $older_than_date = $params->{before}; - $older_than_date = dt_from_string $older_than_date if $older_than_date; + $older_than_date = dt_from_string( $older_than_date ) if $older_than_date; # The default of 0 does not work due to foreign key constraints # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry diff --git a/Koha/Quotes.pm b/Koha/Quotes.pm index d9fc43f9bf4..c647290514f 100644 --- a/Koha/Quotes.pm +++ b/Koha/Quotes.pm @@ -69,7 +69,7 @@ sub get_daily_quote { # Fall through... we also return a random quote as a catch-all if all else fails } else { - my $dt = $dtf->format_date(dt_from_string); + my $dt = $dtf->format_date(dt_from_string()); $quote = $self->search( { timestamp => { -between => => [ "$dt 00:00:00", "$dt 23:59:59" ] }, diff --git a/Koha/StockRotationItem.pm b/Koha/StockRotationItem.pm index 58f0a6c25b6..a034ec8dd79 100644 --- a/Koha/StockRotationItem.pm +++ b/Koha/StockRotationItem.pm @@ -312,7 +312,7 @@ sub toggle_indemand { $item->homebranch($new_stage->branchcode_id)->store; # Revert update homebranch $new_indemand = 0; # Reset indemand $transfer->tobranch($new_stage->branchcode_id); # Reset StockrotationAdvance - $transfer->datearrived(dt_from_string); # Reset StockrotationAdvance + $transfer->datearrived(dt_from_string()); # Reset StockrotationAdvance $transfer->store; } } diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm index afecb2b0524..0509d2a9537 100644 --- a/Koha/Virtualshelf.pm +++ b/Koha/Virtualshelf.pm @@ -64,7 +64,7 @@ sub store { $self->allow_change_from_others( 0 ) unless defined $self->allow_change_from_others; - $self->created_on( dt_from_string ) + $self->created_on( dt_from_string() ) unless defined $self->created_on; return $self->SUPER::store( $self ); @@ -135,7 +135,7 @@ sub share { { shelfnumber => $self->shelfnumber, invitekey => $key, - sharedate => dt_from_string, + sharedate => dt_from_string(), } )->store; } @@ -193,7 +193,7 @@ sub add_biblio { borrowernumber => $borrowernumber, } )->store; - $self->lastmodified(dt_from_string); + $self->lastmodified(dt_from_string()); $self->store; return $content; diff --git a/Koha/Virtualshelfshare.pm b/Koha/Virtualshelfshare.pm index 5f61e27a84a..aca88f3a71b 100644 --- a/Koha/Virtualshelfshare.pm +++ b/Koha/Virtualshelfshare.pm @@ -59,7 +59,7 @@ sub accept { return $search->next; } else { $self->invitekey(undef); - $self->sharedate(dt_from_string); + $self->sharedate(dt_from_string()); $self->borrowernumber($borrowernumber); $self->store; return $self; @@ -69,7 +69,7 @@ sub accept { sub has_expired { my ($self) = @_; my $dt_sharedate = dt_from_string( $self->sharedate, 'sql' ); - my $today = dt_from_string; + my $today = dt_from_string(); my $expiration_delay = DateTime::Duration->new( days => SHARE_INVITATION_EXPIRY_DAYS ); my $has_expired = DateTime->compare( $today, $dt_sharedate->add_duration($expiration_delay) ); # Note: has_expired = 0 if the share expires today diff --git a/Koha/pdfformat/layout2pages.pm b/Koha/pdfformat/layout2pages.pm index b0d4affbdc9..2d8d0530bb1 100644 --- a/Koha/pdfformat/layout2pages.pm +++ b/Koha/pdfformat/layout2pages.pm @@ -164,7 +164,7 @@ sub printhead { $text->text($basketgroup->{'id'}); # print the date - my $today = output_pref({ dt => dt_from_string, dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateonly => 1 }); $text->translate(130/mm, ($height-5-48)/mm); $text->text($today); diff --git a/Koha/pdfformat/layout2pagesde.pm b/Koha/pdfformat/layout2pagesde.pm index 8d519058982..01170f2e308 100644 --- a/Koha/pdfformat/layout2pagesde.pm +++ b/Koha/pdfformat/layout2pagesde.pm @@ -163,7 +163,7 @@ sub printhead { $text->text($basketgroup->{'id'}); # print the date - my $today = output_pref({ dt => dt_from_string, dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateonly => 1 }); $text->translate(130/mm, ($height-5-48)/mm); $text->text($today); diff --git a/Koha/pdfformat/layout3pages.pm b/Koha/pdfformat/layout3pages.pm index fb0d557b185..d3e9ea2dc6b 100644 --- a/Koha/pdfformat/layout3pages.pm +++ b/Koha/pdfformat/layout3pages.pm @@ -331,7 +331,7 @@ sub printhead { $text->text($basketgroup->{'id'}); # print the date - my $today = output_pref({ dt => dt_from_string, dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateonly => 1 }); $text->translate(130/mm, ($height-5-48)/mm); $text->text($today); diff --git a/Koha/pdfformat/layout3pagesfr.pm b/Koha/pdfformat/layout3pagesfr.pm index 1003583b6d9..33d3ccbebdb 100644 --- a/Koha/pdfformat/layout3pagesfr.pm +++ b/Koha/pdfformat/layout3pagesfr.pm @@ -333,7 +333,7 @@ sub printhead { $text->text($basketgroup->{'id'}); # print the date - my $today = output_pref({ dt => dt_from_string, dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateonly => 1 }); $text->translate(130/mm, ($height-5-48)/mm); $text->text($today); diff --git a/acqui/duplicate_orders.pl b/acqui/duplicate_orders.pl index 1964b41418c..70cda8c29cd 100755 --- a/acqui/duplicate_orders.pl +++ b/acqui/duplicate_orders.pl @@ -68,9 +68,9 @@ my $filters = { }; my $from_placed_on = - eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string; + eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string(); my $to_placed_on = - eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string; + eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string(); unless ( $input->param('from') ) { # Fill the form with year-1 diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index cbb371d4df7..7da2e4b8b02 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -89,8 +89,8 @@ my $filters = { managing_library => scalar $input->param('managing_library'), }; -my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string; -my $to_placed_on = eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string; +my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string(); +my $to_placed_on = eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string(); unless ( $input->param('from') ) { # Fill the form with year-1 $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 22c7c3c04f4..5915192e163 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -245,7 +245,7 @@ if ( not $ordernumber ) { # create order if ( $value ) { # get today date & replace <>, <>, <>, <
> if provided in the default value - my $today_dt = dt_from_string; + my $today_dt = dt_from_string(); my $year = $today_dt->strftime('%Y'); my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 588b465d38d..608e1d70cc8 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -119,7 +119,7 @@ my $creator = Koha::Patrons->find( $order->created_by ); my $budget = GetBudget( $order->budget_id ); -my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string; +my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string(); # get option values for TaxRates syspref my @gst_values = map { diff --git a/acqui/parcels.pl b/acqui/parcels.pl index cd6e2562b10..923d440029f 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -75,7 +75,7 @@ use C4::Acquisition qw( GetInvoices GetInvoice AddInvoice ); use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); use Koha::Acquisition::Booksellers; -use Koha::DateUtils qw( output_pref dt_from_string ); +use Koha::DateUtils qw( output_pref dt_from_string() ); my $input = CGI->new; my $booksellerid = $input->param('booksellerid'); @@ -198,7 +198,7 @@ $template->param( dateto => $dateto, resultsperpage => $resultsperpage, name => $bookseller->name, - shipmentdate_today => dt_from_string, + shipmentdate_today => dt_from_string(), booksellerid => $booksellerid, GST => C4::Context->preference('TaxRates'), budgets => $budget_loop, diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index b5932725b51..7fe728e974a 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -167,8 +167,8 @@ elsif ( $op eq 'duplicate_form'){ elsif ( $op eq 'duplicate_budget' ){ die "please specify a budget period id\n" if( !defined $budget_period_id || $budget_period_id eq '' ); - my $budget_period_startdate = dt_from_string scalar $input->param('budget_period_startdate'); - my $budget_period_enddate = dt_from_string scalar $input->param('budget_period_enddate'); + my $budget_period_startdate = dt_from_string() scalar $input->param('budget_period_startdate'); + my $budget_period_enddate = dt_from_string() scalar $input->param('budget_period_enddate'); my $budget_period_description = $input->param('budget_period_description'); my $amount_change_percentage = $input->param('amount_change_percentage'); my $amount_change_round_increment = $input->param('amount_change_round_increment'); diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index 83e99d7d0c6..0c86a31722d 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -99,7 +99,7 @@ elsif ( $op eq 'add_validate' ) { my $contractstart_dt = eval { dt_from_string( scalar $input->param('contractstartdate') ); }; my $contractend_dt = eval { dt_from_string( scalar $input->param('contractenddate') ); }; unless ( $contractstart_dt and $contractend_dt ) { - my $today = dt_from_string; + my $today = dt_from_string(); $contractstart_dt ||= $today; $contractend_dt ||= $today; } diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 138fceab445..bb15a95acda 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -292,7 +292,7 @@ sub create_input { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{}; # get today date & replace <>, <>, <>, <
> if provided in the default value - my $today_dt = dt_from_string; + my $today_dt = dt_from_string(); my $year = $today_dt->strftime('%Y'); my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index e0992152562..49695ff7071 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -132,7 +132,7 @@ sub generate_subfield_form { $value = $subfieldlib->{defaultvalue}; if ( $value ) { # get today date & replace <>, <>, <>, <
> if provided in the default value - my $today_dt = dt_from_string; + my $today_dt = dt_from_string(); my $year = $today_dt->strftime('%Y'); my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl index da1ec86ac98..136ffee4b76 100755 --- a/cataloguing/value_builder/barcode.pl +++ b/cataloguing/value_builder/barcode.pl @@ -35,7 +35,7 @@ my $builder = sub { my %args; # find today's date - ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 })); + ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 })); ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" ); ($args{loctag},$args{locsubfield}) = GetMarcFromKohaField( "items.homebranch" ); diff --git a/cataloguing/value_builder/barcode_manual.pl b/cataloguing/value_builder/barcode_manual.pl index a3840bd436e..92be7e00e95 100755 --- a/cataloguing/value_builder/barcode_manual.pl +++ b/cataloguing/value_builder/barcode_manual.pl @@ -36,7 +36,7 @@ my $builder = sub { $args{dbh} = $dbh; # find today's date - ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 })); + ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 })); ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" ); ($args{loctag},$args{locsubfield}) = GetMarcFromKohaField( "items.homebranch" ); diff --git a/cataloguing/value_builder/dateaccessioned.pl b/cataloguing/value_builder/dateaccessioned.pl index 1ce91e55f6c..c26e7870f0e 100755 --- a/cataloguing/value_builder/dateaccessioned.pl +++ b/cataloguing/value_builder/dateaccessioned.pl @@ -27,7 +27,7 @@ my $builder = sub { my ( $params ) = @_; my $function_name = $params->{id}; - my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + my $date = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); my $res = < diff --git a/circ/circulation.pl b/circ/circulation.pl index 7988782577f..22ade2e39db 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -194,7 +194,7 @@ my ($datedue,$invalidduedate); my $duedatespec_allow = C4::Context->preference('SpecifyDueDate'); if( $onsite_checkout && !$duedatespec_allow ) { - $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); + $datedue = output_pref({ dt => dt_from_string(), dateonly => 1, dateformat => 'iso' }); $datedue .= ' 23:59:00'; } elsif( $duedatespec_allow ) { if ( $duedatespec ) { diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 0b2fea21955..2d98f569d9e 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -130,7 +130,7 @@ if ( $op eq 'cancel_reserve' and $reserve_id ) { } -my $today = dt_from_string; +my $today = dt_from_string(); if ( $startdate ) { $startdate =~ s/^\s+//; diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl index 7311d1e8c94..de68fbb407e 100755 --- a/circ/reserveratios.pl +++ b/circ/reserveratios.pl @@ -65,7 +65,7 @@ if ( $basketno ){ $startdate = eval { dt_from_string( $startdate ) } if $startdate; $enddate = eval { dt_from_string( $enddate ) } if $enddate; -my $todaysdate = dt_from_string; +my $todaysdate = dt_from_string(); # A default of the prior years's holds is a reasonable way to pull holds $enddate = $todaysdate unless $enddate; diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index d0545b20e98..cb257c22071 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -120,7 +120,7 @@ while ( my $library = $libraries->next ) { $template->param( branchesloop => \@branchesloop, - show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), + show_date => output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), latetransfers => $latetransfers ? 1 : 0, ); diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index c9d4e84e822..e8ee69fbe50 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -106,7 +106,7 @@ $template->param( reservecount => scalar @reserve_loop, overloop => \@over_loop, overcount => scalar @over_loop, - show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), + show_date => output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), tab => $tab, ); diff --git a/members/memberentry.pl b/members/memberentry.pl index 5844b9c3f90..97e3d91674b 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -770,10 +770,10 @@ if ($nok) { #Formatting data for display if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){ - $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + $data{'dateenrolled'} = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); } if ( $op eq 'duplicate' ) { - $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + $data{'dateenrolled'} = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); my $patron_category = Koha::Patron::Categories->find( $data{categorycode} ); $data{dateexpiry} = $patron_category->get_expiry_date( $data{dateenrolled} ); } diff --git a/misc/add_date_fields_to_marc_records.pl b/misc/add_date_fields_to_marc_records.pl index f619f521c44..1ac557e1b5c 100755 --- a/misc/add_date_fields_to_marc_records.pl +++ b/misc/add_date_fields_to_marc_records.pl @@ -47,7 +47,7 @@ pod2usage(1) if $help; pod2usage("Parameter field is mandatory") unless @fields; my @fields_to_add; -my $dt = dt_from_string; # Could be an option of the script +my $dt = dt_from_string(); # Could be an option of the script for my $field (@fields) { my ( $f_sf, $value ) = split '=', $field; my ( $tag, $subfield ) = split '\$', $f_sf; diff --git a/misc/cronjobs/archive_purchase_suggestions.pl b/misc/cronjobs/archive_purchase_suggestions.pl index a7c3e8879c3..ddeaeffcb36 100755 --- a/misc/cronjobs/archive_purchase_suggestions.pl +++ b/misc/cronjobs/archive_purchase_suggestions.pl @@ -75,7 +75,7 @@ else { $age_date_field = 'manageddate'; } -my $date = dt_from_string; +my $date = dt_from_string(); if ($age) { if ( $age =~ m|^(\d)$| || $age =~ m|^days:(\d+)$| ) { $date->subtract( days => $1 ); diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl index a777acbbcfd..829eeef5975 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -80,8 +80,8 @@ $delimiter ||= q|,|; cronlogaction(); -my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ; -my $today_syspref = output_pref( { dt => dt_from_string, dateonly => 1 } ); +my $today_iso = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ) ; +my $today_syspref = output_pref( { dt => dt_from_string(), dateonly => 1 } ); my @all_messages = @{ GetPrintMessages() }; diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl index 53d60071b41..1757595030e 100755 --- a/misc/cronjobs/serialsUpdate.pl +++ b/misc/cronjobs/serialsUpdate.pl @@ -121,7 +121,7 @@ while ( my $issue = $sth->fetchrow_hashref ) { if ( $subscription && $publisheddate ) { my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata ); - my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); if ( $nextpublisheddate && $today ) { my ( $year, $month, $day ) = split( /-/, $nextpublisheddate ); diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl index 6d7cf733c48..1d055015126 100755 --- a/misc/cronjobs/staticfines.pl +++ b/misc/cronjobs/staticfines.pl @@ -133,7 +133,7 @@ if (defined $borrowernumberlimit) { } my $overdueItemsCounted = 0; my %calendars = (); -$today = dt_from_string; +$today = dt_from_string(); $today_iso = output_pref( { dt => $today, dateonly => 1, dateformat => 'iso' } ); my ($tyear, $tmonth, $tday) = split( /-/, $today_iso ); $today_days = Date_to_Days( $tyear, $tmonth, $tday ); diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 8945cc339ba..a2c10a71263 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -520,7 +520,7 @@ sub ParseCgiForBorrower { } # Replace checkbox 'agreed' by datetime in gdpr_proc_consent - $borrower{gdpr_proc_consent} = dt_from_string if $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed'; + $borrower{gdpr_proc_consent} = dt_from_string() if $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed'; return %borrower; } diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl index e6aab17d603..ba103499465 100755 --- a/opac/opac-showreviews.pl +++ b/opac/opac-showreviews.pl @@ -59,7 +59,7 @@ my ( $template, $borrowernumber, $cookie ) = &get_template_and_user( ); if($format eq "rss"){ - my $lastbuilddate = dt_from_string; + my $lastbuilddate = dt_from_string(); my $lastbuilddate_output = $lastbuilddate->strftime("%a, %d %b %Y %H:%M:%S %z"); $template->param( rss => 1, @@ -131,7 +131,7 @@ for my $result (@$reviews){ if($format eq "rss"){ my $rsstimestamp = eval { dt_from_string( $result->{datereviewed} ); }; - $rsstimestamp = dt_from_string unless ( $rsstimestamp ); #default to today if something went wrong + $rsstimestamp = dt_from_string() unless ( $rsstimestamp ); #default to today if something went wrong my $rsstimestamp_output = $rsstimestamp->strftime("%a, %d %b %Y %H:%M:%S %z"); $result->{timestamp} = $rsstimestamp_output; } diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 1fb5ffb1369..b1913209cf2 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -175,7 +175,7 @@ if ( $op eq "add_confirm" ) { $suggestion->{$suggest} = Encode::encode( "utf8", $scrubber->scrub( $suggestion->{$suggest} ) ); } - $suggestion->{suggesteddate} = dt_from_string; + $suggestion->{suggesteddate} = dt_from_string(); $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"}; &NewSuggestion($suggestion); diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 40d591519b1..03061aeb9b5 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -242,7 +242,7 @@ elsif ( $patron && ( $op eq 'checkout' ) ) { borrowernumber => $borrower->{borrowernumber}, debit_type_code => 'RESERVE', description => $item->biblio->title, - date => $dtf->format_date(dt_from_string) + date => $dtf->format_date(dt_from_string()) } )->count, ); diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index 0dcc38f08c7..d85a60ed159 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -51,8 +51,8 @@ $template->param( ); #Initialize date pickers to today -my $fromDate = dt_from_string; -my $toDate = dt_from_string; +my $fromDate = dt_from_string(); +my $toDate = dt_from_string(); my @debit_types = Koha::Account::DebitTypes->search()->as_list; @@ -62,9 +62,9 @@ my $registerid; if ($do_it) { - $fromDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("from")) } || dt_from_string, + $fromDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("from")) } || dt_from_string(), dateformat => 'sql', dateonly => 1 }); #for sql query - $toDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("to")) } || dt_from_string, + $toDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("to")) } || dt_from_string(), dateformat => 'sql', dateonly => 1 }); #for sql query my $whereTType = q{}; diff --git a/reserve/request.pl b/reserve/request.pl index 6ab8ba7ac50..90bc9395058 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -84,7 +84,7 @@ my $messages; my $exceeded_maxreserves; my $exceeded_holds_per_record; -my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); +my $date = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); my $action = $input->param('action'); $action ||= q{}; diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index 963eeeb577e..672bb9ae77d 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -66,7 +66,7 @@ if($op eq 'gennext' && @subscriptionid){ $sth->execute($subscriptionid); # modify actual expected issue, to generate the next if ( my $issue = $sth->fetchrow_hashref ) { - my $planneddate = $date_received_today ? dt_from_string : $issue->{planneddate}; + my $planneddate = $date_received_today ? dt_from_string() : $issue->{planneddate}; ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, $planneddate, $issue->{publisheddate}, $issue->{publisheddatetext}, $status, "" ); @@ -83,7 +83,7 @@ if($op eq 'gennext' && @subscriptionid){ ## We generate the next publication date my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1); - my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate; + my $planneddate = $date_received_today ? dt_from_string() : $nextpublisheddate; ## Creating the new issue NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $planneddate, $nextpublisheddate, undef, diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 76a6bf0b250..bb54b268e5d 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -128,7 +128,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my @serialdatalist; my %processedserialid; -my $today = output_pref( { dt => dt_from_string, dateonly => 1 } ); +my $today = output_pref( { dt => dt_from_string(), dateonly => 1 } ); foreach my $serialid (@serialids) { diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl index 6420e50ce1a..efbadd6c906 100755 --- a/serials/showpredictionpattern.pl +++ b/serials/showpredictionpattern.pl @@ -91,7 +91,7 @@ my %pattern = ( ); $firstacquidate = eval { output_pref( { str => $firstacquidate, dateonly => 1, dateformat => 'iso' } ); } - or output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); + or output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); $enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); }; diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index 5da15363c19..ce1ea65079e 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -120,7 +120,7 @@ if ( $op eq "renew" ) { } my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) - or output_pref( { dt => dt_from_string, dateonly => 1 } ); + or output_pref( { dt => dt_from_string(), dateonly => 1 } ); $template->param( startdate => $newstartdate, diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 27a263cd2c0..42049a415e1 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -40,12 +40,12 @@ sub Init{ # "Managed by" is used only when a suggestion is being edited (not when created) if ($suggestion->{'suggesteddate'} eq "") { # new suggestion - $suggestion->{suggesteddate} = dt_from_string; + $suggestion->{suggesteddate} = dt_from_string(); $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'}); } else { # editing of an existing suggestion - $suggestion->{manageddate} = dt_from_string; + $suggestion->{manageddate} = dt_from_string(); $suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'managedby'}); } $suggestion->{'branchcode'}=C4::Context->userenv->{"branch"} unless ($suggestion->{'branchcode'}); @@ -164,10 +164,10 @@ if ( $op =~ /save/i ) { if ( $suggestion_only->{"STATUS"} ) { if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { - $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; + $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string(); $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; } - $suggestion_only->{manageddate} = dt_from_string; + $suggestion_only->{manageddate} = dt_from_string(); $suggestion_only->{"managedby"} ||= C4::Context->userenv->{number}; } @@ -178,7 +178,7 @@ if ( $op =~ /save/i ) { if ( $suggestion_only->{'suggestionid'} > 0 ) { - $suggestion_only->{lastmodificationdate} = dt_from_string; + $suggestion_only->{lastmodificationdate} = dt_from_string(); $suggestion_only->{lastmodificationby} = C4::Context->userenv->{number}; &ModSuggestion($suggestion_only); @@ -263,18 +263,18 @@ elsif ($op eq "update_status" ) { my $accepted_by = $input->param('acceptedby'); if ( $STATUS eq "ACCEPTED" ) { $suggestion = { - accepteddate => dt_from_string, + accepteddate => dt_from_string(), acceptedby => C4::Context->userenv->{number}, }; } elsif ( $STATUS eq "REJECTED" ) { $suggestion = { - rejecteddate => dt_from_string, + rejecteddate => dt_from_string(), rejectedby => C4::Context->userenv->{number}, }; } if ($STATUS) { - $suggestion->{manageddate} = dt_from_string; + $suggestion->{manageddate} = dt_from_string(); $suggestion->{managedby} = C4::Context->userenv->{number}; $suggestion->{STATUS} = $STATUS; } diff --git a/svc/hold/resume b/svc/hold/resume index e14c6b1b39f..bb982e410fd 100755 --- a/svc/hold/resume +++ b/svc/hold/resume @@ -25,7 +25,7 @@ use JSON qw(to_json); use C4::Context; use C4::Output qw(output_with_http_headers); use C4::Auth qw(check_cookie_auth); -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Koha::Holds; my $input = CGI->new; diff --git a/svc/hold/suspend b/svc/hold/suspend index 41b4130a398..19339c3bfdf 100755 --- a/svc/hold/suspend +++ b/svc/hold/suspend @@ -25,7 +25,7 @@ use JSON qw(to_json); use C4::Context; use C4::Output qw(output_with_http_headers); use C4::Auth qw(check_cookie_auth); -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Koha::Holds; my $input = CGI->new; diff --git a/svc/members/search b/svc/members/search index 7cad0e8ab03..0d2bbf4649f 100755 --- a/svc/members/search +++ b/svc/members/search @@ -24,7 +24,7 @@ use C4::Auth qw( get_template_and_user haspermission get_user_subpermissions ); use C4::Output qw( output_with_http_headers ); use C4::Utils::DataTables qw( dt_get_params ); use C4::Utils::DataTables::Members qw( search ); -use Koha::DateUtils qw( output_pref dt_from_string ); +use Koha::DateUtils qw( output_pref dt_from_string() ); use Koha::Patrons; my $input = CGI->new; diff --git a/svc/renew b/svc/renew index a3edd4db435..6d1fa079cc6 100755 --- a/svc/renew +++ b/svc/renew @@ -27,7 +27,7 @@ use C4::Circulation qw( AddRenewal CanBookBeRenewed ); use C4::Context; use C4::Auth qw(check_cookie_auth); -use Koha::DateUtils qw(output_pref dt_from_string); +use Koha::DateUtils qw(output_pref dt_from_string()); my $input = CGI->new; diff --git a/t/DateUtils.t b/t/DateUtils.t index 5b00c771247..1756dee5c3b 100755 --- a/t/DateUtils.t +++ b/t/DateUtils.t @@ -186,7 +186,7 @@ $date_string = output_pref({ dt => $dt, dateformat => 'us', timeformat => '12hr' cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and timeformat 12hr (non-midnight time)'; my $now = DateTime->now; -is( dt_from_string, $now, "Without parameter, dt_from_string should return today" ); +is( dt_from_string(), $now, "Without parameter, dt_from_string should return today" ); my $module_context = Test::MockModule->new('C4::Context'); $module_context->mock( diff --git a/t/db_dependent/Acquisition/NewOrder.t b/t/db_dependent/Acquisition/NewOrder.t index 6c7e6820fe7..c780195745a 100755 --- a/t/db_dependent/Acquisition/NewOrder.t +++ b/t/db_dependent/Acquisition/NewOrder.t @@ -89,7 +89,7 @@ $order = Koha::Acquisition::Order->new( my $ordernumber = $order->ordernumber; $order = Koha::Acquisition::Orders->find( $ordernumber ); is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' ); -is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' ); +is( $order->entrydate, output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' ); is( $order->created_by, $logged_in_user->borrowernumber, 'Koha::Acquisition::Order->store set created_by to logged in user if not given' ); $schema->storage->txn_rollback(); diff --git a/t/db_dependent/Authority/MergeRequests.t b/t/db_dependent/Authority/MergeRequests.t index bba791992a0..a78b0d6a7b4 100755 --- a/t/db_dependent/Authority/MergeRequests.t +++ b/t/db_dependent/Authority/MergeRequests.t @@ -14,7 +14,7 @@ $schema->storage->txn_begin; subtest "Tests for cron_cleanup" => sub { plan tests => 3; - my $dt = dt_from_string; + my $dt = dt_from_string(); $dt->subtract( hours => 2 ); my $req1 = Koha::Authority::MergeRequest->new({ authid => 1, diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index e054c74ab56..7622ec08a36 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -71,8 +71,8 @@ sub test_debarment_on_checkout { my $item = $params->{item}; my $library = $params->{library}; my $patron = $params->{patron}; - my $due_date = $params->{due_date} || dt_from_string; - my $return_date = $params->{return_date} || dt_from_string; + my $due_date = $params->{due_date} || dt_from_string(); + my $return_date = $params->{return_date} || dt_from_string(); my $expected_expiration_date = $params->{expiration_date}; $expected_expiration_date = output_pref( @@ -105,7 +105,7 @@ my $builder = t::lib::TestBuilder->new; my $dbh = C4::Context->dbh; # Prevent random failures by mocking ->now -my $now_value = dt_from_string; +my $now_value = dt_from_string(); my $mocked_datetime = Test::MockModule->new('DateTime'); $mocked_datetime->mock( 'now', sub { return $now_value->clone; } ); @@ -2218,7 +2218,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { ); # Patron cannot issue item_1, they have overdues - my $now = dt_from_string; + my $now = dt_from_string(); my $five_days_ago = $now->clone->subtract( days => 5 ); my $ten_days_ago = $now->clone->subtract( days => 10 ); AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue @@ -2324,7 +2324,7 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); my $five_days_ago = $now->clone->subtract( days => 5 ); # We want to charge 2 days every day, without grace # With 5 days of overdue: 5 * Z @@ -2356,7 +2356,7 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { } ); { - my $now = dt_from_string; + my $now = dt_from_string(); my $five_days_ago = $now->clone->subtract( days => 5 ); # We want to charge 2 days every day, without grace # With 5 days of overdue: 5 * Z @@ -2603,7 +2603,7 @@ subtest 'AddReturn | is_overdue' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); my $one_day_ago = $now->clone->subtract( days => 1 ); my $two_days_ago = $now->clone->subtract( days => 2 ); my $five_days_ago = $now->clone->subtract( days => 5 ); @@ -2799,7 +2799,7 @@ subtest 'AddReturn | is_overdue' => sub { t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); - my $due_date = dt_from_string; + my $due_date = dt_from_string(); my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); # Add fine @@ -3569,7 +3569,7 @@ subtest 'CanBookBeIssued | is_overdue' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1}); my $ten_days_go = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 }); my $library = $builder->build( { source => 'Branch' } ); @@ -3946,7 +3946,7 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub { $context = Test::MockModule->new('C4::Context'); $context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew) - my $now = dt_from_string; + my $now = dt_from_string(); $date = output_pref( { dt => $now, dateonly => 1, dateformat => 'iso' } ); $old_log_size = Koha::ActionLogs->count( \%params_renewal ); my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); @@ -4036,7 +4036,7 @@ subtest 'Incremented fee tests' => sub { is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item" ); - my $now = dt_from_string; + my $now = dt_from_string(); my $dt_from = $now->clone; my $dt_to = $now->clone->add( days => 7 ); my $dt_to_renew = $now->clone->add( days => 13 ); @@ -4412,7 +4412,7 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { )->next; ok( $a, "Found accountline for lost fee" ); is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); - my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); + my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); $a = $a->get_from_storage; is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); $a->delete; @@ -4447,7 +4447,7 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { )->next; ok( $a, "Found accountline for lost fee" ); is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); - my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); + my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); $a = $a->get_from_storage; is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); $a->delete; @@ -4482,7 +4482,7 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { )->next; ok( $a, "Found accountline for lost fee" ); is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); - my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); + my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); $a = $a->get_from_storage; is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); $a->delete; @@ -4518,7 +4518,7 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { $a = $a->next; ok( $a, "Found accountline for lost fee" ); is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); - my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); + my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); $a = $a->get_from_storage; is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); $a->delete; @@ -4897,8 +4897,8 @@ subtest "updateWrongTransfer tests" => sub { itemnumber => $item->itemnumber, frombranch => $library2->branchcode, tobranch => $library1->branchcode, - daterequested => dt_from_string, - datesent => dt_from_string, + daterequested => dt_from_string(), + datesent => dt_from_string(), datecancelled => undef, datearrived => undef, reason => 'Manual' diff --git a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t index bdb9d5aee61..1c98035f685 100755 --- a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t +++ b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t @@ -126,7 +126,7 @@ subtest "suspension_chargeperiod" => sub { my $item = $builder->build_sample_item; my $last_year = dt_from_string->clone->subtract( years => 1 ); - my $today = dt_from_string; + my $today = dt_from_string(); my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today ); is( $new_debar_dt->truncate( to => 'day' ), $today->clone->add( days => 365 / 15 * 7 )->truncate( to => 'day' ) ); @@ -152,7 +152,7 @@ subtest "maxsuspensiondays" => sub { my $item = $builder->build_sample_item; my $last_year = dt_from_string->clone->subtract( years => 1 ); - my $today = dt_from_string; + my $today = dt_from_string(); my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today ); is( $new_debar_dt->truncate( to => 'day' ), $today->clone->add( days => 333 )->truncate( to => 'day' ) ); diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t index e7b1d44421c..4bbe175e7ad 100755 --- a/t/db_dependent/Circulation/MarkIssueReturned.t +++ b/t/db_dependent/Circulation/MarkIssueReturned.t @@ -27,7 +27,7 @@ use C4::Circulation qw( MarkIssueReturned AddIssue ); use C4::Context; use Koha::Checkouts; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Koha::Old::Checkouts; use Koha::Patrons; use Koha::Patron::Debarments; diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t index c361d3c1651..adbb19f7cf0 100755 --- a/t/db_dependent/Circulation/Returns.t +++ b/t/db_dependent/Circulation/Returns.t @@ -268,7 +268,7 @@ subtest 'Handle ids duplication' => sub { my ($doreturn, $messages, $new_checkout, $borrower); warning_like { ( $doreturn, $messages, $new_checkout, $borrower ) = - AddReturn( $item->barcode, undef, undef, undef, dt_from_string ); + AddReturn( $item->barcode, undef, undef, undef, dt_from_string() ); } [ qr{.*DBD::mysql::st execute failed: Duplicate entry.*}, diff --git a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t index 1c8ea0f7d0c..3c702a170a4 100755 --- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t +++ b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t @@ -85,7 +85,7 @@ t::lib::Mocks::mock_userenv({ patron => $patron }); t::lib::Mocks::mock_preference('AllowTooManyOverride', 0); # Add onsite checkout -C4::Circulation::AddIssue( $patron_unblessed, $item->barcode, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); +C4::Circulation::AddIssue( $patron_unblessed, $item->barcode, dt_from_string(), undef, dt_from_string, undef, { onsite_checkout => 1 } ); my ( $impossible, $messages ); t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0); @@ -111,7 +111,7 @@ my $another_item = $builder->build_sample_item( } ); -C4::Circulation::AddIssue( $patron_unblessed, $another_item->barcode, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); +C4::Circulation::AddIssue( $patron_unblessed, $another_item->barcode, dt_from_string(), undef, dt_from_string, undef, { onsite_checkout => 1 } ); ( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->barcode ); is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 1 - Switch is allowed' ); is( exists $impossible->{TOO_MANY}, '', 'Specific case 1 - Switch is allowed' ); diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index d4fb82b55b7..0f921617ff9 100755 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -102,7 +102,7 @@ Koha::CirculationRules->set_rules( ); # Add Dates -my $dt_today = dt_from_string; +my $dt_today = dt_from_string(); my $today = output_pref( { dt => $dt_today, dateformat => 'iso', @@ -111,7 +111,7 @@ my $today = output_pref( } ); -my $dt_today2 = dt_from_string; +my $dt_today2 = dt_from_string(); my $dur10 = DateTime::Duration->new( days => -10 ); $dt_today2->add_duration($dur10); my $daysago10 = output_pref( @@ -482,7 +482,7 @@ my $reserve_id = AddReserve( } ); ok( $reserve_id, 'The reserve should have been inserted' ); -AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' ); +AddIssue( $borrower_2, $barcode_1, dt_from_string(), 'cancel' ); my $hold = Koha::Holds->find( $reserve_id ); is( $hold, undef, 'The reserve should have been correctly cancelled' ); diff --git a/t/db_dependent/Circulation/transfers.t b/t/db_dependent/Circulation/transfers.t index 99767c8798e..0dda2ae1583 100755 --- a/t/db_dependent/Circulation/transfers.t +++ b/t/db_dependent/Circulation/transfers.t @@ -21,7 +21,7 @@ use C4::Circulation qw( CreateBranchTransferLimit DeleteBranchTransferLimits Get use C4::Biblio qw( AddBiblio ); use C4::Items qw( ModItemTransfer ); use Koha::Database; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use DateTime::Duration; use Koha::Item::Transfers; @@ -136,7 +136,7 @@ ModItemTransfer( $trigger ); my $transfer_requested = Koha::Item::Transfers->search( { itemnumber => $item_id3 }, { rows => 1 })->single; -$transfer_requested->set({ daterequested => dt_from_string, datesent => undef })->store; +$transfer_requested->set({ daterequested => dt_from_string(), datesent => undef })->store; # Add a "cancelled" transfer for tests ModItemTransfer( @@ -146,7 +146,7 @@ ModItemTransfer( $trigger ); my $transfer_cancelled = Koha::Item::Transfers->search( { itemnumber => $item_id4 }, { rows => 1 })->single; -$transfer_cancelled->set( { daterequested => dt_from_string, datesent => undef, datecancelled => dt_from_string } )->store; +$transfer_cancelled->set( { daterequested => dt_from_string(), datesent => undef, datecancelled => dt_from_string() } )->store; #Begin Tests #Test CreateBranchTransferLimit diff --git a/t/db_dependent/Contract.t b/t/db_dependent/Contract.t index 7ce9d34ac7d..b86fdfa97ce 100755 --- a/t/db_dependent/Contract.t +++ b/t/db_dependent/Contract.t @@ -77,7 +77,7 @@ is( $contract->{contractname}, $my_contract1->{contractname}, 'AddContract store is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'AddContract stores the contract description correctly.' ); is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'AddContract stores the bookseller id correctly.' ); -my $now = dt_from_string; +my $now = dt_from_string(); my $three_more_days = $now + DateTime::Duration->new( days => 3 ); $my_contract1 = { diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index fb983caca5c..cd9de06b819 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -79,7 +79,7 @@ $hold->store(); my $b1_cal = C4::Calendar->new( branchcode => $branches[1]->{branchcode} ); $b1_cal->insert_single_holiday( day => 2, month => 1, year => 2017, title => "Morty Day", description => "Rick" ); #Add a holiday -my $today = dt_from_string; +my $today = dt_from_string(); is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days') , "Age of hold is days from reservedate to now if calendar ignored"); is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used"); diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index b62bc123bd1..ee8f9a5b2b1 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -102,7 +102,7 @@ my $reservedate = $first_hold->reservedate; my $borrowernumber = $first_hold->borrowernumber; my $branch_1code = $first_hold->branchcode; my $reserve_id = $first_hold->reserve_id; -is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date"); +is( $reservedate, output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date"); is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); ok($reserve_id, "Test holds_placed_today()"); @@ -358,7 +358,7 @@ $hold = Koha::Hold->new( biblionumber => $biblio->biblionumber, found => undef, priority => 1, - reservedate => dt_from_string, + reservedate => dt_from_string(), branchcode => $branch_1, } )->store(); diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 30f4ec3eae2..3c9861d0ac9 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -1690,7 +1690,7 @@ subtest 'Remove holds on check-in match' => sub { t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } ); - AddIssue( $patron1->unblessed, $item->barcode, dt_from_string ); + AddIssue( $patron1->unblessed, $item->barcode, dt_from_string() ); my $hold_id = AddReserve( { @@ -1724,7 +1724,7 @@ subtest 'Remove holds on check-in match' => sub { is( $count_1, 1, "Holds queue has one element" ); - AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string ); + AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string() ); ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0, $hold->reserve_id ); diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index 72681afd699..3c814e11e09 100755 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -88,7 +88,7 @@ subtest 'AuthenticatePatron test' => sub { t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); $query->param( 'username', uc( $borrower->{userid} )); $reply = C4::ILSDI::Services::AuthenticatePatron( $query ); - my $now = dt_from_string; + my $now = dt_from_string(); is( $reply->{id}, $borrower->{borrowernumber}, "userid is not case sensitive - Patron authenticated" ); is( $reply->{code}, undef, "Error code undef"); $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} }); diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 120d9b9307d..a2c4be749d4 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -374,7 +374,7 @@ subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { my $biblio = $schema->resultset('Biblio')->create({ title => "Test title", - datecreated => dt_from_string, + datecreated => dt_from_string(), biblioitems => [ { itemtype => 'BIB_LEVEL' } ], }); my $biblioitem = $biblio->biblioitems->first; diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t index 0c1b044b384..03090542fbe 100755 --- a/t/db_dependent/Items/AutomaticItemModificationByAge.t +++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t @@ -121,7 +121,7 @@ $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new_status value is not updated| ); # Play with age -my $dt_today = dt_from_string; +my $dt_today = dt_from_string(); my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) ); $modified_item->dateaccessioned($days5ago)->store; diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index fa36c4b8356..0262b6f6310 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -1125,7 +1125,7 @@ subtest 'Koha::Account::pay() generates credit number (Koha::Account::Line->stor my $context = Test::MockModule->new('C4::Context'); $context->mock( 'userenv', { branch => $library->id } ); - my $now = dt_from_string; + my $now = dt_from_string(); my $year = $now->year; my $month = $now->month; my ($accountlines_id, $accountline); diff --git a/t/db_dependent/Koha/Acquisition/Basket.t b/t/db_dependent/Koha/Acquisition/Basket.t index 0a237f84436..4d8fd3ddcd3 100755 --- a/t/db_dependent/Koha/Acquisition/Basket.t +++ b/t/db_dependent/Koha/Acquisition/Basket.t @@ -27,7 +27,7 @@ use t::lib::Mocks; use C4::Acquisition qw( NewBasket ModBasket ModBasketHeader ); use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use_ok('Koha::Acquisition::Basket'); use_ok('Koha::Acquisition::Baskets'); @@ -161,7 +161,7 @@ subtest 'to_api() tests' => sub { ok( defined $closed, 'closed is defined' ); ok( !$closed, 'closedate is undef, closed evaluates to false' ); - $basket->closedate( dt_from_string )->store->discard_changes; + $basket->closedate( dt_from_string() )->store->discard_changes; $closed = $basket->to_api->{closed}; ok( defined $closed, 'closed is defined' ); ok( $closed, 'closedate is defined, closed evaluates to true' ); @@ -197,7 +197,7 @@ subtest 'estimated_delivery_date' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); is( $basket->estimated_delivery_date, undef, 'return undef if closedate and deliverytime are not defined' ); @@ -232,7 +232,7 @@ subtest 'late_since_days' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); $basket->closedate(undef)->store; # Basket is open is( $basket->late_since_days, undef, 'return undef if basket is still open'); diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t index 9025f1cc81d..8aa802025b8 100755 --- a/t/db_dependent/Koha/Acquisition/Booksellers.t +++ b/t/db_dependent/Koha/Acquisition/Booksellers.t @@ -65,11 +65,11 @@ subtest '->subscriptions() tests' => sub { my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); is( $vendor->subscriptions->count, 0, 'Vendor has no subscriptions' ); - my $dt_today = dt_from_string; + my $dt_today = dt_from_string(); my $today = output_pref( { dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 } ); - my $dt_today1 = dt_from_string; + my $dt_today1 = dt_from_string(); my $dur5 = DateTime::Duration->new( days => -5 ); $dt_today1->add_duration($dur5); my $daysago5 = output_pref( diff --git a/t/db_dependent/Koha/Acquisition/Budgets.t b/t/db_dependent/Koha/Acquisition/Budgets.t index e5aedefdada..c228e03f3f9 100755 --- a/t/db_dependent/Koha/Acquisition/Budgets.t +++ b/t/db_dependent/Koha/Acquisition/Budgets.t @@ -32,7 +32,7 @@ $schema->storage->txn_begin; my $builder = t::lib::TestBuilder->new; my $nb_of_budgets= Koha::Acquisition::Budgets->search->count; -my $now = dt_from_string; +my $now = dt_from_string(); my $new_budget = Koha::Acquisition::Budget->new({ budget_period_startdate => $now, budget_period_enddate => $now, diff --git a/t/db_dependent/Koha/Acquisition/Invoice.t b/t/db_dependent/Koha/Acquisition/Invoice.t index e99f01f1c3b..6c81fc17466 100755 --- a/t/db_dependent/Koha/Acquisition/Invoice.t +++ b/t/db_dependent/Koha/Acquisition/Invoice.t @@ -25,7 +25,7 @@ use Test::MockModule; use t::lib::TestBuilder; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use_ok('Koha::Acquisition::Invoice'); @@ -57,7 +57,7 @@ subtest 'to_api() tests' => sub { ok( defined $closed, 'closed is defined' ); ok( !$closed, 'closedate is undef, closed evaluates to false' ); - $invoice->closedate( dt_from_string )->store->discard_changes; + $invoice->closedate( dt_from_string() )->store->discard_changes; $closed = $invoice->to_api->{closed}; ok( defined $closed, 'closed is defined' ); ok( $closed, 'closedate is defined, closed evaluates to true' ); diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t index dd2138405f0..801f7ee81d4 100755 --- a/t/db_dependent/Koha/Acquisition/Order.t +++ b/t/db_dependent/Koha/Acquisition/Order.t @@ -29,7 +29,7 @@ use C4::Circulation qw( AddIssue AddReturn ); use Koha::Biblios; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Koha::Items; my $schema = Koha::Database->schema; @@ -370,7 +370,7 @@ subtest 'claim*' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); is( $order->claims->count, 0, 'No claim yet, ->claims should return an empty set'); is( $order->claims_count, 0, 'No claim yet, ->claims_count should return 0'); is( $order->claimed_date, undef, 'No claim yet, ->claimed_date should return undef'); @@ -392,7 +392,7 @@ subtest 'filter_by_late' => sub { plan tests => 16; $schema->storage->txn_begin; - my $now = dt_from_string; + my $now = dt_from_string(); my $bookseller = $builder->build_object( { class => 'Koha::Acquisition::Booksellers', @@ -546,7 +546,7 @@ subtest 'filter_by_current & filter_by_cancelled' => sub { plan tests => 2; $schema->storage->txn_begin; - my $now = dt_from_string; + my $now = dt_from_string(); my $order_1 = $builder->build_object( { class => 'Koha::Acquisition::Orders', @@ -567,7 +567,7 @@ subtest 'filter_by_current & filter_by_cancelled' => sub { { class => 'Koha::Acquisition::Orders', value => { - datecancellationprinted => dt_from_string, + datecancellationprinted => dt_from_string(), } } ); diff --git a/t/db_dependent/Koha/AdditionalContents.t b/t/db_dependent/Koha/AdditionalContents.t index 80fb4c60cf1..ceb63c0b499 100755 --- a/t/db_dependent/Koha/AdditionalContents.t +++ b/t/db_dependent/Koha/AdditionalContents.t @@ -79,7 +79,7 @@ subtest '->is_expired' => sub { $schema->storage->txn_begin; - my $today = dt_from_string; + my $today = dt_from_string(); my $yesterday = dt_from_string->add( days => -1 ); my $tomorrow = dt_from_string->add( days => 1 ); my $new_today = $builder->build_object({ @@ -163,7 +163,7 @@ subtest '->search_for_display' => sub { Koha::AdditionalContents->search->delete; - my $today = dt_from_string; + my $today = dt_from_string(); my $yesterday = dt_from_string->add( days => -1 ); my $tomorrow = dt_from_string->add( days => 1 ); my $library1 = $builder->build_object({ class => 'Koha::Libraries' }); diff --git a/t/db_dependent/Koha/BackgroundJobs.t b/t/db_dependent/Koha/BackgroundJobs.t index f678e206357..6f12bbf579d 100755 --- a/t/db_dependent/Koha/BackgroundJobs.t +++ b/t/db_dependent/Koha/BackgroundJobs.t @@ -54,7 +54,7 @@ my $new_job = Koha::BackgroundJobs->find($job_id); ok( $new_job, 'New job correctly enqueued' ); is_deeply( decode_json( $new_job->data ), $data, 'data retrieved and json encoded correctly' ); -is( t::lib::Dates::compare( $new_job->enqueued_on, dt_from_string ), +is( t::lib::Dates::compare( $new_job->enqueued_on, dt_from_string() ), 0, 'enqueued_on correctly filled with now()' ); is( $new_job->size, $job_size, 'job size retrieved correctly' ); is( $new_job->status, "new", 'job has not started yet, status is new' ); diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t index d19e8f3c0d4..959af767833 100755 --- a/t/db_dependent/Koha/Biblios.t +++ b/t/db_dependent/Koha/Biblios.t @@ -59,7 +59,7 @@ subtest 'store' => sub { is( Koha::Biblios->find( $biblio->biblionumber )->datecreated, output_pref( - { dt => dt_from_string, dateformat => 'iso', dateonly => 1 } + { dt => dt_from_string(), dateformat => 'iso', dateonly => 1 } ), "datecreated must be set to today if not passed to the constructor" ); diff --git a/t/db_dependent/Koha/Charges/Fees.t b/t/db_dependent/Koha/Charges/Fees.t index 2f2af9d8769..56ac44ce491 100755 --- a/t/db_dependent/Koha/Charges/Fees.t +++ b/t/db_dependent/Koha/Charges/Fees.t @@ -29,7 +29,7 @@ use t::lib::Dates; use Time::Fake; use C4::Calendar qw( new insert_week_day_holiday delete_holiday ); -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); BEGIN { use_ok('Koha::Charges::Fees'); diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t index 9c4b0dbfeae..2b2d2954ece 100755 --- a/t/db_dependent/Koha/Checkouts.t +++ b/t/db_dependent/Koha/Checkouts.t @@ -239,7 +239,7 @@ subtest 'Koha::Old::Checkouts->filter_by_todays_checkins' => sub { ); } # Checkin 4 today - my $today = dt_from_string; + my $today = dt_from_string(); for my $i ( 3 .. 6 ) { my $checkout = $checkouts[$i]; C4::Circulation::AddReturn( @@ -287,7 +287,7 @@ subtest 'automatic_checkin' => sub { $ac_item->itemtype->automatic_checkin(1)->store; $normal_item->itemtype->automatic_checkin(0)->store; - my $today = dt_from_string; + my $today = dt_from_string(); my $tomorrow = dt_from_string->add( days => 1 ); my $yesterday = dt_from_string->subtract( days => 1 ); diff --git a/t/db_dependent/Koha/Checkouts/ReturnClaim.t b/t/db_dependent/Koha/Checkouts/ReturnClaim.t index f614895f891..27cadc40999 100755 --- a/t/db_dependent/Koha/Checkouts/ReturnClaim.t +++ b/t/db_dependent/Koha/Checkouts/ReturnClaim.t @@ -208,7 +208,7 @@ subtest "resolve() tests" => sub { close STDERR; } - my $today = dt_from_string; + my $today = dt_from_string(); my $tomorrow = dt_from_string->add( days => 1 ); $claim->resolve( diff --git a/t/db_dependent/Koha/Club/Enrollment.t b/t/db_dependent/Koha/Club/Enrollment.t index 528be791515..f3ba315c2a1 100755 --- a/t/db_dependent/Koha/Club/Enrollment.t +++ b/t/db_dependent/Koha/Club/Enrollment.t @@ -24,7 +24,7 @@ use Test::Exception; use Koha::Patron; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use t::lib::TestBuilder; diff --git a/t/db_dependent/Koha/Club/Hold.t b/t/db_dependent/Koha/Club/Hold.t index 9c88f1049ed..dcd914cd0e9 100755 --- a/t/db_dependent/Koha/Club/Hold.t +++ b/t/db_dependent/Koha/Club/Hold.t @@ -27,7 +27,7 @@ use Koha::Club::Hold; use Koha::Club::Hold::PatronHolds; use Koha::Holds; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Scalar::Util qw(blessed); use t::lib::TestBuilder; @@ -109,7 +109,7 @@ subtest 'add' => sub { is(blessed($club_hold), 'Koha::Club::Hold', 'add returns a Koha::Club::Hold'); - $e->date_canceled(dt_from_string)->store; + $e->date_canceled(dt_from_string())->store; throws_ok { Koha::Club::Hold::add( diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index e9cc993cd75..21676782fdc 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -522,7 +522,7 @@ subtest 'request_transfer' => sub { is($transfers->count, 2, "There are now 2 live transfers in the queue"); $transfer = $transfer->get_from_storage; is_deeply($transfer->unblessed, $original_transfer->unblessed, "Original transfer unchanged"); - $queued_transfer->datearrived(dt_from_string)->store(); + $queued_transfer->datearrived(dt_from_string())->store(); # Replace transfer my $replaced_transfer = $item->request_transfer( @@ -533,7 +533,7 @@ subtest 'request_transfer' => sub { ok($original_transfer->datecancelled, "Original transfer cancelled"); $transfers = $item->get_transfers; is($transfers->count, 1, "There is only 1 live transfer in the queue"); - $replaced_transfer->datearrived(dt_from_string)->store(); + $replaced_transfer->datearrived(dt_from_string())->store(); # BranchTransferLimits t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); diff --git a/t/db_dependent/Koha/Item/Transfer.t b/t/db_dependent/Koha/Item/Transfer.t index 54b82084194..4e564b0b3b9 100755 --- a/t/db_dependent/Koha/Item/Transfer.t +++ b/t/db_dependent/Koha/Item/Transfer.t @@ -20,7 +20,7 @@ use Modern::Perl; use Koha::Database; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use t::lib::TestBuilder; @@ -235,19 +235,19 @@ subtest 'in_transit tests' => sub { itemnumber => $item->itemnumber, frombranch => $library_from->branchcode, tobranch => $library_to->branchcode, - daterequested => dt_from_string, + daterequested => dt_from_string(), } )->store; ok( !$transfer->in_transit, 'in_transit returns false when only daterequested is defined' ); - $transfer->datesent(dt_from_string)->store; + $transfer->datesent(dt_from_string())->store; ok( $transfer->in_transit, 'in_transit returns true when datesent is defined'); - $transfer->datearrived(dt_from_string)->store; + $transfer->datearrived(dt_from_string())->store; ok( !$transfer->in_transit, 'in_transit returns false when datearrived is defined'); - $transfer->set( { datearrived => undef, datecancelled => dt_from_string } )->store; + $transfer->set( { datearrived => undef, datecancelled => dt_from_string() } )->store; ok( !$transfer->in_transit, 'in_transit returns false when datecancelled is defined'); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/Item/Transfers.t b/t/db_dependent/Koha/Item/Transfers.t index 03ed3cf3aa2..9aeb7e85808 100755 --- a/t/db_dependent/Koha/Item/Transfers.t +++ b/t/db_dependent/Koha/Item/Transfers.t @@ -47,8 +47,8 @@ my $new_transfer_1 = Koha::Item::Transfer->new( { itemnumber => $item->itemnumber, frombranch => $library_from->{branchcode}, tobranch => $library_to->{branchcode}, - datearrived => dt_from_string, - datesent => dt_from_string, + datearrived => dt_from_string(), + datesent => dt_from_string(), } )->store; my $new_transfer_2 = Koha::Item::Transfer->new( @@ -56,7 +56,7 @@ my $new_transfer_2 = Koha::Item::Transfer->new( frombranch => $library_from->{branchcode}, tobranch => $library_to->{branchcode}, datearrived => undef, - datesent => dt_from_string, + datesent => dt_from_string(), } )->store; @@ -86,7 +86,7 @@ subtest 'daterequested tests' => sub { } ); - my $now = dt_from_string; + my $now = dt_from_string(); my $transfer = Koha::Item::Transfer->new( { itemnumber => $item->itemnumber, diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t index aecd8d971b5..9c1aef0b5e0 100755 --- a/t/db_dependent/Koha/ItemTypes.t +++ b/t/db_dependent/Koha/ItemTypes.t @@ -29,7 +29,7 @@ use C4::Calendar qw( new ); use Koha::Biblioitems; use Koha::Libraries; use Koha::Database; -use Koha::DateUtils qw(dt_from_string);; +use Koha::DateUtils qw(dt_from_string());; use Koha::Items; BEGIN { diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index a1e10e846a3..6b366cc38f5 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -154,7 +154,7 @@ subtest 'discard_changes' => sub { my $patron = $builder->build( { source => 'Borrower' } ); $patron = Koha::Patrons->find( $patron->{borrowernumber} ); - $patron->dateexpiry(dt_from_string); + $patron->dateexpiry(dt_from_string()); $patron->discard_changes; is( dt_from_string( $patron->dateexpiry ), diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index 554b631741b..e0bd139433e 100755 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -1070,7 +1070,7 @@ subtest "filter_by_last_update" => sub { $schema->storage->txn_begin; - my $now = dt_from_string->truncate( to => 'day' ); + my $now = dt_from_string()->truncate( to => 'day' ); my @borrowernumbers; # Building 6 patrons that have been created today, yesterday, ... 1 per day for my $i ( 0 .. 5 ) { diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index f5a329960dc..5dd5392eb8c 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -24,7 +24,7 @@ use Test::Exception; use Test::Warn; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Koha::Patrons; use Koha::Patron::Relationships; diff --git a/t/db_dependent/Koha/Patron/Consents.t b/t/db_dependent/Koha/Patron/Consents.t index ab9ed669d46..07dcbba2fd7 100755 --- a/t/db_dependent/Koha/Patron/Consents.t +++ b/t/db_dependent/Koha/Patron/Consents.t @@ -38,7 +38,7 @@ subtest 'Basic tests for Koha::Patron::Consent' => sub { my $consent1 = Koha::Patron::Consent->new({ borrowernumber => $patron1->borrowernumber, type => 'GDPR_PROCESSING', - given_on => dt_from_string, + given_on => dt_from_string(), })->store; is( Koha::Patron::Consents->search({ borrowernumber => $patron1->borrowernumber })->count, 1, 'One consent for new borrower' ); $consent1->delete; diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 152b80c35b9..db4ddeda4f6 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -42,7 +42,7 @@ use Koha::Patron::Attribute::Types; use Koha::Patron::Categories; use Koha::Patron::Relationship; use Koha::Database; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use Koha::Virtualshelves; use Koha::Notice::Messages; @@ -293,7 +293,7 @@ subtest 'is_expired' => sub { $patron = Koha::Patrons->find( $patron->{borrowernumber} ); $patron->dateexpiry( undef )->store->discard_changes; is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set'); - $patron->dateexpiry( dt_from_string )->store->discard_changes; + $patron->dateexpiry( dt_from_string() )->store->discard_changes; is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today'); $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes; is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow'); @@ -1935,7 +1935,7 @@ subtest 'search_unsubscribed' => sub { t::lib::Mocks::mock_preference( 'UnsubscribeReflectionDelay', 0 ); Koha::Patron::Consents->delete; # for correct counts - Koha::Patron::Consent->new({ borrowernumber => $patron1->borrowernumber, type => 'GDPR_PROCESSING', refused_on => dt_from_string })->store; + Koha::Patron::Consent->new({ borrowernumber => $patron1->borrowernumber, type => 'GDPR_PROCESSING', refused_on => dt_from_string() })->store; is( Koha::Patrons->search_unsubscribed->count, 1, 'Find patron1' ); # Add another refusal but shift the period @@ -2012,7 +2012,7 @@ subtest 'search_anonymized' => sub { is( Koha::Patrons->search_anonymized->count, 0, 'Empty set' ); t::lib::Mocks::mock_preference( 'PatronRemovalDelay', 1 ); - $patron1->dateexpiry( dt_from_string ); + $patron1->dateexpiry( dt_from_string() ); $patron1->anonymized(0)->store; my $cnt = Koha::Patrons->search_anonymized->count; $patron1->anonymized(1)->store; diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t index 674ad36bf1a..f1d47cc7d44 100755 --- a/t/db_dependent/Koha/Pseudonymization.t +++ b/t/db_dependent/Koha/Pseudonymization.t @@ -84,8 +84,8 @@ subtest 'Koha::Anonymized::Transactions tests' => sub { t::lib::Mocks::mock_preference( 'Pseudonymization', 0 ); my $item = $builder->build_sample_item; t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch }); - AddIssue( $patron->unblessed, $item->barcode, dt_from_string ); - AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string ); + AddIssue( $patron->unblessed, $item->barcode, dt_from_string() ); + AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string() ); my $pseudonymized= Koha::PseudonymizedTransactions->search( { itemnumber => $item->itemnumber } )->next; is( $pseudonymized, undef, @@ -96,8 +96,8 @@ subtest 'Koha::Anonymized::Transactions tests' => sub { ); $item = $builder->build_sample_item; t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch }); - AddIssue( $patron->unblessed, $item->barcode, dt_from_string ); - AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string ); + AddIssue( $patron->unblessed, $item->barcode, dt_from_string() ); + AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string() ); my $statistic = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next; $pseudonymized = Koha::PseudonymizedTransactions->search( { itemnumber => $item->itemnumber } )->next; like( $pseudonymized->hashed_borrowernumber, diff --git a/t/db_dependent/Koha/Quotes.t b/t/db_dependent/Koha/Quotes.t index 0ecd7d85f7d..96109758a00 100755 --- a/t/db_dependent/Koha/Quotes.t +++ b/t/db_dependent/Koha/Quotes.t @@ -19,7 +19,7 @@ use Modern::Perl; use Test::More tests => 14; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); use Koha::Quote; use Koha::Quotes; @@ -66,7 +66,7 @@ t::lib::Mocks::mock_preference('QuoteOfTheDay', 'opac,intranet'); $quote = Koha::Quotes->get_daily_quote('id'=>$quote_3->id); is($quote->id, $quote_3->id, "Correctly got quote by ID"); is($quote->text, $quote_3->text, "Quote is correct"); -is(t::lib::Dates::compare($quote->timestamp, dt_from_string), 0, "get_daily_quote updated the timestamp/last seen"); +is(t::lib::Dates::compare($quote->timestamp, dt_from_string()), 0, "get_daily_quote updated the timestamp/last seen"); $quote = Koha::Quotes->get_daily_quote('random'=>1); ok($quote, "Got a random quote."); @@ -77,7 +77,7 @@ subtest 'timestamp column is updated' => sub { Koha::Quotes->search->update( { timestamp => $yesterday } ); - my $now = dt_from_string; + my $now = dt_from_string(); my $expected_quote = { id => $quote_3->id, diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 4ba21055607..9233e137356 100755 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -77,7 +77,7 @@ my $library = $builder->build({ } }); my $patron_category = $builder->build({ source => 'Category' })->{categorycode}; -my $date = dt_from_string; +my $date = dt_from_string(); my $borrowernumber = Koha::Patron->new({ firstname => 'Jane', surname => 'Smith', @@ -631,7 +631,7 @@ subtest 'SendAlerts - claimissue' => sub { } { - my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + my $publisheddate = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0]; ModSerialStatus( $serials[0]->{serialid}, "No. 1", $publisheddate, $publisheddate, $publisheddate, '3', 'a note' ); ($serials_count, @serials) = GetSerials($subscriptionid); diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t index 04658e78999..adcfd10dec3 100755 --- a/t/db_dependent/Letters/TemplateToolkit.t +++ b/t/db_dependent/Letters/TemplateToolkit.t @@ -625,7 +625,7 @@ EOF plan tests => 3; my $code = 'ISSUESLIP'; - my $now = dt_from_string; + my $now = dt_from_string(); my $one_minute_ago = dt_from_string->subtract( minutes => 1 ); my $branchcode = $library->{branchcode}; diff --git a/t/db_dependent/Members/IssueSlip.t b/t/db_dependent/Members/IssueSlip.t index dced42384d4..da9cf5622a7 100755 --- a/t/db_dependent/Members/IssueSlip.t +++ b/t/db_dependent/Members/IssueSlip.t @@ -123,7 +123,7 @@ my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; my $module = Test::MockModule->new('C4::Context'); $module->mock( 'userenv', sub { { branch => $branchcode } } ); -my $today = dt_from_string; +my $today = dt_from_string(); my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) ); subtest 'Issue slip' => sub { @@ -165,7 +165,7 @@ EOS # Set timestamps to the same value to avoid a different order Koha::Checkouts->search( { borrowernumber => $borrower->{borrowernumber} } - )->update( { timestamp => dt_from_string } ); + )->update( { timestamp => dt_from_string() } ); $expected_slip = <search( { borrowernumber => $borrower->{borrowernumber} } - )->update( { timestamp => dt_from_string } ); + )->update( { timestamp => dt_from_string() } ); $expected_slip = <new( } ); $b1->store(); -my $now = dt_from_string; +my $now = dt_from_string(); my $b2 = Koha::Patron->new( { surname => 'Test 2', diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index e748f115f48..c23c595df37 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -432,7 +432,7 @@ AddReserve( $holds = $item->current_holds; my $dtf = Koha::Database->new->schema->storage->datetime_parser; -my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); +my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string() ) } } ); is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); # 9788b: current_holds does not return future item level hold $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); @@ -446,11 +446,11 @@ AddReserve( itemnumber => $item->itemnumber, } ); #item level hold -$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); +$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string() ) } } ); is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); # 9788c: current_holds returns future wait (confirmed future hold) ModReserveAffect( $item->itemnumber, $requesters{$branch_1} , 0); #confirm hold -$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); +$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string() ) } } ); is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' ); # End of tests for bug 9788 diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 790248b748c..50d4f6dad79 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -245,7 +245,7 @@ subtest "Test cr_item_field" => sub { shift; return C4::SIP::ILS->checkin(@_); }); - my $today = dt_from_string; + my $today = dt_from_string(); my $respcode; @@ -587,7 +587,7 @@ sub test_checkout_v2 { shift; return C4::SIP::ILS->checkout(@_); }); - my $today = dt_from_string; + my $today = dt_from_string(); t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 }); t::lib::Mocks::mock_preference( 'CheckPrevCheckout', 'hardyes' ); @@ -650,7 +650,7 @@ sub test_checkin_v2 { shift; return C4::SIP::ILS->checkin(@_); }); - my $today = dt_from_string; + my $today = dt_from_string(); # Checkin invalid barcode Koha::Items->search({ barcode => 'not_to_be_found' })->delete; diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index 1f8cab65f21..3832fc7721d 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -462,7 +462,7 @@ subtest checkin_lost => sub { } ); - $item->itemlost(1)->itemlost_on(dt_from_string)->store(); + $item->itemlost(1)->itemlost_on(dt_from_string())->store(); my $instituation = { id => $library->id, @@ -500,7 +500,7 @@ subtest checkin_withdrawn => sub { } ); - $item->withdrawn(1)->withdrawn_on(dt_from_string)->store(); + $item->withdrawn(1)->withdrawn_on(dt_from_string())->store(); my $instituation = { id => $library->id, diff --git a/t/db_dependent/Search/History.t b/t/db_dependent/Search/History.t index 56946945349..e0364b02c58 100755 --- a/t/db_dependent/Search/History.t +++ b/t/db_dependent/Search/History.t @@ -224,7 +224,7 @@ C4::Search::History::add( { }); my $search_history_id = $dbh->last_insert_id( undef, undef, 'search_history', undef ); my $search_history = C4::Search::History::get({ id => $search_history_id }); -is( output_pref({ dt => dt_from_string($search_history->[0]->{time}), dateonly => 1 }), output_pref({ dt => dt_from_string, dateonly => 1 }), "Inserting a new search history should handle undefined time" ); +is( output_pref({ dt => dt_from_string($search_history->[0]->{time}), dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "Inserting a new search history should handle undefined time" ); delete_all( $userid ); @@ -378,7 +378,7 @@ $session->flush; sub myMockedget_from_session { my $expected_recent_searches = [ { - 'time' => dt_from_string, + 'time' => dt_from_string(), 'query_cgi' => 'cgi_test', 'total' => 2, 'query_desc' => 'kw,wrdl: history, ' diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 925a7502502..c5b8450cf17 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -240,7 +240,7 @@ is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing i subtest 'test_updateClaim' => sub { plan tests => 11; - my $today = output_pref({ dt => dt_from_string, dateonly => 1 }); + my $today = output_pref({ dt => dt_from_string(), dateonly => 1 }); # Given ... nothing much # When ... Then ... my $result_0 = C4::Serials::updateClaim(undef); @@ -335,7 +335,7 @@ is( @serials, 1, "GetSerials returns the serial" ); my $subscription = C4::Serials::GetSubscription($subscriptionid); my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); -my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); +my $publisheddate = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1); diff --git a/t/db_dependent/Serials/Claims.t b/t/db_dependent/Serials/Claims.t index afc3a18e663..da2aad3a5d2 100755 --- a/t/db_dependent/Serials/Claims.t +++ b/t/db_dependent/Serials/Claims.t @@ -159,6 +159,6 @@ is( $serial_claimed->{claims_count}, 2, 'The serial should have been claimed' ); is( $serial_claimed->{claims_count}, 1, 'The serial should have been claimed' ); -my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); +my $today = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # FIXME: This test should pass. The GetLateOrMissingIssues should not deal with date format! #is( $serial_claimed->{claimdate}, $today, 'The serial should have been claimed today' ); diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 44e90a945a8..a78c2bd17c3 100755 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -101,7 +101,7 @@ my $my_suggestion = { branchcode => 'CPL', managedby => '', manageddate => '', - accepteddate => dt_from_string, + accepteddate => dt_from_string(), note => 'my note', quantity => '', # Insert an empty string into int to catch strict SQL modes errors }; @@ -129,7 +129,7 @@ my $my_suggestion_with_budget = { biblionumber => $biblio_1->biblionumber, managedby => '', manageddate => '', - accepteddate => dt_from_string, + accepteddate => dt_from_string(), note => 'my note', budgetid => $budget_id, }; @@ -141,7 +141,7 @@ my $my_suggestion_with_budget2 = { biblionumber => $biblio_1->biblionumber, managedby => '', manageddate => '', - accepteddate => dt_from_string, + accepteddate => dt_from_string(), note => 'my note', budgetid => $budget_id, }; @@ -154,7 +154,7 @@ my $my_suggestion_without_suggestedby = { branchcode => 'CPL', managedby => '', manageddate => '', - accepteddate => dt_from_string, + accepteddate => dt_from_string(), note => 'my note', quantity => '', # Insert an empty string into int to catch strict SQL modes errors }; diff --git a/t/db_dependent/Template/Plugin/KohaDates.t b/t/db_dependent/Template/Plugin/KohaDates.t index e40c79565e9..239c07c16f7 100755 --- a/t/db_dependent/Template/Plugin/KohaDates.t +++ b/t/db_dependent/Template/Plugin/KohaDates.t @@ -53,7 +53,7 @@ is( $filtered_date, '01/04/1979', 'us: dt_from_string should return the valid da $filtered_date = $filter->filter('1979-04-01', undef, { dateformat => 'iso' } ); is( $filtered_date, '1979-04-01', 'date should be returned in ISO if dateformat is passed with a value of iso' ); -is( Koha::DateUtils::output_pref( dt_from_string ), $filter->output_preference( dt_from_string ), 'Filter output_preference method output matches output_pref' ); +is( Koha::DateUtils::output_pref( dt_from_string() ), $filter->output_preference( dt_from_string() ), 'Filter output_preference method output matches output_pref' ); $module_context->mock( 'tz', diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t index 9d535dd2be2..96a033ccd2d 100755 --- a/t/db_dependent/Upload.t +++ b/t/db_dependent/Upload.t @@ -287,7 +287,7 @@ subtest 'Testing delete_temporary' => sub { # Move all permanents to today - 1 # Move temp 1 to today - 3, and temp 2,3 to today - 5 - my $today = dt_from_string; + my $today = dt_from_string(); $today->subtract( minutes => 2 ); # should be enough :) my $dt = $today->clone->subtract( days => 1 ); foreach my $rec ( Koha::UploadedFiles->search({ permanent => 1 }) ) { diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t index d349b7b39b0..31f8f9d31cd 100755 --- a/t/db_dependent/Virtualshelves.t +++ b/t/db_dependent/Virtualshelves.t @@ -44,7 +44,7 @@ subtest 'CRUD' => sub { is( $number_of_shelves, 1, '1 shelf should have been inserted' ); is( $shelf->allow_change_from_owner, 1, 'The default value for allow_change_from_owner should be 1' ); is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' ); - is( t::lib::Dates::compare( $shelf->created_on, dt_from_string), 0, 'The creation time should have been set to today' ); + is( t::lib::Dates::compare( $shelf->created_on, dt_from_string()), 0, 'The creation time should have been set to today' ); # Test if creation date will not be overwritten by store my $created = dt_from_string->subtract( hours => 1 ); @@ -196,7 +196,7 @@ subtest 'Shelf content' => sub { my $content1 = $shelf->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} ); is( ref($content1), 'Koha::Virtualshelfcontent', 'add_biblio to a shelf should return a Koha::Virtualshelfcontent object if inserted' ); $shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); - is( t::lib::Dates::compare( $shelf->lastmodified, dt_from_string), 0, 'Adding a biblio to a shelf should update the lastmodified for the shelf' ); + is( t::lib::Dates::compare( $shelf->lastmodified, dt_from_string()), 0, 'Adding a biblio to a shelf should update the lastmodified for the shelf' ); my $content2 = $shelf->add_biblio( $biblio2->biblionumber, $patron1->{borrowernumber} ); $number_of_contents = Koha::Virtualshelfcontents->search->count; is( $number_of_contents, 2, '2 biblio should have been inserted' ); diff --git a/t/db_dependent/api/v1/return_claims.t b/t/db_dependent/api/v1/return_claims.t index a9877f79463..fda1aa683a5 100755 --- a/t/db_dependent/api/v1/return_claims.t +++ b/t/db_dependent/api/v1/return_claims.t @@ -28,7 +28,7 @@ use C4::Circulation qw( AddIssue ); use Koha::Checkouts::ReturnClaims; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); +use Koha::DateUtils qw(dt_from_string()); my $schema = Koha::Database->schema; my $builder = t::lib::TestBuilder->new; diff --git a/t/lib/Koha/BackgroundJob/BatchTest.pm b/t/lib/Koha/BackgroundJob/BatchTest.pm index 2b6490dbfcc..23aaa651318 100644 --- a/t/lib/Koha/BackgroundJob/BatchTest.pm +++ b/t/lib/Koha/BackgroundJob/BatchTest.pm @@ -37,7 +37,7 @@ sub process { } my $job_progress = 0; - $job->started_on(dt_from_string) + $job->started_on(dt_from_string()) ->progress($job_progress) ->status('started') ->store; @@ -63,7 +63,7 @@ sub process { $job_data->{messages} = \@messages; $job_data->{report} = $report; - $job->ended_on(dt_from_string) + $job->ended_on(dt_from_string()) ->data(encode_json $job_data); $job->status('finished') if $job->status ne 'cancelled'; $job->store; diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index e8b0dbf1269..551aaa9a442 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -2,10 +2,10 @@ package t::lib::TestBuilder; use Modern::Perl; -use Koha::Database qw( schema ); +use Koha::Database; use C4::Biblio qw( AddBiblio ); -use Koha::Biblios qw( _type ); -use Koha::Items qw( _type ); +use Koha::Biblios; +use Koha::Items; use Koha::DateUtils qw( dt_from_string ); use Bytes::Random::Secure; @@ -506,12 +506,12 @@ sub _gen_real { sub _gen_date { my ($self, $params) = @_; - return $self->schema->storage->datetime_parser->format_date(dt_from_string) + return $self->schema->storage->datetime_parser->format_date(dt_from_string()) } sub _gen_datetime { my ($self, $params) = @_; - return $self->schema->storage->datetime_parser->format_datetime(dt_from_string); + return $self->schema->storage->datetime_parser->format_datetime(dt_from_string()); } sub _gen_text { diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 0f57a2debd9..951e8c99a3b 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -439,7 +439,7 @@ foreach my $tag (sort keys %{$tagslib}) { if ( $use_default_values) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; # get today date & replace YYYY, MM, DD if provided in the default value - my $today = dt_from_string; + my $today = dt_from_string(); my $year = $today->year; my $month = $today->month; my $day = $today->day; diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index add68a23bc1..ece607ad76a 100755 --- a/tools/cleanborrowers.pl +++ b/tools/cleanborrowers.pl @@ -53,19 +53,19 @@ my $params = $cgi->Vars; my $step = $params->{step} || 1; my $not_borrowed_since = # the date which filter on issue history. $params->{not_borrowed_since} - ? dt_from_string $params->{not_borrowed_since} + ? dt_from_string() $params->{not_borrowed_since} : undef; my $last_issue_date = # the date which filter on borrowers last issue. $params->{last_issue_date} - ? dt_from_string $params->{last_issue_date} + ? dt_from_string() $params->{last_issue_date} : undef; my $borrower_dateexpiry = $params->{borrower_dateexpiry} - ? dt_from_string $params->{borrower_dateexpiry} + ? dt_from_string() $params->{borrower_dateexpiry} : undef; my $borrower_lastseen = $params->{borrower_lastseen} - ? dt_from_string $params->{borrower_lastseen} + ? dt_from_string() $params->{borrower_lastseen} : undef; my $patron_list_id = $params->{patron_list_id}; diff --git a/tools/holidays.pl b/tools/holidays.pl index ddf45db1dcb..a6d795680b3 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -39,7 +39,7 @@ my ($template, $loggedinuser, $cookie) # calendardate - date passed in url for human readability (syspref) # if the url has an invalid date default to 'now.' -my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate') ); } || dt_from_string; +my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate') ); } || dt_from_string(); my $calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } ); # keydate - date passed to calendar.js. calendar.js does not process dashes within a date. diff --git a/tools/inventory.pl b/tools/inventory.pl index 5eac6e4e743..8f81f198168 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -134,7 +134,7 @@ foreach my $itemtype ( @itemtypes ) { $template->param( authorised_values => \@authorised_value_list, - today => dt_from_string, + today => dt_from_string(), minlocation => $minlocation, maxlocation => $maxlocation, location => $location, @@ -225,7 +225,7 @@ if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch}); if( $doreturn ) { $item_unblessed->{onloan} = undef; - $item_unblessed->{datelastseen} = dt_from_string; + $item_unblessed->{datelastseen} = dt_from_string(); } else { push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 }; } -- 2.25.1