Browse Source

Bug 13813: Remove deprecated module C4::Dates from system

Test plan: See Bugzilla.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
3.22.x
Marc Véron 7 years ago
committed by Tomas Cohen Arazi
parent
commit
5dceb851dd
  1. 5
      C4/Acquisition.pm
  2. 1
      C4/Barcodes.pm
  3. 13
      C4/Barcodes/annual.pm
  4. 27
      C4/Barcodes/hbyymmincr.pm
  5. 1
      C4/Biblio.pm
  6. 1
      C4/HoldsQueue.pm
  7. 16
      C4/Items.pm
  8. 6
      C4/Log.pm
  9. 8
      C4/NewsChannels.pm
  10. 1
      C4/Output.pm
  11. 9
      C4/Suggestions.pm
  12. 1
      Koha/Borrower/Files.pm
  13. 1
      Koha/Misc/Files.pm
  14. 4
      cataloguing/value_builder/barcode.pl
  15. 4
      cataloguing/value_builder/barcode_manual.pl
  16. 5
      cataloguing/value_builder/dateaccessioned.pl
  17. 4
      circ/transferstoreceive.pl
  18. 5
      circ/waitingreserves.pl
  19. 1
      members/notices.pl
  20. 4
      members/printinvoice.pl
  21. 5
      members/readingrec.pl
  22. 1
      opac/opac-messaging.pl
  23. 1
      opac/opac-privacy.pl
  24. 4
      opac/opac-user.pl
  25. 1
      tags/list.pl
  26. 6
      tools/koha-news.pl
  27. 6
      tools/scheduler.pl
  28. 1
      tools/viewlog.pl

5
C4/Acquisition.pm

