예제 #1
0
    def expand_event(self, event, frequency):
        events = []

        this_year = datetime.now().year
        start_year = max(this_year, event["date"].year)
        end_year = this_year + 1

        if frequency == "yearly":
            for year in range(start_year, end_year):
                new_event = event.copy()
                new_event["date"] = safe_date_replace(
                        event["date"], year=year)
                events.append(new_event)
        elif frequency == "monthly":
            for year in range(start_year, end_year):
                for month in range(1, 13):
                    new_event = event.copy()
                    new_event["date"] = safe_date_replace(
                            event["date"], year=year)
                    events.append(new_event)

        return events
예제 #2
0
    def expand_event(self, event, frequency):
        events = []

        today = parse_date("now").date()
        start_year = max(today.year, event["date"].year)
        end_year = today.year + 1

        if frequency == "yearly":
            for year in range(start_year, end_year):
                new_event = event.copy()
                new_event["date"] = safe_date_replace(
                        event["date"], year=year)
                events.append(new_event)
        elif frequency == "monthly":
            for year in range(start_year, end_year):
                for month in range(1, 13):
                    new_event = event.copy()
                    new_event["date"] = safe_date_replace(
                            event["date"], year=year)
                    events.append(new_event)

        events = [e for e in events if e["date"].date() > today]

        return events