https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37707

--- Comment #41 from Paul Derscheid <[email protected]> ---
Created attachment 191746
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=191746&action=edit
Bug 37707: (follow-up) Fix timezone handling for cross-timezone bookings

This patch fixes timezone issues that caused booking dates to shift
when the browser and server are in different timezones.

The code used implicit timezone conversions via
.toISOString() and .toDate(), which work when browser and server
timezones match but fail otherwise. QA testing showed:
- PST browser: end date shifts +1 day
- NZDT browser: end date shifts +2 days

Make timezone handling explicit by establishing that
booking dates are interpreted in the library's timezone.

- Form submission: Extract date value (YYYY-MM-DD) and send as
  explicit UTC day boundaries using dayjs.utc().startOf/endOf('day')
- Timeline display: Convert UTC to library timezone using $timezone()
  and new $toDisplayDate() helper for consistent rendering
- Added $timezone() to expose server timezone to JavaScript
- Added $toDisplayDate() to create display-ready Date objects that
  render correctly regardless of browser timezone

To test:
1. Apply patch and run: yarn build
2. Configure a bookable item with 2-day lead and 3-day trail periods

Timezone handling (PST):
3. Set browser timezone to PST (America/Los_Angeles), for example with
Chrome Devtools -> Ctrl/Cmd + Shift + P -> sensors -> Location
4. Create a single-day booking for Jan 20
5. Verify the booking table shows start: Jan 20, end: Jan 20
   (not Jan 21)
6. Verify the timeline shows the booking on Jan 20 only
7. Create a 3-day booking (Jan 22-24)
8. Verify the table shows start: Jan 22, end: Jan 24
9. Verify the timeline spans exactly 3 days

Timezone handling (NZDT):
10. Set browser timezone to NZDT (Pacific/Auckland)
11. Repeat steps 4-9
12. Verify dates do not shift by +2 days as previously reported

Test lead/trail conflict detection:
13. With existing booking on Jan 20 (trail period: Jan 21-23)
14. Attempt to create new booking starting Jan 24 (lead: Jan 22-23)
15. Verify conflict is detected (lead overlaps with trail)
16. Verify booking starting Jan 26 (lead: Jan 24-25) is allowed

Test multi-item filtering:
17. On a bib with multiple bookable items
18. Create booking on item A for Jan 20
19. Open booking modal, select item B
20. Verify calendar does NOT show conflicts from item A's booking

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to