I'm trying to select events for the next 2 weeks starting from today's date. The logic used is pretty easy. I get all calendars, then pick one i need to pull events from and supply the date range. I'm pulling dates from the selected calendar however it doesn't look like the date range is applied. Now, i have 2 events scheduled for the following dates.
- October 8
- October 20
I should only be getting event scheduled for October 20th, but i'm getting both.
CalendarService calService = new CalendarService(calendarAppName);
calService.setUserCredentials(username, password);
CalendarQuery calQuery = new CalendarQuery();
calQuery.Uri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed calFeed = (CalendarFeed)calService.Query(calQuery);
var activeCalendar = calFeed.Entries.Where(x => x.Title.Text == calendarName).FirstOrDefault();
if (activeCalendar != null)
{
EventQuery evtQuery = new EventQuery(GetCalendarFeed(activeCalendar));
evtQuery.StartDate = DateTime.Now.AddDays(-1);
evtQuery.EndDate = DateTime.Now.AddDays(14);
evtQuery.FutureEvents = false;
EventFeed evtFeed = calService.Query(evtQuery);
}
...
private static string GetCalendarFeed(AtomEntry calendarEntry)
{
string feedstring = calendarEntry.Id.AbsoluteUri.Substring(63);
return string.Format("http://www.google.com/calendar/feeds/{0}/private/full", feedstring);
}
Can anybody spot something anything wrong?
EDIT: It turns out StartTime/EndTime works correctly. I don't really understand what the difference is though and i can't seem to find anything in the docs.