@ -22,7 +22,6 @@ use Modern::Perl;
use Carp;
use C4::Context;
use C4::Debug;
use C4::Dates qw(format_date format_date_in_iso);
use C4::Suggestions;
use C4::Biblio;
use C4::Contract;
@ -1393,7 +1392,7 @@ sub ModReceiveOrder {
my $order_vendornote = $params->{order_vendornote};
my $dbh = C4::Context->dbh;
$datereceived = C4::Dates->output('iso') unless $datereceived;
$datereceived = output_pref({ dt=>dt_from_string, dateonly=>1, dateformat=>'iso' }) unless $datereceived;
my $suggestionid = GetSuggestionFromBiblionumber( $biblionumber );
if ($suggestionid) {
ModSuggestion( {suggestionid=>$suggestionid,
@ -2719,7 +2718,7 @@ sub CloseInvoice {
Reopen an invoice
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string, dateonly=>1, otputpref=>'iso' }))
=cut

1
C4/Barcodes.pm

@ -24,7 +24,6 @@ use Carp;
use C4::Context;
use C4::Debug;
use C4::Dates;
use C4::Barcodes::hbyymmincr;
use C4::Barcodes::annual;
use C4::Barcodes::incremental;

13
C4/Barcodes/annual.pm

@ -24,7 +24,8 @@ use Carp;
use C4::Context;
use C4::Debug;
use C4::Dates;
use Koha::DateUtils qw( output_pref dt_from_string );
use vars qw($VERSION @ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
@ -44,13 +45,13 @@ sub db_max ($;$) {
my ($iso);
if (@_) {
my $input = shift;
$iso = C4::Dates->new($input,'iso')->output('iso'); # try to set the date w/ 2nd arg
$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 = C4::Dates->new->output('iso'); # failover back to today
$iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # failover back to today
}
} else {
$iso = C4::Dates->new->output('iso');
$iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
}
my $year = substr($iso,0,4); # YYYY
$sth->execute("$year-%");
@ -61,7 +62,7 @@ sub db_max ($;$) {
sub initial () {
my $self = shift;
return substr(C4::Dates->new->output('iso'),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 ($;$) {
@ -82,7 +83,7 @@ sub width ($;$) {
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.
return substr(C4::Dates->new->output('iso'),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 {

27
C4/Barcodes/hbyymmincr.pm

@ -24,7 +24,8 @@ use Carp;
use C4::Context;
use C4::Debug;
use C4::Dates;
use Koha::DateUtils qw( dt_from_string output_pref );
use vars qw($VERSION @ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
@ -48,16 +49,16 @@ sub db_max {
$debug and print STDERR "(hbyymmincr) db_max query: $query\n";
my $sth = C4::Context->dbh->prepare($query);
my ($iso);
if (@_) {
my $input = shift;
$iso = C4::Dates->new($input,'iso')->output('iso'); # 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 = C4::Dates->new->output('iso'); # failover back to today
}
} else {
$iso = C4::Dates->new->output('iso');
}
if (@_) {
my $input = shift;
$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
}
} else {
$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;
$sth->execute("^[a-zA-Z]{1,}" . $year . "[0-9]{$andtwo}"); # the extra two digits are the month. we don't care what they are, just that they are there.
@ -74,7 +75,7 @@ sub db_max {
sub initial {
my $self = shift;
# FIXME: populated branch?
my $iso = C4::Dates->new->output('iso'); # like "2008-07-02"
my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
}
@ -104,7 +105,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 = C4::Dates->new->output('iso'); # 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);
}

1
C4/Biblio.pm

@ -31,7 +31,6 @@ use POSIX qw(strftime);
use Module::Load::Conditional qw(can_load);
use C4::Koha;
use C4::Dates qw/format_date/;
use C4::Log; # logaction
use C4::Budgets;
use C4::ClassSource;

1
C4/HoldsQueue.pm

@ -29,7 +29,6 @@ use C4::Branch;
use C4::Circulation;
use C4::Members;
use C4::Biblio;
use C4::Dates qw/format_date/;
use List::Util qw(shuffle);
use List::MoreUtils qw(any);

16
C4/Items.pm

@ -25,7 +25,7 @@ use Carp;
use C4::Context;
use C4::Koha;
use C4::Biblio;
use C4::Dates qw/format_date format_date_in_iso/;
use Koha::DateUtils;
use MARC::Record;
use C4::ClassSource;
use C4::Log;
@ -648,8 +648,8 @@ C<$itemnum> is the item number
sub ModDateLastSeen {
my ($itemnumber) = @_;
my $today = C4::Dates->new();
ModItem({ itemlost => 0, datelastseen => $today->output("iso") }, undef, $itemnumber);
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
ModItem({ itemlost => 0, datelastseen => $today }, undef, $itemnumber);
}
=head2 DelItem
@ -2128,7 +2128,7 @@ C<items.withdrawn>
sub _set_defaults_for_add {
my $item = shift;
$item->{dateaccessioned} ||= C4::Dates->new->output('iso');
$item->{dateaccessioned} ||= output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
$item->{$_} ||= 0 for (qw( notforloan damaged itemlost withdrawn));
}
@ -2162,7 +2162,7 @@ sub _koha_new_item {
notforloan = ?,
damaged = ?,
itemlost = ?,
withdrawn = ?,
withdrawn = ?,
itemcallnumber = ?,
coded_location_qualifier = ?,
restricted = ?,
@ -2171,7 +2171,7 @@ sub _koha_new_item {
holdingbranch = ?,
paidfor = ?,
location = ?,
permanent_location = ?,
permanent_location = ?,
onloan = ?,
issues = ?,
renewals = ?,
@ -2181,14 +2181,14 @@ sub _koha_new_item {
ccode = ?,
itype = ?,
materials = ?,
uri = ?,
uri = ?,
enumchron = ?,
more_subfields_xml = ?,
copynumber = ?,
stocknumber = ?
";
my $sth = $dbh->prepare($query);
my $today = C4::Dates->today('iso');
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
$sth->execute(
$item->{'biblionumber'},
$item->{'biblioitemnumber'},

6
C4/Log.pm

@ -25,7 +25,7 @@ use strict;
use warnings;
use C4::Context;
use C4::Dates qw(format_date);
use Koha::DateUtils;
use vars qw($VERSION @ISA @EXPORT);
@ -220,8 +220,8 @@ sub GetLogs {
my $object = shift;
my $info = shift;
my $iso_datefrom = C4::Dates->new($datefrom,C4::Context->preference("dateformat"))->output('iso');
my $iso_dateto = C4::Dates->new($dateto,C4::Context->preference("dateformat"))->output('iso');
my $iso_datefrom = output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 });
my $iso_dateto = output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 });
my $dbh = C4::Context->dbh;
my $query = "

8
C4/NewsChannels.pm

@ -20,7 +20,7 @@ package C4::NewsChannels;
use Modern::Perl;
use C4::Context;
use C4::Dates qw(format_date);
use Koha::DateUtils;
use vars qw($VERSION @ISA @EXPORT);
@ -135,8 +135,8 @@ sub get_opac_new {
$sth->execute($idnew);
my $data = $sth->fetchrow_hashref;
$data->{$data->{'lang'}} = 1 if defined $data->{lang};
$data->{expirationdate} = format_date($data->{expirationdate});
$data->{timestamp} = format_date($data->{timestamp});
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 });
$data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ;
return $data;
}
@ -209,7 +209,7 @@ sub GetNewsToDisplay {
$sth->execute($lang,$branch);
my @results;
while ( my $row = $sth->fetchrow_hashref ){
$row->{newdate} = format_date($row->{newdate});
$row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 });
push @results, $row;
}
return \@results;

1
C4/Output.pm

@ -31,7 +31,6 @@ use strict;
use URI::Escape;
use C4::Context;
use C4::Dates qw(format_date);
use C4::Templates;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

9
C4/Suggestions.pm

@ -25,13 +25,11 @@ use CGI qw ( -utf8 );
use C4::Context;
use C4::Output;
use C4::Dates qw(format_date format_date_in_iso);
use C4::Debug;
use C4::Letters;
use Koha::DateUtils qw( dt_from_string );
use Koha::DateUtils;
use List::MoreUtils qw(any);
use C4::Dates qw(format_date_in_iso);
use base qw(Exporter);
our $VERSION = 3.07.00.049;
@ -176,16 +174,15 @@ sub SearchSuggestion {
}
# filter on date fields
my $today = C4::Dates->today('iso');
foreach my $field (qw( suggesteddate manageddate accepteddate )) {
my $from = $field . "_from";
my $to = $field . "_to";
if ( $suggestion->{$from} || $suggestion->{$to} ) {
push @query, qq{ AND suggestions.$field BETWEEN ? AND ? };
push @sql_params,
format_date_in_iso( $suggestion->{$from} ) || '0000-00-00';
output_pref({ dt => dt_from_string( $suggestion->{$from} ), dateformat => 'iso', dateonly => 1 }) || '0000-00-00';
push @sql_params,
format_date_in_iso( $suggestion->{$to} ) || $today;
output_pref({ dt => dt_from_string( $suggestion->{$to} ), dateformat => 'iso', dateonly => 1 }) || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
}
}

1
Koha/Borrower/Files.pm

@ -23,7 +23,6 @@ use vars qw($VERSION);
use C4::Context;
use C4::Output;
use C4::Dates;
use C4::Debug;
BEGIN {

1
Koha/Misc/Files.pm

@ -25,7 +25,6 @@ $VERSION = '0.25';
use C4::Context;
use C4::Output;
use C4::Dates;
=head1 NAME

4
cataloguing/value_builder/barcode.pl

@ -23,7 +23,7 @@ no warnings 'redefine'; # otherwise loading up multiple plugins fills the log wi
use C4::Context;
require C4::Barcodes::ValueBuilder;
require C4::Dates;
use Koha::DateUtils;
use Algorithm::CheckDigits;
@ -35,7 +35,7 @@ sub plugin_javascript {
my %args;
# find today's date
($args{year}, $args{mon}, $args{day}) = split('-', C4::Dates->today('iso'));
($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", '');

4
cataloguing/value_builder/barcode_manual.pl

@ -23,7 +23,7 @@ no warnings 'redefine'; # otherwise loading up multiple plugins fills the log wi
use C4::Context;
require C4::Barcodes::ValueBuilder;
require C4::Dates;
use Koha::DateUtils;
my $DEBUG = 0;
@ -35,7 +35,7 @@ sub plugin_javascript {
$args{dbh} = $dbh;
# find today's date
($args{year}, $args{mon}, $args{day}) = split('-', C4::Dates->today('iso'));
($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", '');

5
cataloguing/value_builder/dateaccessioned.pl

@ -18,15 +18,14 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::DateUtils;
no warnings 'redefine';
sub plugin_javascript {
# my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
my $function_name = "dateaccessioned".(int(rand(100000))+1);
require C4::Dates;
my $date = C4::Dates->today('iso');
my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
# find the tag/subfield mapped to items.dateaccessioned
my ($tag,$subfield) = GetMarcFromKohaField("items.dateaccessioned","");

4
circ/transferstoreceive.pl

@ -25,7 +25,7 @@ use C4::Context;
use C4::Output;
use C4::Branch; # GetBranches
use C4::Auth;
use C4::Dates qw/format_date/;
use Koha::DateUtils;
use C4::Biblio;
use C4::Circulation;
use C4::Members;
@ -119,7 +119,7 @@ foreach my $br ( keys %$branches ) {
$template->param(
branchesloop => \@branchesloop,
show_date => format_date(C4::Dates->today('iso')),
show_date => output_pref({ dt => dt_from_string, dateonly => 1 }),
TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'),
latetransfers => $latetransfers ? 1 : 0,
);

5
circ/waitingreserves.pl

@ -25,12 +25,11 @@ use C4::Context;
use C4::Output;
use C4::Branch; # GetBranchName
use C4::Auth;
use C4::Dates qw/format_date/;
use C4::Circulation;
use C4::Members;
use C4::Biblio;
use C4::Items;
use Koha::DateUtils;
use Date::Calc qw(
Today
Add_Delta_Days
@ -158,7 +157,7 @@ $template->param(
reservecount => $reservcount,
overloop => \@overloop,
overcount => $overcount,
show_date => format_date(C4::Dates->today('iso')),
show_date => output_pref({ dt => dt_from_string, dateonly => 1 }),
ReservesMaxPickUpDelay => C4::Context->preference('ReservesMaxPickUpDelay')
);

1
members/notices.pl

@ -29,7 +29,6 @@ use C4::Branch;
use C4::Letters;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Dates qw/format_date/;
my $input=new CGI;

4
members/printinvoice.pl

@ -25,7 +25,7 @@ use warnings;
use C4::Auth;
use C4::Output;
use C4::Dates qw/format_date/;
use Koha::DateUtils;
use CGI qw ( -utf8 );
use C4::Members;
use C4::Branch;
@ -89,7 +89,7 @@ for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
}
my %row = (
'date' => format_date( $accts->[$i]{'date'} ),
'date' => output_pref({ dt => dt_from_string( $accts->[$i]{'date'}, 'iso' ), dateonly => 1 }),
'amountcredit' => $accts->[$i]{'amountcredit'},
'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
'toggle' => $accts->[$i]{'toggle'},

5
members/readingrec.pl

@ -31,8 +31,6 @@ use C4::Members;
use C4::Branch qw(GetBranches);
use List::MoreUtils qw/any uniq/;
use Koha::DateUtils;
use C4::Dates qw/format_date/;
use C4::Members::Attributes qw(GetBorrowerAttributes);
my $input = CGI->new;
@ -77,8 +75,7 @@ my $branches = GetBranches();
# barcode export
if ( $op eq 'export_barcodes' ) {
my $today = C4::Dates->new();
$today = $today->output('iso');
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
my @barcodes =
map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
my $borrowercardnumber =

1
opac/opac-messaging.pl

@ -27,7 +27,6 @@ use C4::Context;
use C4::Koha;
use C4::Circulation;
use C4::Output;
use C4::Dates qw/format_date/;
use C4::Members;
use C4::Members::Messaging;
use C4::Branch;

1
opac/opac-privacy.pl

@ -24,7 +24,6 @@ use C4::Context;
use C4::Circulation;
use C4::Members;
use C4::Output;
use C4::Dates;
my $query = new CGI;

4
opac/opac-user.pl

@ -292,7 +292,9 @@ foreach my $res (@reserves) {
if ($show_priority) {
$res->{'priority'} ||= '';
}
$res->{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref") if ( $res->{'suspend_until'} );
if ( $res->{'suspend_until'} ) {
$res->{'suspend_until'} = output_pref({ dt => dt_from_string( $res->{'suspend_until'} , 'iso' ), dateonly => 1 });
}
}
# use Data::Dumper;

1
tags/list.pl

@ -24,7 +24,6 @@ use CGI qw ( -utf8 );
use C4::Auth qw(:DEFAULT check_cookie_auth);
use C4::Biblio;
use C4::Context;
use C4::Dates qw(format_date);
use C4::Items;
use C4::Koha;
use C4::Tags qw(get_tags remove_tag get_tag_rows);

6
tools/koha-news.pl

@ -28,20 +28,20 @@ use CGI qw ( -utf8 );
use C4::Auth;
use C4::Koha;
use C4::Context;
use C4::Dates qw(format_date_in_iso);
use C4::Output;
use C4::NewsChannels;
use C4::Languages qw(getTranslatedLanguages);
use Date::Calc qw/Date_to_Days Today/;
use C4::Branch qw/GetBranches/;
use Koha::DateUtils;
my $cgi = new CGI;
my $id = $cgi->param('id');
my $title = $cgi->param('title');
my $new = $cgi->param('new');
my $expirationdate = format_date_in_iso($cgi->param('expirationdate'));
my $timestamp = format_date_in_iso($cgi->param('timestamp'));
my $expirationdate = output_pref({ dt => dt_from_string( $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
my $timestamp = output_pref({ dt => dt_from_string( $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 });
my $number = $cgi->param('number');
my $lang = $cgi->param('lang');
my $branchcode = $cgi->param('branch');

6
tools/scheduler.pl

@ -25,7 +25,7 @@ use C4::Reports::Guided;
use C4::Auth;
use CGI qw ( -utf8 );
use C4::Output;
use C4::Dates;
use Koha::DateUtils;;
use vars qw($debug);
@ -62,10 +62,10 @@ my $id = $input->param('id');
if ( $mode eq 'job_add' ) {
# Retrieving the date according to the dateformat syspref
my $c4date = C4::Dates->new($input->param('startdate'));
my $c4date = output_pref({ dt => dt_from_string( $input->param('startdate') ), dateformat => 'iso', dateonly => 1 });
# Formatting it for Schedule::At
my $startdate = join('', (split /-/, $c4date->output("iso")));
my $startdate = join('', (split /-/, $c4date));
my $starttime = $input->param('starttime');
$starttime =~ s/\://g;

1
tools/viewlog.pl

@ -25,7 +25,6 @@ use CGI qw ( -utf8 );
use Text::CSV::Encoded;
use C4::Context;
use C4::Koha;
use C4::Dates;
use C4::Output;
use C4::Log;
use C4::Items;

Loading…
Cancel
Save