From 867da55cd97a0973b20ce0df26a6f4edfa7645eb Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 21 Sep 2018 15:23:11 -0400 Subject: [PATCH] LP#1789442: fix editing due date of hourly loans in web staff This patch fixes a bug where editing the due date of an hourly loan would result in the time portion always getting set to 00:00. To test ------- [1] Set up some daily and hourly loans in your database. [2] Apply the patch. [3] From the items out page, edit the due date for one or more hourly loans. Verify that the resulting due date is set correctly. [4] From the items out page, edit the due date for some daily loans and verify correctness. In particular, verify that the resulting due date is /not/ the following day if testing in time zones in the Americas. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm | 5 +++++ Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index f1fcf1f3db..bad3be3819 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -685,6 +685,11 @@ sub set_circ_due_date { if (!(interval_to_seconds($circ->duration) % 86400)) { # duration is divisible by days my $original_date = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($circ->due_date)); my $new_date = DateTime::Format::ISO8601->new->parse_datetime($date); + + # since the new date may be coming in as UTC, convert it + # to the same time zone as the original due date so that + # ->ymd is more likely to yield the expected results + $new_date->set_time_zone($original_date->time_zone()); $date = clean_ISO8601( $new_date->ymd . 'T' . $original_date->strftime('%T%z') ); } diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js b/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js index 105c9f5a42..e75d9a275e 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js @@ -320,13 +320,7 @@ function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc , // Fire off the due-date updater for each circ. // When all is done, close the dialog $scope.ok = function(args) { - // toISOString gives us Zulu time, so - // adjust for that before truncating to date - var adjust_date = new Date( $scope.args.due_date ); - adjust_date.setMinutes( - $scope.args.due_date.getMinutes() - adjust_date.getTimezoneOffset() - ); - var due = adjust_date.toISOString().replace(/T.*/,''); + var due = $scope.args.due_date.toISOString(); console.debug("applying due date of " + due); var promises = []; -- 2.43.2