Description
Kyle M Hall (khall)
2023-02-21 17:45:27 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 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 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> Tested: [% KohaDates.datetime_from_string(checkout.issuedate).add( days => 3) | $KohaDates %] too 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> 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> Love this, but can you please rebase? 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> Pushed to master for 23.11. Nice work everyone, thanks! Enhancement no required for 23.05.x series as yet |