]> 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)
committerVictor Grousset/tuxayo <victor@tuxayo.net>
Mon, 9 May 2022 21:46:33 +0000 (23:46 +0200)
commitc2996ef4cf2a61214f68bfd7b6746666373c16af
treefe0eb42e13358ae2b0166956aa60eecd32f91b8f
parent7dfd5a74bc8d76c5e07622d5680f846fc6de3eaa
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>
(cherry picked from commit fb1f752f47b70c56509747c5ce6e25bc56f34779)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Koha/StockRotationItem.pm