Summary: | Make formatting date and datetime fields in notices a bit shorter/easier | ||
---|---|---|---|
Product: | Koha | Reporter: | Marcel de Rooy <m.de.rooy> |
Component: | Notices | Assignee: | Marcel de Rooy <m.de.rooy> |
Status: | Pushed to stable --- | QA Contact: | Martin Renvoize (ashimema) <martin.renvoize> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | david, jonathan.druart, martin.renvoize, paul.derscheid, wainuiwitikapark |
Version: | Main | Keywords: | additional_work_needed, release-notes-needed |
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: |
This enhancement adds an easier way to format dates in notices, and minimise potential errors - strftime. It can be used for both date and date time fields, and is locale friendly.
Examples:
- Date field: [% borrower.dateexpiry.strftime('%d-%m-%y') %]
- Date and time field: [% borrower.lastseen.strftime("%d-%m-%y %H:%M") %]
- Locale: [% borrower.dateexpiry.strftime("%d %B %Y", "nl_NL") %]
|
Version(s) released in: |
25.05.00,24.11.01
|
Circulation function: | |||
Attachments: |
Bug 38758: Add strftime as TT virtual method
Bug 38758: Add subtest to Letters.t Bug 38758: Add strftime as TT virtual method Bug 38758: Add subtest to Letters.t Bug 38758: Add strftime as TT virtual method Bug 38758: Add subtest to Letters.t |
Description
Marcel de Rooy
2024-12-20 10:13:48 UTC
Created attachment 175818 [details] [review] 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> Created attachment 175819 [details] [review] Bug 38758: Add subtest to Letters.t Test plan: Run t/db_dependent/Letters.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Created attachment 175820 [details] [review] 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> Created attachment 175821 [details] [review] Bug 38758: Add subtest to Letters.t Test plan: Run t/db_dependent/Letters.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 175822 [details] [review] 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> Created attachment 175823 [details] [review] Bug 38758: Add subtest to Letters.t Test plan: Run t/db_dependent/Letters.t 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> I'd be tempted to add the option to the filter call too I've confirmed it works as is.. though I'm not entirely sure I understand the innards of TT plugins to know why. It might be nice to be able to call it as so [% borrower.lastseen | $KohaDates with_format = '%d-%m' %] (In reply to Martin Renvoize (ashimema) from comment #7) > I'd be tempted to add the option to the filter call too > > I've confirmed it works as is.. though I'm not entirely sure I understand > the innards of TT plugins to know why. > > It might be nice to be able to call it as so > > [% borrower.lastseen | $KohaDates with_format = '%d-%m' %] Thanks for QA. I would prefer to change the filter sub of KohaDates on another report though. We have a bit of documentation for formatting dates in the TT notices in the wiki, can you please update? https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit#Example:_Format_dates Pushed for 25.05! Well done everyone, thank you! Nice work everyone! Pushed to 24.11.x for 24.11.01 I had a go at a relase note - I'm not sure if I've got this right, particularly showing the date time field example. That's elegant but definitely not consistent with anything else. IMO it should have been a method of KohaDates (matching the existing pattern: KohaDates.output_preference) Not backporting to 24.05 unless requested |