From 61bb34bfae330bad4ebfad9bae2653b85f43af71 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 13 Nov 2018 12:36:17 -0500 Subject: [PATCH] Bug 21824: Add KohaDates method 'output_preference' to make it easy to store formatted dates in TT variable Signed-off-by: Owen Leonard --- Koha/Template/Plugin/KohaDates.pm | 5 +++++ t/db_dependent/Template/Plugin/KohaDates.t | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm index 13ebec8..e87d478 100644 --- a/Koha/Template/Plugin/KohaDates.pm +++ b/Koha/Template/Plugin/KohaDates.pm @@ -37,4 +37,9 @@ sub filter { output_pref({ dt => $dt, dateonly => !$config->{with_hours}, dateformat => $config->{dateformat} }); } +sub output_preference { + my ( $self, @params ) = @_; + return output_pref( @params ); +} + 1; diff --git a/t/db_dependent/Template/Plugin/KohaDates.t b/t/db_dependent/Template/Plugin/KohaDates.t index 36857a6..53449d8 100644 --- a/t/db_dependent/Template/Plugin/KohaDates.t +++ b/t/db_dependent/Template/Plugin/KohaDates.t @@ -1,10 +1,12 @@ #!/usr/bin/perl use Modern::Perl; + use C4::Context; use Koha::DateUtils; -use Test::More tests => 8; + use Test::MockModule; +use Test::More tests => 9; use t::lib::Mocks; BEGIN { @@ -51,6 +53,8 @@ is( $filtered_date, '01/04/1979', 'us: dt_from_string should return the valid da $filtered_date = $filter->filter('1979-04-01', undef, { dateformat => 'iso' } ); is( $filtered_date, '1979-04-01', 'date should be returned in ISO if dateformat is passed with a value of iso' ); +is( Koha::DateUtils::output_pref( dt_from_string ), $filter->output_preference( dt_from_string ), 'Filter output_preference method output matches output_pref' ); + $module_context->mock( 'tz', sub { -- 2.1.4