Bugzilla – Attachment 147084 Details for
Bug 33029
Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Bug-33029-Add-wrapper-method-for-dtfromstring-to-K.patch (text/plain), 2.67 KB, created by
Kyle M Hall (khall)
on 2023-02-21 17:49:45 UTC
(
hide
)
Description:
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-02-21 17:49:45 UTC
Size:
2.67 KB
patch
obsolete
>From a83cfdd3320cb208d3e20867d7b65039b1a4c93f Mon Sep 17 00:00:00 2001 >From: Kyle Hall <kyle@bywatersolutions.com> >Date: Tue, 21 Feb 2023 12:45:48 -0500 >Subject: [PATCH] Bug 33029: Add wrapper method for dt_from_string to KohaDates > template toolkit plugin > >It would be very useful to have direct access to dt_from_string in our templates. This would allow for us to handle custom date and time formatting. It would, for example, allow us to output the month name for a given date via Template Toolkit easily. > >Test Plan: >1) Apply this patch >2) In a notice add '[% Use KohaDates %][% KohaDates.datetime_from_string().ymd %]' to the top of a notice >3) Generate that notice for a patron >4) Note today's date in iso format is rendered at the top of the notice >--- > Koha/Template/Plugin/KohaDates.pm | 5 +++++ > t/db_dependent/Letters/TemplateToolkit.t | 26 ++++++++++++++++++++++++ > 2 files changed, 31 insertions(+) > >diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm >index 783833f7df..8fa5abb73d 100644 >--- a/Koha/Template/Plugin/KohaDates.pm >+++ b/Koha/Template/Plugin/KohaDates.pm >@@ -38,6 +38,11 @@ sub filter { > output_pref({ dt => $dt, dateonly => !$config->{with_hours}, dateformat => $config->{dateformat} }); > } > >+sub datetime_from_string { >+ my ( $self, @params ) = @_; >+ return dt_from_string( @params ); >+} >+ > sub output_preference { > my ( $self, @params ) = @_; > return output_pref( @params ); >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index edd91ac091..beb2442130 100755 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -1188,6 +1188,32 @@ EOF > is( $letter->{content}, $expected_content ); > }; > >+subtest 'KohaDates::dt_from_string' => sub { >+ plan tests => 1; >+ my $code = 'TEST_DATE'; >+ t::lib::Mocks::mock_preference('dateformat', 'metric'); # MM/DD/YYYY >+ my $biblio = $builder->build_object( >+ { >+ class => 'Koha::Biblios', >+ value => { >+ timestamp => '2018-12-13 20:21:22', >+ datecreated => '2018-12-13' >+ } >+ } >+ ); >+ my $template = q{[% USE KohaDates %][% KohaDates.datetime_from_string('2000-12-01').dmy %]}; >+ >+ reset_template({ template => $template, code => $code, module => 'test' }); >+ my $letter = GetPreparedLetter( >+ module => 'test', >+ letter_code => $code, >+ tables => { >+ biblio => $biblio->biblionumber, >+ } >+ ); >+ is( $letter->{content}, '01-12-2000' ); >+}; >+ > subtest 'Execute TT process in a DB transaction' => sub { > plan tests => 2; > my $code = 'TEST_TXN'; >-- >2.30.2
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 33029
:
147084
|
148258
|
148263
|
150353
|
153071