Bugzilla – Attachment 25973 Details for
Bug 11148
Two routines are useless in Koha::DateUtils
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11148: Two routines are useless in Koha::DateUtils
Bug-11148-Two-routines-are-useless-in-KohaDateUtil.patch (text/plain), 5.84 KB, created by
Jonathan Druart
on 2014-03-10 08:51:52 UTC
(
hide
)
Description:
Bug 11148: Two routines are useless in Koha::DateUtils
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-03-10 08:51:52 UTC
Size:
5.84 KB
patch
obsolete
>From d85854f278c846405fd54c1805329c8db409e78b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 28 Oct 2013 15:10:26 +0100 >Subject: [PATCH] Bug 11148: Two routines are useless in Koha::DateUtils > >There are 2 useless routines in the Koha::DateUtils >module:output_pref_due and format_sqlduedatetime. We can call >output_pref and format_datetime with dateonly = 0. > >format_sqlduedatetime is only used in one place: opac-reserve.pl > >Test plan: >1/ Verify on the opac-reserve.pl page that the date is correctly >displayed for for onloan items (you should use the "specific copy" >feature). >2/ Launch prove t/DateUtils.t UT file and verify all UT pass. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Due date on opac-reserve shown correctly. Unit tests pass. >Did a grep on both function names. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >No references to subs found. Passes koha-qa.pl, t and xt >--- > Koha/DateUtils.pm | 55 +------------------------------------------------- > opac/opac-reserve.pl | 2 +- > t/DateUtils.t | 23 +-------------------- > 3 files changed, 3 insertions(+), 77 deletions(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index ea57778..85c90d6 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -27,7 +27,7 @@ use base 'Exporter'; > use version; our $VERSION = qv('1.0.0'); > > our @EXPORT = ( >- qw( dt_from_string output_pref format_sqldatetime output_pref_due format_sqlduedatetime) >+ qw( dt_from_string output_pref format_sqldatetime ) > ); > > =head1 DateUtils >@@ -154,31 +154,6 @@ sub output_pref { > > } > >-=head2 output_pref_due >- >-$date_string = output_pref_due({ dt => $dt [, dateformat => $date_format, timeformat => $time_format, dateonly => 0|1 ] }); >-$date_string = output_pref_due($dt); >- >-Returns a string containing the time & date formatted as per the C4::Context setting >- >-This routine can either be passed a DateTime object or or a hashref. If it is >-passed a hashref, the expected keys are a mandatory 'dt' for the DateTime, >-an optional 'dateformat' to override the dateformat system preference, an >-optional 'timeformat' to override the TimeFormat system preference value, >-and an optional 'dateonly' to specify that only the formatted date string >-should be returned without the time. >- >-This is effectively a wrapper around output_pref for due dates; >-the time portion is stripped if it is '23:59' >- >-=cut >- >-sub output_pref_due { >- my $disp_str = output_pref(@_); >- $disp_str =~ s/ 23:59//; >- return $disp_str; >-} >- > =head2 format_sqldatetime > > $string = format_sqldatetime( $string_as_returned_from_db ); >@@ -208,32 +183,4 @@ sub format_sqldatetime { > return q{}; > } > >-=head2 format_sqlduedatetime >- >-$string = format_sqldatetime( $string_as_returned_from_db ); >- >-a convenience routine for calling dt_from_string and formatting the result >-with output_pref_due as it is a frequent activity in scripts >- >-=cut >- >-sub format_sqlduedatetime { >- my $str = shift; >- my $force_pref = shift; # if testing we want to override Context >- my $force_time = shift; >- my $dateonly = shift; >- >- if ( defined $str && $str =~ m/^\d{4}-\d{2}-\d{2}/ ) { >- my $dt = dt_from_string( $str, 'sql' ); >- $dt->truncate( to => 'minute' ); >- return output_pref_due({ >- dt => $dt, >- dateformat => $force_pref, >- timeformat => $force_time, >- dateonly => $dateonly >- }); >- } >- return q{}; >-} >- > 1; >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 6d5d46f..9649231 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -426,7 +426,7 @@ foreach my $biblioNum (@biblionumbers) { > # change the background color. > my $issues= GetItemIssue($itemNum); > if ( $issues->{'date_due'} ) { >- $itemLoopIter->{dateDue} = format_sqlduedatetime($issues->{date_due}); >+ $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issues->{date_due}, 'sql'), dateonly => 1 }); > $itemLoopIter->{backgroundcolor} = 'onloan'; > } > >diff --git a/t/DateUtils.t b/t/DateUtils.t >index 0f8f2b9..00dc402 100755 >--- a/t/DateUtils.t >+++ b/t/DateUtils.t >@@ -5,7 +5,7 @@ use DateTime; > use DateTime::TimeZone; > > use C4::Context; >-use Test::More tests => 31; >+use Test::More tests => 27; > use Test::MockModule; > > BEGIN { use_ok('Koha::DateUtils'); } >@@ -67,16 +67,6 @@ cmp_ok $date_string, 'eq', '16/06/2011 12:00', 'metric output'; > $date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => 'notime', dateonly => 1 }); > cmp_ok $date_string, 'eq', '16/06/2011', 'metric output (date only)'; > >-$date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => '24hr' }); >-cmp_ok $date_string, 'eq', '16/06/2011 12:00', >- 'output_pref_due preserves non midnight HH:SS'; >- >-$dt->set_hour(23); >-$dt->set_minute(59); >-$date_string = output_pref_due({ dt => $dt, dateformat => 'metric', timeformat => '24hr' }); >-cmp_ok $date_string, 'eq', '16/06/2011', >- 'output_pref_due truncates HH:SS at midnight'; >- > my $dear_dirty_dublin = DateTime::TimeZone->new( name => 'Europe/Dublin' ); > my $new_dt = dt_from_string( '16/06/2011', 'metric', $dear_dirty_dublin ); > isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' ); >@@ -118,14 +108,3 @@ cmp_ok( $formatted, 'eq', '16/06/2011 12:00', 'format_sqldatetime conversion' ); > $formatted = format_sqldatetime( undef, 'metric' ); > cmp_ok( $formatted, 'eq', q{}, > 'format_sqldatetime formats undef as empty string' ); >- >-$formatted = format_sqlduedatetime( '2011-06-16 12:00:07', 'metric', '24hr' ); >-cmp_ok( >- $formatted, 'eq', >- '16/06/2011 12:00', >- 'format_sqlduedatetime conversion for hourly loans' >-); >- >-$formatted = format_sqlduedatetime( '2011-06-16 23:59:07', 'metric', '24hr' ); >-cmp_ok( $formatted, 'eq', '16/06/2011', >- 'format_sqlduedatetime conversion for daily loans' ); >-- >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 11148
:
22470
|
22759
|
23092
|
23239
|
23253
|
24219
|
25973
|
25974
|
25975
|
26212
|
26213
|
26214
|
26278
|
26279
|
26280