omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. AA737

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 6
    • Best 0
    • Controversial 0
    • Groups 0

    AA737

    @AA737

    0
    Reputation
    447
    Profile views
    6
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    AA737 Unfollow Follow

    Latest posts made by AA737

    • RE: How to remove or change a calendar event?

      @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 
      

      Fantastic, thanks @cvp and @JonB !

      posted in Pythonista
      AA737
      AA737
    • RE: How to remove or change a calendar event?

      @cvp said:

      @AA737 After testing, I've remarked that after 10 runs (always), there is no crash at all but the returned calendars list of EKEventStore is empty and sincerely, I didn't find anything similar in Google nor any explanation.

      Interesting, thank you for looking into it, and all your help!

      posted in Pythonista
      AA737
      AA737
    • RE: How to remove or change a calendar event?

      @cvp Have you noticed you can only run your calendar script about 8 times in a row, and then it stops working and Pythonista has to be reset? Any idea why, or a fix for it?

      posted in Pythonista
      AA737
      AA737
    • RE: How to remove or change a calendar event?

      @cvp that worked great, thank you! I have a lot to learn...

      posted in Pythonista
      AA737
      AA737
    • RE: How to remove or change a calendar event?

      @ccc sorry, I didn’t word that very clearly. Right now, I have a parameter to return all events that occur in the next 2 days, from all calendars. I would like to return events from only one calendar. I have reviewed the Apple documentation, but I have to admit I don’t understand it

      @cvp thank you, that works well, however, instead of doing an If statement, what would be the format to replace the “None” with a calendar name in the predicate?

      I tried a few things, but I really can’t figure out the format.
      Thanks for the help

       store = ObjCClass('EKEventStore').alloc().init()
       now = datetime.now()
      
      start_date = now.strftime('%Y-%m-%d %H:%M:%S')
      
      start_date = datetime.now() + timedelta(hours=0)
      tomorrow = datetime.now() + timedelta(days=2)
      
      start_date = start_date.strftime('%Y-%m-%d %H:%M:%S')
      tomorrow_formatted = tomorrow.strftime('%Y-%m-%d %H:%M:%S')
      
      startDate = ObjCClass('NSDate').dateWithTimeIntervalSince1970_(time.mktime(time.strptime(start_date, '%Y-%m-%d %H:%M:%S')))
      
      endDate = 	ObjCClass('NSDate').dateWithTimeIntervalSince1970_(time.mktime(time.strptime(tomorrow_formatted, '%Y-%m-%d %H:%M:%S')))
      
      predicate = store.predicateForEventsWithStartDate_endDate_calendars_(startDate, endDate, None)
      
      events = store.eventsMatchingPredicate_(predicate)’ ‘ ‘
      
      posted in Pythonista
      AA737
      AA737
    • RE: How to remove or change a calendar event?

      Hello!

      Brand new to python, and programming as a whole. I used this template successfully, thank you, but I was wondering how to specify a specific calendar? I assume it would be in the “predicate,” after the start and end time, the “none?”

      Thanks!

      posted in Pythonista
      AA737
      AA737