]> git.koha-community.org Git - koha.git/commit
Bug 30518: Correct DateTime maths for needs_advancing
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 13 Apr 2022 07:24:22 +0000 (08:24 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Wed, 20 Apr 2022 07:25:50 +0000 (21:25 -1000)
commitc48ec95cbfc717a460a723e1a0f8274a2c4aace9
treeb4eadcdc187040c9c3a9ab4dc8d67dffc3d7c67c
parentae557cfa91655b6bb8316b1a4632876f08a54640
Bug 30518: Correct DateTime maths for needs_advancing

The needs_advancing method prior to this patch used basic DateTime
arithmatic, adding a DateTime::Duration in Days to the Arrival date of
the item and then comparing that to today. This, however, can cause bugs
when the arrival + duration date coincides with a DST boundary and as
such may result in an invalid local date.  See
https://metacpan.org/pod/DateTime#Making-Things-Simple for further
details.

This patch updates the code to use the DST safe delta_days method to
count the days between arrival and now instead and then compares this
integer to the defined duration of the stage.

To test:
1. Re-run the unit tests, they should now pass.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/StockRotationItem.pm