I am attempting to use the Google .Net Client Libraries to query for Google Calendar events.
I am successfully pulling down events but it seems to completely ignore the TimeMin and TimeMax and return events outside of that time-frame.
As a test, I widened this window from this time yesterday to this time tomorrow with AddDays()
.
My code is:
EventsResource.ListRequest req = service.Events.List(calendarId);
// Limit the calendar to today
req.TimeMin = DateTime.Now.AddDays(-1);
req.TimeMax = DateTime.Now.AddDays(1);
var events = req.Execute().Items;
For today (11/12/14 ... so 11/11/14 to 11/13/14 using the code above) this is returning events from 11/5/14.
Using the .Net libraries, these two properties are defined as nullable DateTime objects (DateTime?
), so I am not string-formatting these to any standard.
Am I doing something wrong here?
EDIT: I came across the following link. If this information is true, how exactly would this be handled from .Net where these fields are DateTime?
.
/events/list accepts timeMin and timeMax arguments and these are simply stated as accepting a ‘datetime’ argument. Of the myriad possible standardized date-time formats, I have discovered that this value should be a UTC date-time (with offset explicitly set at 00:00) formatted as RFC3339 (yyyy-MM-ddThh:mm:ss.sss+00:00).