Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to remove or change a calendar event?
-
@ccc I know, but here we need Objectivec NSDateFormatter objects
-
Yes. My point was about converting from Python datetimes to Objective C datetimes.
-
@cvp said:
@AA737 Thanks to @JonB , this works
import datetime import objc_util with objc_util.autoreleasepool(): # EKEventStore = calendar database store = objc_util.ObjCClass('EKEventStore').alloc().init() # Convert string yyyymmdd to NSdate dateFormat = objc_util.ObjCClass('NSDateFormatter').alloc().init() dateFormat.setDateFormat_('yyyyMMdd HH:mm') date1 = dateFormat.dateFromString_('20200101 00:01') date2 = dateFormat.dateFromString_('20201231 23:59') calendars_array = [calendar for calendar in store.calendars() if str(calendar.title()) == 'Sorties'] predicate = store.predicateForEventsWithStartDate_endDate_calendars_(date1, date2, calendars_array) events = store.eventsMatchingPredicate_(predicate) for event in events: print(event.title()) store.autorelease() del events, predicate, store, calendars_array