Bugzilla – Attachment 43285 Details for
Bug 14985
Remove C4::Dates from 6 files in folder C4/*.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Remove C4::Dates from files in folder C4/*.pm (part one)
Remove-C4Dates-from-files-in-folder-C4pm-part-one.patch (text/plain), 9.79 KB, created by
Marc Véron
on 2015-10-08 21:05:33 UTC
(
hide
)
Description:
Remove C4::Dates from files in folder C4/*.pm (part one)
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-10-08 21:05:33 UTC
Size:
9.79 KB
patch
obsolete
>From 8e2759b2daa94ba6c34d0be34c9bdb8b980ee5b6 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Thu, 8 Oct 2015 23:02:30 +0200 >Subject: [PATCH] Remove C4::Dates from files in folder C4/*.pm (part one) > >This patch removes C4::Dates from following files in folder C4: > >- C4/Members.pm >- C4/Reserves.pm >- C4/Search.pm >- C4/Utils/DataTables.pm >- C4/Utils/DataTables/Members.pm >- C4/VirtualShelves/Page.pm > >To test: > -run tests as appropriate, >- have a close look at the code changes >- try to find regressions > >http://bugs.koha-community.org/show_bug.cgi?id=14985 >--- > C4/Members.pm | 13 ++++++------- > C4/Reserves.pm | 16 +++++++++------- > C4/Search.pm | 4 ++-- > C4/Utils/DataTables.pm | 4 ++-- > C4/Utils/DataTables/Members.pm | 2 +- > C4/VirtualShelves/Page.pm | 4 ++-- > 6 files changed, 22 insertions(+), 21 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 5fb1764..6de1643 100644 >--- a/C4/Members.pm >+++ b/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 >@@ -740,12 +739,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'} ); >@@ -1830,8 +1829,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(<<EOF); >@@ -2229,8 +2229,7 @@ sub GetMessages { > my @results; > > while ( my $data = $sth->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; >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 4b10ff9..d2161cc 100644 >--- a/C4/Reserves.pm >+++ b/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. >diff --git a/C4/Search.pm b/C4/Search.pm >index e0f34bf..fa11758 100644 >--- a/C4/Search.pm >+++ b/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; >@@ -2105,7 +2105,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} }; >diff --git a/C4/Utils/DataTables.pm b/C4/Utils/DataTables.pm >index 26af6c5..2a0d998 100644 >--- a/C4/Utils/DataTables.pm >+++ b/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 ); > } >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index 4240fa0..5b1ffee 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/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} = ''; > } >diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm >index f4f09d7..b0dc3de 100644 >--- a/C4/VirtualShelves/Page.pm >+++ b/C4/VirtualShelves/Page.pm >@@ -35,10 +35,10 @@ use C4::Koha; > use C4::Auth qw/get_session/; > use C4::Members; > use C4::Output; >-use C4::Dates qw/format_date/; > use C4::Tags qw(get_tags); > use C4::Csv; > use C4::XSLT; >+use Koha::DateUtils; > > use constant VIRTUALSHELVES_COUNT => 20; > >@@ -276,7 +276,7 @@ sub shelfpage { > # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn > #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype} }->{'imageurl'}; > #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'}; >- $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} ); >+ $this_item->{'dateadded'} = eval { output_pref( { dt => dt_from_string( $this_item->{'dateadded'} ), dateonly => 1, dateformat => 'iso' } ); }; > $this_item->{'imageurl'} = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'}; > $this_item->{'coins'} = GetCOinSBiblio( $record ); > $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'})); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14985
:
43285
|
44439
|
44556
|
44621
|
44699
|
44700
|
44701
|
44739
|
44740
|
44741
|
44764
|
44765