Bugzilla – Attachment 48309 Details for
Bug 15882
refactor C4::Log::GetLogs to accept DateTime
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15882 - refactor C4::Log::GetLogs to accept DateTime
Bug-15882---refactor-C4LogGetLogs-to-accept-DateTi.patch (text/plain), 2.06 KB, created by
Olli-Antti Kivilahti
on 2016-02-23 09:49:58 UTC
(
hide
)
Description:
Bug 15882 - refactor C4::Log::GetLogs to accept DateTime
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2016-02-23 09:49:58 UTC
Size:
2.06 KB
patch
obsolete
>From 8a809b1dab33d89a3352c6d4e04221909ef4e6f3 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 23 Feb 2016 11:49:28 +0200 >Subject: [PATCH] Bug 15882 - refactor C4::Log::GetLogs to accept DateTime > >C4::Log::GetLogs accepts dates in some strange format. >It should accept DateTime as that is a de-facto standard. > >Refactored to accept DateTimes so it can be used internally more easily. >Also killed a undefined warning bug. >--- > C4/Log.pm | 20 +++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > >diff --git a/C4/Log.pm b/C4/Log.pm >index 671fcdb..6727223 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -23,9 +23,11 @@ package C4::Log; > > use strict; > use warnings; >+use Scalar::Util qw(blessed); > > use C4::Context; > use C4::Dates qw(format_date); >+use DateTime; > > use vars qw($VERSION @ISA @EXPORT); > >@@ -202,8 +204,20 @@ 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; >+ if (blessed($datefrom) && $datefrom->isa('DateTime')) { >+ $iso_datefrom = $datefrom->ymd(); >+ } >+ else { >+ $iso_datefrom = C4::Dates->new($datefrom,C4::Context->preference("dateformat"))->output('iso'); >+ } >+ my $iso_dateto; >+ if (blessed($dateto) && $dateto->isa('DateTime')) { >+ $iso_dateto = $dateto->ymd(); >+ } >+ else { >+ $iso_dateto = C4::Dates->new($dateto,C4::Context->preference("dateformat"))->output('iso'); >+ } > > my $dbh = C4::Context->dbh; > my $query = " >@@ -215,7 +229,7 @@ sub GetLogs { > my @parameters; > $query .= " AND DATE_FORMAT(timestamp, '%Y-%m-%d') >= \"".$iso_datefrom."\" " if $iso_datefrom; #fix me - mysql specific > $query .= " AND DATE_FORMAT(timestamp, '%Y-%m-%d') <= \"".$iso_dateto."\" " if $iso_dateto; >- if($user ne "") { >+ if($user) { > $query .= " AND user = ? "; > push(@parameters,$user); > } >-- >1.9.1
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 15882
: 48309