[Bug 33242] New: Allow passing things like add_days => 3 to KohaDates filter
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Bug ID: 33242 Summary: Allow passing things like add_days => 3 to KohaDates filter Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: m.de.rooy@rijksmuseum.nl QA Contact: testopia@bugs.koha-community.org I have a use case where I want to add some days to an issue date in a notice. We either need a dt_from_string wrapper in our template plugin like bug 33029 proposes or allow passing options like add_days => X to KohaDates which looks nicer but is less generic. Perhaps we can do both btw ! These approaches each have their benefits and do not exclude each other. Compare the 33029 approach [% KohaDates.datetime_from_string(checkout.issuedate).add( days => 3) | $KohaDates %] with the approch of this report [% checkout.issuedate | $KohaDates add_days => 3 %] The latter notation is definitely shorter and prettier in my use case and does only need a few lines more. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |m.de.rooy@rijksmuseum.nl |ity.org | Status|NEW |ASSIGNED -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=33029 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #1 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Ack, I'm torn now. I can see the utility of a dt method allowing us full access to dt functions from the template.. but I also love the idea of the 'pretty' syntax we could introduce with this approach.. `[% checkout.issuesdate | $KohaDates add => "3 days" %]`.. I'm overthinking. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #2 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 148256 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=148256&action=edit Bug 33242: Allow passing add_{duration} options to KohaDates For example, if I want to add a few days to the issuedate in a TT template, I could do this: [% checkout.issuedate | $KohaDates add_days => 3 %] This development allows you to pass add/subtract years, months, weeks, days, hours, minutes and seconds. Test plan: Pick a notice like CHECKOUT. Add a line like: [% checkout.date_due | $KohaDates with_hours => 1, add_minutes => 15 %] Do a checkout. Verify that the notice generated contains a time that shifted 15 minutes. Undo your change. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 148257 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=148257&action=edit Bug 33242: Add unit test Test plan: Run t/db_dependent/Letters/TemplateToolkit.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #4 from Kyle M Hall <kyle@bywatersolutions.com> --- (In reply to Martin Renvoize from comment #1)
Ack, I'm torn now.
I can see the utility of a dt method allowing us full access to dt functions from the template.. but I also love the idea of the 'pretty' syntax we could introduce with this approach.. `[% checkout.issuesdate | $KohaDates add => "3 days" %]`.. I'm overthinking.
I think both this bug and bug 33029 can live in harmony. This would be the "easy" mode to bug 33029's "advanced" mode. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148256|0 |1 is obsolete| | Attachment #148257|0 |1 is obsolete| | --- Comment #5 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 148261 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=148261&action=edit Bug 33242: Allow passing add_{duration} options to KohaDates For example, if I want to add a few days to the issuedate in a TT template, I could do this: [% checkout.issuedate | $KohaDates add_days => 3 %] This development allows you to pass add/subtract years, months, weeks, days, hours, minutes and seconds. Test plan: Pick a notice like CHECKOUT. Add a line like: [% checkout.date_due | $KohaDates with_hours => 1, add_minutes => 15 %] Do a checkout. Verify that the notice generated contains a time that shifted 15 minutes. Undo your change. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #6 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 148262 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=148262&action=edit Bug 33242: Add unit test Test plan: Run t/db_dependent/Letters/TemplateToolkit.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com Attachment #148261|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148262|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148257|1 |0 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148256|1 |0 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148256|0 |1 is obsolete| | --- Comment #7 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 148264 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=148264&action=edit Bug 33242: Allow passing add_{duration} options to KohaDates For example, if I want to add a few days to the issuedate in a TT template, I could do this: [% checkout.issuedate | $KohaDates add_days => 3 %] This development allows you to pass add/subtract years, months, weeks, days, hours, minutes and seconds. Test plan: Pick a notice like CHECKOUT. Add a line like: [% checkout.date_due | $KohaDates with_hours => 1, add_minutes => 15 %] Do a checkout. Verify that the notice generated contains a time that shifted 15 minutes. Undo your change. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148257|0 |1 is obsolete| | --- Comment #8 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 148265 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=148265&action=edit Bug 33242: Add unit test Test plan: Run t/db_dependent/Letters/TemplateToolkit.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #9 from Nick Clemens <nick@bywatersolutions.com> --- Tested with 33029 (accidentally applied merged patches first time) They both work well, I think having both provides nice flexibility, easy way to add to dates here, and full access to dt object from 33029 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com --- Comment #10 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- I was going to PQA until I saw bug 33029, which gives us more flexibility. Not sure we need both personally. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #11 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Jonathan Druart from comment #10)
I was going to PQA until I saw bug 33029, which gives us more flexibility. Not sure we need both personally.
Yes we looked at that. Kyle, Nick and I concluded that both go fine together. See description too, saying this: Compare the 33029 approach [% KohaDates.datetime_from_string(checkout.issuedate).add( days => 3) | $KohaDates %] with the approch of this report [% checkout.issuedate | $KohaDates add_days => 3 %] The latter notation is definitely shorter and prettier in my use case and does only need a few lines more. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #12 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- (In reply to Marcel de Rooy from comment #11)
(In reply to Jonathan Druart from comment #10)
I was going to PQA until I saw bug 33029, which gives us more flexibility. Not sure we need both personally.
Yes we looked at that. Kyle, Nick and I concluded that both go fine together. See description too, saying this:
Compare the 33029 approach [% KohaDates.datetime_from_string(checkout.issuedate).add( days => 3) | $KohaDates %] with the approch of this report [% checkout.issuedate | $KohaDates add_days => 3 %]
The latter notation is definitely shorter and prettier in my use case and does only need a few lines more.
Yes, more code to maintain, and the parsing here looks hacky to me, for less flexibility. Note that I didn't FQA but I am not the one who is going to PQA this ;) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #13 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Jonathan Druart from comment #12)
Yes, more code to maintain, and the parsing here looks hacky to me, for less flexibility.
What is hacky in this parsing ? if( $entry =~ /^(add|subtract)_(years|months|weeks|days|hours|minutes|seconds)$/ ) { -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #14 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- (In reply to Marcel de Rooy from comment #13)
(In reply to Jonathan Druart from comment #12)
Yes, more code to maintain, and the parsing here looks hacky to me, for less flexibility.
What is hacky in this parsing ? if( $entry =~ /^(add|subtract)_(years|months|weeks|days|hours|minutes|seconds)$/ ) {
Here you are providing an handy way to do date calculation, but without its flexibility. It's all what I am saying. For instance what about the end_of_month limit? You cannot change it. But really, if others find it useful, just let it go ;) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |kyle@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #148264|0 |1 is obsolete| | Attachment #148265|0 |1 is obsolete| | --- Comment #15 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 150390 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=150390&action=edit Bug 33242: Allow passing add_{duration} options to KohaDates For example, if I want to add a few days to the issuedate in a TT template, I could do this: [% checkout.issuedate | $KohaDates add_days => 3 %] This development allows you to pass add/subtract years, months, weeks, days, hours, minutes and seconds. Test plan: Pick a notice like CHECKOUT. Add a line like: [% checkout.date_due | $KohaDates with_hours => 1, add_minutes => 15 %] Do a checkout. Verify that the notice generated contains a time that shifted 15 minutes. Undo your change. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #150390|0 |1 is obsolete| | --- Comment #16 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 150391 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=150391&action=edit Bug 33242: Allow passing add_{duration} options to KohaDates For example, if I want to add a few days to the issuedate in a TT template, I could do this: [% checkout.issuedate | $KohaDates add_days => 3 %] This development allows you to pass add/subtract years, months, weeks, days, hours, minutes and seconds. Test plan: Pick a notice like CHECKOUT. Add a line like: [% checkout.date_due | $KohaDates with_hours => 1, add_minutes => 15 %] Do a checkout. Verify that the notice generated contains a time that shifted 15 minutes. Undo your change. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #17 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 150392 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=150392&action=edit Bug 33242: Add unit test Test plan: Run t/db_dependent/Letters/TemplateToolkit.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #18 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Kyle M Hall from comment #17)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Thx ! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to master Version(s)| |23.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 --- Comment #19 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Pushed to master for 23.11. Nice work everyone, thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|Architecture, internals, |Templates |and plumbing | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |release-notes-needed CC| |tomascohen@gmail.com Resolution|--- |FIXED Status|Pushed to master |RESOLVED --- Comment #20 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Enhancement won't be backported to stable release. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33242 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|release-notes-needed | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org