@@ -, +, @@ - C4/Members.pm - C4/Reserves.pm - C4/Search.pm - C4/Utils/DataTables.pm - C4/Utils/DataTables/Members.pm - C4/VirtualShelves/Page.pm -run tests as appropriate, - have a close look at the code changes - try to find regressions --- C4/Members.pm | 13 ++++++------- C4/Reserves.pm | 16 +++++++++------- C4/Search.pm | 4 ++-- C4/Utils/DataTables.pm | 4 ++-- C4/Utils/DataTables/Members.pm | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) --- a/C4/Members.pm +++ a/C4/Members.pm @@ -23,7 +23,6 @@ package C4::Members; use strict; #use warnings; FIXME - Bug 2505 use C4::Context; -use C4::Dates qw(format_date_in_iso format_date); use String::Random qw( random_string ); use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/; use C4::Log; # logaction @@ -738,12 +737,12 @@ sub AddMember { # add expiration date if it isn't already there unless ( $data{'dateexpiry'} ) { - $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, C4::Dates->new()->output("iso") ); + $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ); } # add enrollment date if it isn't already there unless ( $data{'dateenrolled'} ) { - $data{'dateenrolled'} = C4::Dates->new()->output("iso"); + $data{'dateenrolled'} = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); } my $patron_category = $schema->resultset('Category')->find( $data{'categorycode'} ); @@ -1862,8 +1861,9 @@ sub ExtendMemberSubscriptionTo { my $borrower = GetMember('borrowernumber'=>$borrowerid); unless ($date){ $date = (C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry') ? - C4::Dates->new($borrower->{'dateexpiry'}, 'iso')->output("iso") : - C4::Dates->new()->output("iso"); + eval { output_pref( { dt => dt_from_string( $borrower->{'dateexpiry'} ), dateonly => 1, dateformat => 'iso' } ); } + : + output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); $date = GetExpiryDate( $borrower->{'categorycode'}, $date ); } my $sth = $dbh->do(<fetchrow_hashref ) { - my $d = C4::Dates->new( $data->{message_date}, 'iso' ); - $data->{message_date_formatted} = $d->output; + $data->{message_date_formatted} = eval { output_pref( { dt => dt_from_string( $data->{message_date} ), dateonly => 1, dateformat => 'iso' } ); }; push @results, $data; } return \@results; --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -35,7 +35,6 @@ use C4::Members::Messaging; use C4::Members qw(); use C4::Letters; use C4::Branch qw( GetBranchDetail ); -use C4::Dates qw( format_date_in_iso ); use Koha::DateUtils; use Koha::Calendar; @@ -166,11 +165,13 @@ sub AddReserve { my $dbh = C4::Context->dbh; - $resdate = format_date_in_iso( $resdate ) if ( $resdate ); - $resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); + $resdate = eval { output_pref( { dt => dt_from_string( $resdate ), dateonly => 1 }); } + if ( $resdate ); + $resdate = eval { output_pref( { dt => dt_from_string, dateonly => 1 }); } + unless ( $resdate ); if ($expdate) { - $expdate = format_date_in_iso( $expdate ); + $expdate = eval { output_pref( { dt => dt_from_string( $expdate), dateonly => 1, dateformat => 'iso' } ); }; } else { undef $expdate; # make reserves.expirationdate default to null rather than '0000-00-00' } @@ -1162,7 +1163,7 @@ sub ModReserve { if ( defined( $suspend_until ) ) { if ( $suspend_until ) { - $suspend_until = C4::Dates->new( $suspend_until )->output("iso"); + $suspend_until = eval { output_pref( { dt => dt_from_string( $suspend_until ), dateonly => 1 }); }; $dbh->do("UPDATE reserves SET suspend = 1, suspend_until = ? WHERE reserve_id = ?", undef, ( $suspend_until, $reserve_id ) ); } else { $dbh->do("UPDATE reserves SET suspend_until = NULL WHERE reserve_id = ?", undef, ( $reserve_id ) ); @@ -1655,7 +1656,8 @@ sub SuspendAll { my $suspend_until = $params{'suspend_until'} || undef; my $suspend = defined( $params{'suspend'} ) ? $params{'suspend'} : 1; - $suspend_until = C4::Dates->new( $suspend_until )->output("iso") if ( defined( $suspend_until ) ); + $suspend_until = eval { output_pref( { dt => dt_from_string( $suspend_until), dateonly => 1, dateformat => 'iso' } ); } + if ( defined( $suspend_until ) ); return unless ( $borrowernumber || $biblionumber ); @@ -1976,7 +1978,7 @@ sub _koha_notify_reserve { 'reserves' => $reserve, 'items', $reserve->{'itemnumber'}, }, - substitute => { today => C4::Dates->new()->output() }, + substitute => { today => eval { output_pref( { dt => dt_from_string, dateonly => 1 } ); } }, ); my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. --- a/C4/Search.pm +++ a/C4/Search.pm @@ -21,10 +21,10 @@ require Exporter; use C4::Context; use C4::Biblio; # GetMarcFromKohaField, GetBiblioData use C4::Koha; # getFacets +use Koha::DateUtils; use Lingua::Stem; use C4::Search::PazPar2; use XML::Simple; -use C4::Dates qw(format_date); use C4::Members qw(GetHideLostItemsPreference); use C4::XSLT; use C4::Branch; @@ -2094,7 +2094,7 @@ sub searchResults { { $onloan_count++; my $key = $prefix . $item->{onloan} . $item->{barcode}; - $onloan_items->{$key}->{due_date} = format_date( $item->{onloan} ); + $onloan_items->{$key}->{due_date} = eval { output_pref( { dt => dt_from_string( $item->{onloan} ), dateonly => 1 } ); }; $onloan_items->{$key}->{count}++ if $item->{$hbranch}; $onloan_items->{$key}->{branchname} = $item->{branchname}; $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} }; --- a/C4/Utils/DataTables.pm +++ a/C4/Utils/DataTables.pm @@ -249,11 +249,11 @@ sub dt_build_query_dates { my @params; if ( $datefrom ) { $query .= " AND $field >= ? "; - push @params, C4::Dates->new($datefrom)->output('iso'); + push @params, eval { output_pref( { dt => dt_from_string( $datefrom ), dateonly => 1, dateformat => 'iso' } ); }; } if ( $dateto ) { $query .= " AND $field <= ? "; - push @params, C4::Dates->new($dateto)->output('iso'); + push @params, eval { output_pref( { dt => dt_from_string( $dateto ), dateonly => 1, dateformat => 'iso' } ); }; } return ( $query, \@params ); } --- a/C4/Utils/DataTables/Members.pm +++ a/C4/Utils/DataTables/Members.pm @@ -142,7 +142,7 @@ sub search { ($patron->{overdues}, $patron->{issues}, $patron->{fines}) = GetMemberIssuesAndFines($patron->{borrowernumber}); if($patron->{dateexpiry} and $patron->{dateexpiry} ne '0000-00-00') { - $patron->{dateexpiry} = C4::Dates->new($patron->{dateexpiry}, "iso")->output(); + $patron->{dateexpiry} = eval { output_pref( { dt => dt_from_string( $patron->{dateexpiry}), dateonly => 1, dateformat => 'iso' } ); }; } else { $patron->{dateexpiry} = ''; } --