I am building a scheduling application with Express. I have a calendar view that displays a monthly calendar.
Each day must be completely covered; whether shifts overlap or not, there must be at least one person on a shift at all times.
Given an array of shifts for the day that look like this
{
start: [javascript Date],
end: [javascript Date],
name: "James Bond",
...
}
I want to conditionally add a CSS class to highlight the day if more shifts are needed to fill it.
What is the best way tell if the time between x and y is completely filled?
You need to show what you have tried, but I will give you pseudocode for two basic approaches for this problem.
With either approach, make sure that you are using half-opened intervals for your shifts. This is represented a few different ways:
// interval notation:
[start, end)
// algebraicly
start <= value < end
// javascript and other code
start <= value && end > value
Date.getTime() on each date to get a simple numeric representation of each date.i = 0.x is in the shift, then increment i.1.-1.x.
i should be starting with the number of people currently working.i.i == 0 then nobody is working. Return false or error.i should never be negative. Error if it is.y is reached.