1

I am trying to use the day field of a datetime property as a filter when selecting events from an iCal calendar.

The following doesn't seem to work (to select all events for the current date):

cal = app("iCal").calendars["myCalender"].get()
cDate = datetime.now()
cEvents = cal.events[its.start_date.day==cDate.day].get()

I get the result: AttributeError: Unknown property, element or command: 'day'

However, this works (for printing the days of any events)...

cal = app("iCal").calendars["myCalender"].get()
for cEvent in cal.events.get():
    print cEvent.start_date.get().day
TheMaster
  • 45,448
  • 6
  • 62
  • 85
plong0
  • 11
  • 1

1 Answers1

0

This line

cal.events[its.start_date.day==cDate.day].get()

checks its.start_date.day==cDate.day and returns False or True. As an index, this translates into 0 and 1 and takes one of the first two elements in the cal.events list. Is this what you want?

eumiro
  • 207,213
  • 34
  • 299
  • 261