Event scheduled on 4th monday of november appears every monday of november

  • Our big holiday is scheduled on the 4th monday of november. DAVx5 syncs it into every monday of november, though.

    • Android 10
    • DAVx5 2.6-gplay (308) 25.10.2019

    Using vdirsync, I get the event as follows; it seems that BYSETPOS is ignored by DAVx5:




  • developer


    Thanks for your report. I could reproduce it with Android 10 (emulated).

    Unfortunately, the Android calendar provider currently doesn’t support all BYDAY rules. When DAVx⁵ inserts the event, these are the logs:

    ical4android: [AndroidEvent] Built event object
    ical4android: 	PARAMETER #0 = mType: 1, mUri: content://com.android.calendar/events?caller_is_syncadapter=true&account_name=test&account_type=bitfire.at.davdroid&caller_is_syncadapter=true&account_name=test&account_type=bitfire.at.davdroid, mSelection: null, mExpectedCount: null, mYieldAllowed: false, mValues: organizer=a@b.ch duration=P1D description=
    ical4android:  allDay=1 accessLevel=3 hasAttendeeData=1 eventLocation=Bern eventStatus=1 rrule=FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYDAY=MO;BYSETPOS=4 title=Zibelemärit eventTimezone=Etc/UTC calendar_id=5 dtstart=1543190400000 availability=1, mValuesBackReferences: null, mSelectionArgsBackReferences: null
    ical4android: [BatchOperation] Committing 4 operations
    ical4android: [BatchOperation] Running 4 operations (0 .. 3)
    ical4android: [BatchOperation] … 3 record(s) affected
    11-09 18:05:12.108  3574  6218 V RecurrenceProcessor: BYSETPOS not supported with these rules: FREQ=YEARLY;INTERVAL=1;WKST=MO;BYDAY=MO;BYMONTH=11;BYSETPOS=4

    Note that DAVx⁵ inserts the event with the full rrule=FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYDAY=MO;BYSETPOS=4. However, Android’s RecurrenceProcessor says that BYSETPOS not supported with these rules.

    If you look up the RecurrenceProcessor source code, you can see that only FREQ=MONTHLY is supported.

    So, unfortunately, your recurring event is not supported by Android. The problem has already been reported to Google, but they classified it as Won’t Fix (Obsolete) without comment.

    Does that help?

  • Thanks!

    line#283ff confirms your findings:

                // BYSETPOS - we only handle rules like FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
                if (freq == EventRecurrence.MONTHLY && r.bydayCount > 0) {
    // ...
                } else {
                                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                                    Log.v(TAG, "BYSETPOS not supported with these rules: " + r);
                // BYSETPOS was defined but we don't know how to handle it.  Do no filtering based
                // on it.

    Not sure how current this code is.

    So the bug report should go to Google/Android.

  • @bitfire would it be possible to normalize such overly complex and confusing rrules? In this case I would expect a simple BYDAY=4MO?

  • developer

    @tapirapps Which RRULE do you mean, is there a specific case? Generally I’d expect the RRULE already to be in the shortest/best format and simplifying sounds complex and error-prone. But if there is a use case and a library, why not…

  • @rfc2822 I meant the case in this thread: rrule=FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYDAY=MO;BYSETPOS=4 (and I just had an aCalendar customer with a similar rrule for ‘last Sunday in October’). It seems like some clients create such awkward rules instead of properly prepending the position in the BYDAY field.

    It looks like a very simple replacement strategy: for rules with just a single week day in BYDAY and a BYSETPOS, set BYDAY to BYSETPOS+BYDAY and remove the BYSETPOS field.

    I understand that as a sync adapter you prefer to transparently keep the rrule as is, but as the Android calendar system doesn’t seem to support this (redundant) type of rule (BYSETPOS with a single value in BYDAY) and davX5 is an Android sync adapter, it would be very useful for your users.

Similar topics