def getOnDayDetails()

in src/zonal/rule.py [0:0]


    def getOnDayDetails(self, start, indicatedDay, indicatedOffset):
        """
        Get RRULE BYxxx part items from the Rule data.

        @param start: start date-time for the recurrence set
        @type start: L{DateTime}
        @param indicatedDay: the day that the Rule indicates for recurrence
        @type indicatedDay: C{int}
        @param indicatedOffset: the offset that the Rule indicates for recurrence
        @type indicatedOffset: C{int}
        """

        month = start.getMonth()
        year = start.getYear()
        dayOfWeek = start.getDayOfWeek()

        # Need to check whether day has changed due to time shifting
        # e.g. if "u" mode is specified, the actual localtime may be
        # shifted to the previous day if the offset is negative
        if indicatedDay != dayOfWeek:
            difference = dayOfWeek - indicatedDay
            if difference in (1, -6,):
                indicatedOffset += 1

                # Adjust the month down too if needed
                if start.getDay() == 1:
                    month -= 1
                    if month < 1:
                        month = 12
            elif difference in (-1, 6,):
                assert indicatedOffset != 1, "Bad RRULE adjustment"
                indicatedOffset -= 1
            elif difference in (-5,):
                pass
            else:
                assert False, "Unknown RRULE adjustment"

        try:
            # Form the appropriate RRULE bits
            day = Rule.DAY_NAME_TO_RDAY[dayOfWeek]
            offset = indicatedOffset
            bymday = None
            if offset == 1:
                offset = 1
            elif offset == 8:
                offset = 2
            elif offset == 15:
                offset = 3
            elif offset == 22:
                offset = 4
            else:
                days_in_month = daysInMonth(month, year)
                if days_in_month - offset == 6:
                    offset = -1
                elif days_in_month - offset == 13:
                    offset = -2
                elif days_in_month - offset == 20:
                    offset = -3
                else:
                    bymday = [offset + i for i in range(7) if (offset + i) <= days_in_month]
                    offset = 0
        except:
            assert False, "onDay value is not recognized: %s" % (self.onDay,)

        return offset, day, bymday