Bug 33029

Summary: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: TemplatesAssignee: Kyle M Hall (khall) <kyle>
Status: Needs documenting --- QA Contact: Aleisha Amohia <aleisha>
Severity: enhancement    
Priority: P5 - low CC: aleisha, lucas, m.de.rooy, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242
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
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin
Bug 33029: Add wrapper method for dt_from_string to KohaDates template toolkit plugin

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