Bug 33029 - Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Summary: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall (khall)
QA Contact: Aleisha Amohia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-21 17:45 UTC by Kyle M Hall (khall)
Modified: 2024-07-25 11:15 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00
Circulation function:


Attachments
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin (2.67 KB, patch)
2023-02-21 17:49 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin (2.97 KB, patch)
2023-03-16 10:11 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin (2.99 KB, patch)
2023-03-16 12:51 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin (3.05 KB, patch)
2023-04-28 04:02 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin (2.98 KB, patch)
2023-07-05 16:58 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2023-02-21 17:45:27 UTC
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.
Comment 1 Kyle M Hall (khall) 2023-02-21 17:49:45 UTC
Created attachment 147084 [details] [review]
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
Comment 2 Martin Renvoize (ashimema) 2023-03-16 09:49:06 UTC
Hadn't spotted this before Marcel brought it to my attention with bug 33242.

I like the syntax we discuss introducing there for some available datetime methods.. but I also see the advantage of having the option of getting back a bare, timezone accounted, datetime which you can then just use normal dt methods upon.

I think I'd rename the method to just 'dt' however.. lazy typing ;P
Comment 3 Marcel de Rooy 2023-03-16 10:11:37 UTC
Created attachment 148258 [details] [review]
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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 4 Marcel de Rooy 2023-03-16 10:13:50 UTC
Tested: [% KohaDates.datetime_from_string(checkout.issuedate).add( days => 3) | $KohaDates %] too
Comment 5 Nick Clemens (kidclamp) 2023-03-16 12:51:21 UTC
Created attachment 148263 [details] [review]
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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 6 Aleisha Amohia 2023-04-28 04:02:58 UTC
Created attachment 150353 [details] [review]
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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 7 Tomás Cohen Arazi (tcohen) 2023-06-21 16:17:03 UTC
Love this, but can you please rebase?
Comment 8 Kyle M Hall (khall) 2023-07-05 16:58:51 UTC
Created attachment 153071 [details] [review]
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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 9 Tomás Cohen Arazi (tcohen) 2023-07-06 15:25:08 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 10 Martin Renvoize (ashimema) 2023-07-18 06:03:12 UTC
Enhancement no required for 23.05.x series as yet