From 68784dfdf2e23f51217b6be76e8a14f17910bf1f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 24 Jan 2013 11:50:08 +0100 Subject: [PATCH 1/3] Bug 9479: The member notices page doesn't display dates in the syspref format In order to let the KohaDates plugin display a datetime, this patch modify this plugin. Now it uses Koha::DateUtils instead of C4::Dates. Test plan: - check that the date format on the member notices page (members/notices.pl) is displayed according your syspref dateformat. - check that existing dates are always in the good format (without the hours) e.g. acqui/histsearch.pl, acqui/basket.pl, etc. - Modify your syspref and recheck the previous pages Signed-off-by: Owen Leonard This is a nice addition, and works according to the test plan. A nice follow-up would be to create a system pref for formatting times (12/24hr). Signed-off-by: Katrin Fischer Fixed a tab in notices.tt to make QA script happy. Signed-off-by: Jared Camins-Esakov --- Koha/Template/Plugin/KohaDates.pm | 23 +++++++++++-------- .../prog/en/modules/members/notices.tt | 3 ++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm index 00656fa590..884c3e5de1 100644 --- a/Koha/Template/Plugin/KohaDates.pm +++ b/Koha/Template/Plugin/KohaDates.pm @@ -17,21 +17,26 @@ package Koha::Template::Plugin::KohaDates; # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -use strict; -use warnings; +use Modern::Perl; use Template::Plugin::Filter; use base qw( Template::Plugin::Filter ); -use warnings; -use strict; -use C4::Dates; +use Koha::DateUtils; +our $DYNAMIC = 1; + +sub init { + my $self = shift; + $self->{ _DYNAMIC } = 1; + return $self; +} sub filter { - my ($self,$text) = @_; - return "" if not $text; - my $date = C4::Dates->new( $text, 'iso' ); - return $date->output("syspref"); + my ( $self, $text, $args, $config ) = @_; + return "" unless $text; + $config->{with_hours} //= 0; + my $dt = dt_from_string( $text, 'iso' ); + return output_pref( $dt, undef, !$config->{with_hours} ); } 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt index 59848c25fd..1d7ec31914 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Sent notices for [% INCLUDE 'patron-title.inc' %] [% INCLUDE 'doc-head-close.inc' %] @@ -72,7 +73,7 @@ [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted [% ELSE %][% QUEUED_MESSAGE.status %][% END %] - [% QUEUED_MESSAGE.time_queued %] + [% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %] [% END %] From f6f18eba0eb6703df511eecbf1f546abdc50bdf6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 22 Mar 2013 09:52:18 +0100 Subject: [PATCH 2/3] Bug 9479: FIX conflict with Bug 9014 3rd parameters of output_pref is already used Signed-off-by: Katrin Fischer All tests and QA script pass. Checked sorting and display on notices page with various settings for dateformat and TimeFormat system preferences. Also checked other pages for correct display: - List of checkouts in patron account - Order search result list - Basket list in vendor search - Staff detail page Signed-off-by: Jared Camins-Esakov --- Koha/Template/Plugin/KohaDates.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm index 884c3e5de1..7c5ee68e38 100644 --- a/Koha/Template/Plugin/KohaDates.pm +++ b/Koha/Template/Plugin/KohaDates.pm @@ -36,7 +36,7 @@ sub filter { return "" unless $text; $config->{with_hours} //= 0; my $dt = dt_from_string( $text, 'iso' ); - return output_pref( $dt, undef, !$config->{with_hours} ); + return output_pref( $dt, undef, undef, !$config->{with_hours} ); } 1; From c49476641a2fb105ecd28fdb596052ca421ab1e1 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Sat, 30 Mar 2013 23:35:55 -0400 Subject: [PATCH 3/3] Bug 9479 follow-up: only set KohaDates as dynamic once --- Koha/Template/Plugin/KohaDates.pm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm index 7c5ee68e38..882d51e04e 100644 --- a/Koha/Template/Plugin/KohaDates.pm +++ b/Koha/Template/Plugin/KohaDates.pm @@ -25,12 +25,6 @@ use base qw( Template::Plugin::Filter ); use Koha::DateUtils; our $DYNAMIC = 1; -sub init { - my $self = shift; - $self->{ _DYNAMIC } = 1; - return $self; -} - sub filter { my ( $self, $text, $args, $config ) = @_; return "" unless $text;