Bugzilla – Attachment 94920 Details for
Bug 21824
Add ability to format dates in various formats in templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21824: Add ability to format dates in various formats in templates
Bug-21824-Add-ability-to-format-dates-in-various-f.patch (text/plain), 2.37 KB, created by
Martin Renvoize (ashimema)
on 2019-10-31 16:40:53 UTC
(
hide
)
Description:
Bug 21824: Add ability to format dates in various formats in templates
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-10-31 16:40:53 UTC
Size:
2.37 KB
patch
obsolete
>From bd9267abd0759a642e6e48d25e943ef3653a9bd1 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 13 Nov 2018 11:09:05 -0500 >Subject: [PATCH] Bug 21824: Add ability to format dates in various formats in > templates > >This patch adds the ability to set a date format for the Template Toolkit filter KohaDates > >Test plan: >1) Apply this patch >2) In a template, use the filter param "dateformat => 'iso'" >3) Note the output is in ISO format > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Template/Plugin/KohaDates.pm | 4 ++-- > t/db_dependent/Template/Plugin/KohaDates.t | 7 +++++-- > 2 files changed, 7 insertions(+), 4 deletions(-) > >diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm >index 712c89f938..13ebec8926 100644 >--- a/Koha/Template/Plugin/KohaDates.pm >+++ b/Koha/Template/Plugin/KohaDates.pm >@@ -33,8 +33,8 @@ sub filter { > my $dt = dt_from_string( $text, 'iso' ); > > return $config->{as_due_date} ? >- output_pref({ dt => $dt, as_due_date => 1 }) : >- output_pref({ dt => $dt, dateonly => !$config->{with_hours} }); >+ output_pref({ dt => $dt, as_due_date => 1, dateformat => $config->{dateformat} }) : >+ output_pref({ dt => $dt, dateonly => !$config->{with_hours}, dateformat => $config->{dateformat} }); > } > > 1; >diff --git a/t/db_dependent/Template/Plugin/KohaDates.t b/t/db_dependent/Template/Plugin/KohaDates.t >index fe188362a3..36857a65dd 100644 >--- a/t/db_dependent/Template/Plugin/KohaDates.t >+++ b/t/db_dependent/Template/Plugin/KohaDates.t >@@ -3,7 +3,7 @@ > use Modern::Perl; > use C4::Context; > use Koha::DateUtils; >-use Test::More tests => 7; >+use Test::More tests => 8; > use Test::MockModule; > use t::lib::Mocks; > >@@ -46,7 +46,10 @@ $module_context->mock( > ); > > $filtered_date = $filter->filter('1979-04-01'); >-is( $filtered_date, '01/04/1979', 'us: dt_from_string should return the valid date if a DST is given' ); >+is( $filtered_date, '01/04/1979', 'us: dt_from_string should return the valid date if a dst is given' ); >+ >+$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' ); > > $module_context->mock( > 'tz', >-- >2.20.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 21824
:
82308
|
82316
|
82879
|
82880
|
83188
|
91354
|
91355
|
91356
|
91357
|
91358
|
91363
|
91364
| 94920 |
94921
|
94922