@property
    def next_time(self):
        """
        Return the OccurringRule or RecurringRule with the closest `dt_start` from now.
        """
        now = timezone.now()
        recurring_start = occurring_start = None

        try:
            occurring_rule = self.occurring_rule
        except OccurringRule.DoesNotExist:
            pass
        else:
            if occurring_rule and now > occurring_rule.dt_start:
                occurring_start = (occurring_rule.dt_start, occurring_rule)

        rrules = self.recurring_rules.filter(finish__gt=now)
        recurring_starts = [(rule.dt_start, rule) for rule in rrules if rule.dt_start is not None]
        recurring_starts.sort(key=itemgetter(0))

        try:
            recurring_start = recurring_starts[0]
        except IndexError:
            pass

        starts = [i for i in (recurring_start, occurring_start) if i is not None]
        starts.sort(key=itemgetter(0))
        try:
            return starts[0][1]
        except IndexError:
            return None
dataset/ETHPy150Open python/pythondotorg/events/models.py/Event.next_time/swapped operands of `>`