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

--- Comment #31 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 191360
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=191360&action=edit
Bug 37707: Fix timezone handling in place_booking modal

This patch fixes timezone inconsistencies in the place_booking modal
that caused dates to shift when the server and browser are in different
timezones.

Issues Fixed:
1. Date index creation used .toISOString().split("T")[0] which converted
   to UTC, causing western timezone dates to appear on wrong calendar days
2. Date comparisons mixed flatpickr.parseDate() and dayjs() without
   normalizing to start-of-day
3. Booking overlap detection had inconsistent timezone handling

Changes:
- Replace .toISOString().split("T")[0] with dayjs().format('YYYY-MM-DD')
  to maintain browser timezone consistency
- Normalize all date comparisons to start-of-day using dayjs().startOf('day')
- Use dayjs() consistently for parsing RFC3339 datetime strings from API
- Add explicit .startOf('day') and .endOf('day') for API submission clarity

These changes ensure:
- Bookings display on correct calendar days regardless of browser timezone
- Multi-day bookings span the correct number of days
- Conflict detection works consistently across all timezones
- Item availability calculations are accurate
- Future hourly booking support is preserved (time components maintained)

Test plan:
1. Set browser to PST (UTC-8), server to UTC
2. Create a booking for January 15
3. Verify booking displays on Jan 15 only (not Jan 15-16)
4. Create a 3-day booking (Jan 15-17)
5. Verify displays on exactly 3 days
6. Test conflict detection with overlapping bookings
7. Repeat tests with browser in HST (UTC-10) and NZDT (UTC+13)

-- 
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