In this episode, we tackle a little issue with how our availability schedule works. By default, our system was showing availability starting at the very beginning of the work day (like 9:00 AM), even if that time had already passed. Obviously, we don't want users booking appointments in the past!
So, we walk through how to automatically exclude time that has already elapsed today. We start by showing what the problem looks like, then jump into our routes to set up a scenario where the booking window should start later – for instance, if it's currently 10:00 AM, bookings should only show up from 11:00 AM onwards.
To do this, we add a new method called excludeTimePassedToday
. This method chops off the part of the day that's already gone and only leaves times in the future for people to book. We use the start of the current day up to the end of the current hour as the period to subtract.
By the end, we've fine-tuned our booking system so users can only make appointments for future times, and we chat a bit about how you might customize this to, say, add a buffer before new appointments can be made. Super handy if you want your booking system to feel a bit smarter and avoid those awkward “booking in the past” moments!