Hi,
i am trying to retrieve start time and end time values from my events calendar for items with recurring events. The start time is fine. But where i have a problem is with the endDate. it shows up as "Nan". You will think that the endDate will take up todays date up until you have exhausted the number of occurrences allowed.
Does anyone know how this can be achieved.
var ConstructUrlGlobalEvents;
var gtGlobEvenID = function getGlobalEventsID () {
// execute AJAX request
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('SSW Events')/items?$Select=Title,Location, EventDate, ID&top=5",
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
//console.log(data);
var globEventsitems = data.d.results;
var globEventspushedLink;
var globEventsitemsHtml = "";
var DateValue;
var TimeValue;
var MonthValue;
var DayValue;
var NewDateFormat;
var CheckTime;
var EventEndDate;
var today = new Date();
today = Date.parse(today);
console.log(data);
for (i=0; i< data.d.results.length; i++) {
CheckTime = data.d.results[i].EventDate;
CheckTime = Date.parse(CheckTime);
EventEndDate = data.d.results[i].EndDate;
EventEndDate = Date.parse(EventEndDate);
TimeValue = data.d.results[i].EventDate;
TimeValue= TimeValue.split('T');
TimeValue= TimeValue[1];
TimeValue = TimeValue.split(':');
TimeValue = TimeValue[0] + ":" + TimeValue[1];
DateValue = new Date(data.d.results[i].EventDate).toString();
DateValue=DateValue.split(' ');
//console.log(DateValue);
MonthValue=DateValue[1];
DayValue=DateValue[2];
NewDateFormat = DayValue.toString() + "-" +MonthValue +" " + TimeValue;
globEventspushedLink = ConstructUrlGlobalEvents + '\?ID=' +data.d.results[i].ID;
if (CheckTime >= today && ((CheckTime < EventEndDate) && (isNan(EventEndDate))) ) {
globEventsitemsHtml += '<li>' + '<a href="' +globEventspushedLink+ '">' +data.d.results[i].Title+ '</a>' + '<p>' + '<strong>' + 'Location:' + '</strong>' +data.d.results[i].Location+'</p>' + '<h4>' +NewDateFormat+'</h4>' + '</li>' ;
}
}
$("#upcomingEventsItems").append(globEventsitemsHtml);
},
error: function () {
//alert("Failed to get details");
}
});
}
var gtdformurlGlobEven = function getdispformUrlGlobalEvents () {
// execute AJAX request
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('SSW Events')/forms?$filter=(FormType eq 4)&$select=ServerRelativeUrl",
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
ConstructUrlGlobalEvents = data.d.results[0].ServerRelativeUrl;
gtGlobEvenID();
},
error: function () {
//alert("Failed to get details");
}
});
}