Bugzilla – Attachment 175822 Details for
Bug 38758
Make formatting date and datetime fields in notices a bit shorter/easier
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38758: Add strftime as TT virtual method
Bug-38758-Add-strftime-as-TT-virtual-method.patch (text/plain), 1.96 KB, created by
Martin Renvoize (ashimema)
on 2024-12-20 12:02:52 UTC
(
hide
)
Description:
Bug 38758: Add strftime as TT virtual method
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-12-20 12:02:52 UTC
Size:
1.96 KB
patch
obsolete
>From e717fd0d7b9bd4c624e863099cedfe067f2034c8 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 18 Dec 2024 15:56:50 +0000 >Subject: [PATCH] Bug 38758: Add strftime as TT virtual method > >Test plan: >Try things like [% borrower.dateexpiry.strftime('%d-%m-%y') %] in >a notice. Also test datetime fields like borrower.lastseen. >Add locale support with strftime('%d %B', 'nl_NL') etc. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Letters.pm | 5 +++++ > Koha/Template/Plugin/KohaDates.pm | 10 ++++++++++ > 2 files changed, 15 insertions(+) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index ce8ffda7e17..bfcaacbe902 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -40,6 +40,7 @@ use Koha::Patrons; > use Koha::SMS::Providers; > use Koha::SMTP::Servers; > use Koha::Subscriptions; >+use Koha::Template::Plugin::KohaDates; > > use constant SERIALIZED_EMAIL_CONTENT_TYPE => 'message/rfc822'; > >@@ -638,6 +639,10 @@ sub GetPreparedLetter { > $lang = shift @languages; > } > >+ $Template::Stash::SCALAR_OPS->{strftime} = sub { >+ return Koha::Template::Plugin::KohaDates->strftime(@_); >+ }; >+ > $letter->{content} = _process_tt( > { > content => $letter->{content}, >diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm >index d8c31beec51..e3f39c2eb2d 100644 >--- a/Koha/Template/Plugin/KohaDates.pm >+++ b/Koha/Template/Plugin/KohaDates.pm >@@ -67,4 +67,14 @@ sub tz { > return C4::Context->tz->name; > } > >+sub strftime { # used as TT virtual method for scalars, wrapper around DateTime counterpart >+ my ( $self, $value, $format, $locale ) = @_; >+ my $dt = eval { dt_from_string($value) }; >+ if ($dt) { >+ $dt->set_locale($locale) if $locale; >+ return $dt->strftime($format); >+ } >+ return $value; >+} >+ > 1; >-- >2.47.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 38758
:
175818
|
175819
|
175820
|
175821
| 175822 |
175823