@property
    def previous_time(self):
        now = timezone.now()
        recurring_end = occurring_end = None

        try:
            occurring_rule = self.occurring_rule
        except OccurringRule.DoesNotExist:
            pass
        else:
            if occurring_rule and occurring_rule.dt_end < now:
                occurring_end = (occurring_rule.dt_end, occurring_rule)

        rrules = self.recurring_rules.filter(begin__lt=now)
        recurring_ends = [(rule.dt_end, rule) for rule in rrules if rule.dt_end is not None]
        recurring_ends.sort(key=itemgetter(0), reverse=True)

        try:
            recurring_end = recurring_ends[0]
        except IndexError:
            pass

        ends = [i for i in (recurring_end, occurring_end) if i is not None]
        ends.sort(key=itemgetter(0), reverse=True)
        try:
            return ends[0][1]
        except IndexError:
            return None
dataset/ETHPy150Open python/pythondotorg/events/models.py/Event.previous_time/original