So basically I wanted a function which took a calendar service
instance, the name of a particular calendar, and a start and end date
and return a feed containing only the events from the named calendar
which occur between start_date and end_date. Much of the code is
copied from the examples.
So why does this query give me events which fall outside the date
range and how can I fix it?
The code follows:
def DateRangeQuery(calendar_service, calname,
start_date='2007-01-01',
end_date='2007-07-01'):
print 'Date range query for events on Primary Calendar: %s to %s' %
(start_date, end_date,)
query = gdata.calendar.service.CalendarEventQuery('default',
'private', 'full')
query.start_min = start_date
query.start_max = end_date
feed = ReturnCalendarFeedByname(calendar_service,calname)
feed.AddQuery(query.ToUri())
for i, an_event in enumerate(feed.entry):
if an_event.title != None:
print '\t%s. %s' % (i, an_event.title.text,)
for a_when in an_event.when:
print '\t\tStart time: %s' % (a_when.start_time,)
print '\t\tEnd time: %s' % (a_when.end_time,)
#useful information about reoccurence can be found
#in feed.entry[n].recurrence.text. It's strange that
#the query doesn't work properly
return(feed)
def ReturnCalendarFeedByname(Calendar_service, calname):
feed = Calendar_service.GetAllCalendarsFeed()
for entry in feed.entry:
if str(entry.title.text).lower() == calname.lower():
return(Calendar_service.GetCalendarEventFeed(entry.link
[0].href))
--
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en.