I need to check the time interval between two time period. ie needs to block the appointment of a person in client side.
I have got 2 arrays
var fromTimings=["8:00","12:00","","16:00"];
var toTimings=["9:10","01:00","","19:00"];
These are the blocks which are already booked. ie first appointment is booked from 8:00 to 9:10, second is 12:00 to 1:00 and so on.
All the appointments are stored in two arrays in the above format.
Now I need to check for a user defined slot.
ie if the user entered like fromTime = 9:15 and 10:00 then must return / show available
logic as follows
fromTime | toTime | result
------------+--------------+-----------
7:00 | 7:59 | true
8:10 | 10:00 | false ( already meeting between 8:00 to 9:10)
19:01 | 23:59 | true
Can anyone please help ?
Thanks in advance
from
andto
time that you can lock or unlock as necessary?var Timeslot = new function(f,t) { this.from=f; this.to=t; this.reserved=false; }; Timeslot.prototype = { toggle: function() { this.reserved = !this.reserved; }};
and now you can simply buildnew Timeslot(...,...)
object and toggle each slot based on whether it's taken. Add a function to see if a time falls in a slot to the prototype, and off you go.