Koha/acqui
Jonathan Druart d0040dff9f
Bug 23079: Handle invalid timezones when adding/subtracting durations
On Nov 3rd 2019, Brazil will skip from 00:00 to 1:00 (http://www.currenttimeonline.com/dst/dst.do?tz=America/Sao_Paulo), DateTime consider it as an invalid date.
It is a problem when we are playing with dates without the time part (always 00:00).
When we instantiate a DateTime (from dt_from_string) we are already handling this issue, and use the floating timezone (since bug 12669).

The problem remains when we generate a DateTime then add or subtract a duration, which will result in an invalid date:

DateTime->new(year => 2019, month => 12, day => 3, time_zone => 'America/Sao_Paulo')->subtract(days => 30);

=> Nov 3rd 2019, kaboom.

We should replace all the problematic occurrences of dt_from_string->subtract (or ->add)
with dt_from_string(undef, undef, 'floating'), to use the floating timezone and avoid the error.

Actually there are not many of them, I have found only 3 that could
produce real problems.

The other occurrences are:
- in tests => Not a big deal (for now)
- called on a datetime, so it will explode if called at midnight
00:00:00 (and nobody should work at that time).

Test plan:
0/ Define the timezone to 'America/Sao_Paulo' (in your koha-conf.xml file), restart_all
1/ Set a patron's expiry date to Dec 3rd 2019, and
NotifyBorrowerDeparture to 30 (default value)
2/ See the checkouts page for this user
=> Without this patch you get "Invalid local time for date in time zone:
America/Sao_Paulo"
=> With this patch apply the page displays correctly

QA will review the 2 other occurrences.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-09-06 13:17:47 +01:00
..
acqui-home.pl Bug 19792: Performance boost for GetBudgetHierarchy 2018-05-11 10:52:46 -03:00
add_user_search.pl Bug 15758: Koha::Libraries - Remove GetBranches 2016-09-08 14:36:03 +00:00
addorder.pl Bug 21587: don't drop patrons to notify in order creation 2018-10-26 16:43:15 +00:00
addorderiso2709.pl Bug 23338: Allow specifying order level replacement price when adding to basket from file 2019-08-19 08:26:39 +01:00
ajax-getauthvaluedropbox.pl Bug 22391: Remove group by clause in ajax-getauthvaluedropbox.pl 2019-02-21 16:48:28 +00:00
basket.pl Bug 18736: Use rounding syspref to determine correct prices in calculations 2019-03-21 16:27:09 +00:00
basketgroup.pl Bug 18736: Use rounding syspref to determine correct prices in calculations 2019-03-21 16:27:09 +00:00
basketheader.pl Bug 15774: (follow-up) Address QA issues 2019-03-07 20:37:05 +00:00
booksellers.pl Bug 18789: Send Koha::Patron object to the templates 2018-02-16 13:03:58 -03:00
cancelorder.pl Bug 13208: [FOLLOW-UP] Creating and implementing new Koha::Acquisition::Basket[s] modules 2017-10-09 14:00:58 -03:00
check_budget_total.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
check_uniqueness.pl Bug 16154: CGI->multi_param - Declare a list 2016-04-26 23:16:42 +00:00
duplicate_orders.pl Bug 23079: Handle invalid timezones when adding/subtracting durations 2019-09-06 13:17:47 +01:00
edi_ean.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
edifactmsgs.pl Bug 20861: Correct EDI permissions on EDI messsages 2018-06-04 13:40:36 -04:00
edimsg.pl Bug 20861: Correct EDI permissions on EDI messsages 2018-06-04 13:40:36 -04:00
finishreceive.pl Bug 22721: Remove frameworkcode parameter in GetMarcFromKohaField calls 2019-07-15 11:28:08 +01:00
histsearch.pl Bug 23079: Handle invalid timezones when adding/subtracting durations 2019-09-06 13:17:47 +01:00
invoice-files.pl Bug 16154: CGI->multi_param - Force scalar context 2016-04-26 23:16:43 +00:00
invoice.pl Bug 18736: Use rounding syspref to determine correct prices in calculations 2019-03-21 16:27:09 +00:00
invoices.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
lateorders-export.pl Bug 16154: CGI->multi_param - Declare a list 2016-04-26 23:16:42 +00:00
lateorders.pl Bug 14535: Update the supplier filter too 2017-03-31 12:38:44 +00:00
modordernotes.pl Bug 13726: Make Koha::Acq::Bookseller using Koha::Object 2016-12-30 11:54:32 +00:00
neworderbiblio.pl Bug 23319: Implement blocking errors for neworderbiblio and basket.pl 2019-08-13 11:27:03 +01:00
neworderempty.pl Bug 23294: Show actual price when ordering 2019-08-20 15:01:13 +01:00
newordersubscription.pl Bug 13726: Make Koha::Acq::Bookseller using Koha::Object 2016-12-30 11:54:32 +00:00
newordersuggestion.pl Bug 4833: (QA follow-up) Add budgetname to SearchSuggestion 2019-05-15 16:46:47 +00:00
ordered.pl Bug 23397: (follow-up) Split and display itemtypes 2019-09-06 13:17:46 +01:00
orderreceive.pl Bug 22225: Correctly use invoiceincgst over listincgst 2019-05-15 12:10:52 +00:00
parcel.pl Bug 18736: Use rounding syspref to determine correct prices in calculations 2019-03-21 16:27:09 +00:00
parcels.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
showorder.pl Bug 12395: (QA follow-up) Change wording for consistency and fix use CGI; 2018-07-06 14:01:50 +00:00
spent.pl Bug 23397: (follow-up) Split and display itemtypes 2019-09-06 13:17:46 +01:00
supplier.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
transferorder.pl Bug 19130: (followup) Controller scripts should preserve behaviour 2017-08-25 11:53:44 -03:00
uncertainprice.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
updatesupplier.pl Bug 19993: use Modern::Perl in Acquisition perl scripts 2018-02-05 09:45:47 -03:00
z3950_search.pl Bug 19916: Add keyword and standard ID fields to acq external search 2018-03-28 16:03:37 -03:00