From 76b877dcb9e5e50d83f238261c143f8448611916 Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Thu, 4 Mar 2021 19:09:44 -0600 Subject: [PATCH] LP#1917396 - Staff Curbside Scheduling UTC Issues When a staff person tries to schedule curbside appointments after their UTC equivalent time moves to the next day, the timeslots for the next day are shown, and appointments get made for the next day. For example, when CST is the local timezone (UTC-6), after 6pm appointments for the current day are scheduled for the next day. Appointments for the next day get scheduled for the day after. This happens because toISOString is used to grab the current date, but toISOString always returns UTC time. The date widget will show the correct date, but the time slots will actually be for the next day. This is more noticeable if days have different schedules. Another clue is that the time slot selector will show all timeslots for the day, not just the ones that are upcoming. Testing Plan: 1. Enable curbside for test location, and set org unit hours to be at least through 8pm for open hours. 2. Wait until after 4PM (Pacific), 6pm CST, 7PM EST, or change your computer clock. 3. Try to schedule an appointment for the current day. 4. The appointment should get scheduled for the next day. 5. Apply the fix. 6. Try to schedule another appointment and see that the correct date gets selected. Signed-off-by: Josh Stompro Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- .../staff/circ/curbside/directives/schedule_pickup.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js b/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js index 6d8ae65e0a..cf5e4fe5d5 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js +++ b/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js @@ -269,7 +269,8 @@ function($scope , $q , egCurbsideCoreSvc , egCore , patronSvc , 'open-ils.curbside', 'open-ils.curbside.times_for_date.atomic', egCore.auth.token(), - hash.slot.substring(0, 10), + // Use date based on local time, not UTC + new Date(hash.slot_date - (hash.slot_date.getTimezoneOffset() * 60000)).toISOString().substring(0, 10), ).then(function(times) { mungeAvailableTimes(hash, times); }); @@ -295,7 +296,8 @@ function($scope , $q , egCurbsideCoreSvc , egCore , patronSvc , $scope.minDate = new Date(); $scope.refreshAvailableTimes = function(hash) { - var dateStr = (new Date(hash.slot_date)).toISOString().substring(0, 10); + // Use date based on local time, not UTC + var dateStr = (new Date(hash.slot_date - (hash.slot_date.getTimezoneOffset() * 60000))).toISOString().substring(0, 10); egCore.net.request ( 'open-ils.curbside', 'open-ils.curbside.times_for_date.atomic', @@ -321,7 +323,8 @@ function($scope , $q , egCurbsideCoreSvc , egCore , patronSvc , 'open-ils.curbside.' + op + '_appointment', egCore.auth.token(), $scope.user_id, - (new Date(appt.slot_date)).toISOString().substring(0, 10), + // Use date based on local time, not UTC + (new Date(appt.slot_date - (appt.slot_date.getTimezoneOffset() * 60000))).toISOString().substring(0, 10), appt.slot_time, egCore.auth.user().ws_ou(), appt.notes -- 2.43.2