]> 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)
committerAndrew Fuerste-Henry <andrew@bywatersolutions.com>
Tue, 3 May 2022 19:52:17 +0000 (19:52 +0000)
commitfb1f752f47b70c56509747c5ce6e25bc56f34779
tree5545442a842587d8f5b65aa19f10336f2c0bf2c7
parentb8c1391c4a7e23d6c1de25bd03b95612c8f99de8
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>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 3929335cdbea81c7c891a8a979d69861468502fd)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Koha/StockRotationItem.pm