From 27d679010d1d479af2b6c10b39cba4f12713646d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Sat, 10 Oct 2015 11:38:20 +0200 Subject: [PATCH] Bug 14998 - Remove C4::Dates from installer and maintenance folders - installer/data/mysql/updatedatabase.pl - misc/maintenance/fix_accountlines_date.pl To test for updatedatabase.pl - perl installer/data/mysql/updatedatabase.pl - review code. Difficult to test, because the code affects $DBversion = '3.03.00.035' To test for misc/maintenance/fix_accountlines_date.pl - review code - The file seems to be a file used for an update, could it be obsolete? If yes, remove it in a follow-up Signed-off-by: Frederic Demians Code OK. Tested updatedatabase.pl with an old DB backup: OK. fix_accountlines_date.pl still working after the patch. Could be removed from master IMO. --- installer/data/mysql/updatedatabase.pl | 6 +++--- misc/maintenance/fix_accountlines_date.pl | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5e1bff4..a8d3c65 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -36,9 +36,9 @@ use Getopt::Long; # Koha modules use C4::Context; use C4::Installer; -use C4::Dates; use Koha::Database; use Koha; +use Koha::DateUtils; use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'utf8' ); @@ -4170,10 +4170,10 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("ALTER TABLE `issuingrules` ADD hardduedatecompare tinyint NOT NULL default 0 AFTER hardduedate"); my $duedate; if (C4::Context->preference("globalDueDate")) { - $duedate = C4::Dates::format_date_in_iso(C4::Context->preference("globalDueDate")); + $duedate = eval { output_pref( { dt => dt_from_string( C4::Context->preference("globalDueDate") ), dateonly => 1, dateformat => 'iso' } ); }; $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = 0"); } elsif (C4::Context->preference("ceilingDueDate")) { - $duedate = C4::Dates::format_date_in_iso(C4::Context->preference("ceilingDueDate")); + $duedate = eval { output_pref( { dt => dt_from_string( C4::Context->preference("ceilingDueDate") ), dateonly => 1, dateformat => 'iso' } ); }; $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = -1"); } $dbh->do("DELETE FROM `systempreferences` WHERE variable = 'globalDueDate' OR variable = 'ceilingDueDate'"); diff --git a/misc/maintenance/fix_accountlines_date.pl b/misc/maintenance/fix_accountlines_date.pl index 896edfa..e0c97f6 100755 --- a/misc/maintenance/fix_accountlines_date.pl +++ b/misc/maintenance/fix_accountlines_date.pl @@ -27,9 +27,9 @@ BEGIN { } use C4::Context; -use C4::Dates; use Getopt::Long; use Pod::Usage; +use Koha::DateUtils; =head1 NAME @@ -146,16 +146,16 @@ while (my $accountline = $sth->fetchrow_hashref) { if ($mode eq 'us') { if ($description =~ /$US_DATE/) { # mm/dd/yyyy - my $date = C4::Dates->new($1, 'us'); - print "Converting $1 (us) to " . $date->output() . "\n" if $DEBUG; - $description =~ s/$US_DATE/$date->output()/; + my $date = eval { output_pref( { dt => dt_from_string( $1 ), dateonly => 1, dateformat => 'us' } ); }; + print "Converting $1 (us) to " . $date . "\n" if $DEBUG;i + $description =~ s/$US_DATE/$date/; $updated = 1; } } elsif ($mode eq 'metric') { if ($description =~ /$METRIC_DATE/) { # dd/mm/yyyy - my $date = C4::Dates->new($1, 'metric'); - print "Converting $1 (metric) to " . $date->output() . "\n" if $DEBUG; - $description =~ s/$METRIC_DATE/$date->output()/; + my $date = eval { output_pref( { dt => dt_from_string( $1 ), dateonly => 1, dateformat => 'metric' } ); }; + print "Converting $1 (metric) to " . $date . "\n" if $DEBUG; + $description =~ s/$METRIC_DATE/$date/; $updated = 2; } } -- 2.6.2