Friends,
I' working Appointment booking Project, Details are as follows: Business hour starts from 9:00 to 7:00 with default duration of 30mins. So, Slots start like (9:00, 9:30, 10:00.... 7:00).
Here, to show the available slots, I'm using the following Logic.
- Storing all the Slots with 30 min duration in a list (LIST A) like [9:00, 9:30, 10:00, 10:30, ... 7:00]
- Looping through booked appointments (contains start and end time), and if start time is matched with any of LIST A elements, I', removing that element from that List. and Loop continues.
Here, the problem is, Consider If appointment is booked 9:30-10:00. Based on my logic, 9:30 is matched with LIST A element, and It will remove 9:30 from that list.
So, available slots will be displayed as [9:00, X ,10:00, 10:30, .... 7:00]. Actually It should be [9:00, 9:30, 10:30, 11:00... 7:00]
Instead of showing available slots 9:00-9:30, 10:30-11:00 it shows 9:00-10:00, 10:30-11 since 9:30 is removed from the list.,
Please help to solve this, or suggest me some alternative approaches for this problem. Badly needed.