omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Calendar event - recurrences and alarms

    Pythonista
    2
    7
    3386
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • brumm
      brumm last edited by brumm

      Who can help me with calendar event recurrences and alarms? I'd like to read and write EKRecurrenceRules and EKAlarms. Sorry still struggling with Objective-C.

      That is what I got so far.

      edit:
      two examples from an event output:

      recurrence = EKRecurrenceRule <0x10eee8160> RRULE FREQ=YEARLY;INTERVAL=1;COUNT=5;

      alarms = (
      "EKAlarm <0x109123e50> {triggerInterval = -300.000000}",
      "EKAlarm <0x108d85720> {triggerInterval = -86400.000000}"
      );

      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @brumm last edited by cvp

        @brumm little help about

        Code to get the alarms timers in seconds and code to add an alarm to an event

        alarms = event.alarms # list of objects EKAlarm
        for alarm in event.alarms:
        	print(int(alarm.relativeOffset()/60))
        	
        # add non zero alarm
        al = 900 # in seconds
        alarm = ObjCClass('EKAlarm').alarmWithRelativeOffset_(al)
        event.addAlarm_(alarm)
        
        1 Reply Last reply Reply Quote 1
        • cvp
          cvp @brumm last edited by

          @brumm same kind of process, but more complex, for recurrence rules
          see here

          1 Reply Last reply Reply Quote 0
          • brumm
            brumm last edited by

            Great, thank you. I will try to write the recurrences part.

            cvp 2 Replies Last reply Reply Quote 0
            • cvp
              cvp @brumm last edited by

              @brumm I forgot to say that you can define an alarm with:
              A negative delay for "before the event begin"
              A positive delay for "after the event begin". This is useful if you want to be warned some time before the end of the event. This is not possible via the standard iOS Calendar app but can be done on iMac. So you have the possibility now on your iDevice.

              1 Reply Last reply Reply Quote 0
              • cvp
                cvp @brumm last edited by

                @brumm try this

                recurrencerule = ObjCClass('EKRecurrenceRule').alloc()
                
                # one way to init it
                # frequency: 0=dayly, ...see https://developer.apple.com/documentation/eventkit/ekrecurrencefrequency?language=objc
                recurrencerule.initRecurrenceWithFrequency_interval_end_(0,1,None)
                
                # other methods allow to set attributes of recurrence rule
                # print(dir(recurrencerule))
                # setDaysOfTheMonth_
                # setDaysOfTheWeek_
                # setDaysOfTheYear_
                # setEndDate_
                # setFirstDayOfTheWeek_
                # setFrequency_
                # setInterval_
                # setMonthsOfTheYear_
                event.addRecurrenceRule_(recurrencerule)		
                
                if event.hasRecurrenceRules():
                	but = console.alert('Event is recurrent','modify this instance only?','Yes','No',hide_cancel_button=True)
                	if but == 1:
                		span = 0 # only this instance
                	else:
                		span = 1 # all instances
                else:
                	span = 0 # only this instance
                # store modified event in calendar
                store.saveEvent_span_error_(event,span,None) 
                
                1 Reply Last reply Reply Quote 1
                • brumm
                  brumm last edited by

                  Thanks a lot!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors