I'm trying to learn javascript by writing my own events calendar and I ran into a challenge.
I'm doing this to check if a date falls between the start and end date of an event:
if(thisCellDate > startEventDate && thisCellDate < endEventDate) {}
thisCellDate is the current cell in a grid of days I'm looping over (the days in the current month). The problem is that when the start date is on the same day as the cell's in the grid it doesn't work because the date of the cell is technically earlier.
He is an example of what I'm talking about:
Start Date: Fri May 02 2014 15:01:16 GMT-0400 (Eastern Daylight Time)
Cell's Date: Sat May 02 2014 00:00:00 GMT-0400 (Eastern Daylight Time)
End Date: Thu May 29 2014 16:01:24 GMT-0400 (Eastern Daylight Time)
I am generation the Cell's date with a date string like: new Date('8,8,2014')
Now I was thinking I could solve this issue by just making the cell's date as close as possible to the next date like this: new Date(2013, 8, 8, 23, 59, 59, 999)
This way the event dates should always be earlier than the cell dates. Is there a problem doing it this way or is there a clearer way?