first of all please forgive my broken English. I'm facing a issue.
Currently my project is a announcement system project. Then user can add new announcement in my calendar. So my calendar can have many options.
Now problem is, let say my calendar announcement have four record:
Title: Announcement Adhoc 1 StartDate: 2017-09-26 StartTime: 00:00 RecurrencePattern: Adhoc EndDate: 2017-09-26 EndTime: 00:03
Title: Announcement Daily 1 StartDate: 2017-09-26 StartTime: 01:00 RecurrencePattern: Daily EndDate: 2017-09-26 EndTime: 01:03
Title: Announcement Weekly StartDate: 2017-09-26 StartTime: 02:00 RecurrencePattern: Weekly Days: ["1","3","4"] //This is getDate() and store EndDate: 2017-09-26 EndTime: 02:03
Title: Announcement Monthly StartDate: 2017-09-26 StartTime: 03:00 RecurrencePattern: Monthly EndDate: 2017-09-26 EndTime: 03:03
and now i would like to add a new Announcement record which is cannot match in between the StartDate StartTime and EndDate EndTime in those records. What should i do?
Note:
Adhoc only play one time.
Daily will play everyday based on the Start Time until the End Time.
Weekly will play based on the days, Start Time and End Time.
Monthly will play based on the Date of the Month, Start Time and End Time.
Hope you all understand what I'm asking and your help would save my life.
Thanks you so much.
Here is my code:
var NewAddStartDateTime = "2016-09-27T13:11:00";
var NewAddEndDateTime = "2016-09-27T13:20:00";
var jsonObj = [{
"id": 1,
"type": "Adhoc",
"days": [],
"startDateTime": "2016-09-28T13:11:00",
"endDateTime": "2016-09-28T13:19:00"
}, {
"id": 2,
"type": "Weekly",
"days": ["1", "3", "4"],
"startDateTime": "2016-09-28T13:11:00",
"endDateTime": "2016-09-28T13:19:00"
}]
//jsonObj[i].startDateTime = "2016-09-27T13:11:00"
//jsonObj[i].endDateTime = "2016-09-27T13:19:00"
for (var i = 0; i < jsonObj.length; i++) {
if ((NewAddStartDateTime > jsonObj[i].startDateTime && NewAddStartDateTime < jsonObj[i].endDateTime) || NewAddStartDateTime == jsonObj[i].startDateTime || (NewAddEndDateTime > jsonObj[i].startDateTime && NewAddEndDateTime < jsonObj[i].endDateTime)) {
console.log("cannot add because in between the date match Adhoc");
CannotAdd = true;
QuitLoop = true;
break;
}
}