Add Rio Carnival to agenda
This commit is contained in:
parent
7e51a32210
commit
5f0d2e884f
|
@ -14,6 +14,7 @@ import isodate # type: ignore
|
|||
import lxml
|
||||
import pytz
|
||||
import yaml
|
||||
from dateutil.easter import easter
|
||||
|
||||
from . import (
|
||||
accommodation,
|
||||
|
@ -65,6 +66,32 @@ def midnight(d: date) -> datetime:
|
|||
return datetime.combine(d, datetime.min.time())
|
||||
|
||||
|
||||
def rio_carnival_events(start_date: date, end_date: date) -> list[Event]:
|
||||
"""List of events for Rio Carnival for each year between start_date and end_date."""
|
||||
events = []
|
||||
for year in range(start_date.year, end_date.year + 1):
|
||||
easter_date = easter(year)
|
||||
carnival_start = easter_date - timedelta(days=51)
|
||||
carnival_end = easter_date - timedelta(days=46)
|
||||
|
||||
# Only include the carnival if it falls within the specified date range
|
||||
if (
|
||||
start_date <= carnival_start <= end_date
|
||||
or start_date <= carnival_end <= end_date
|
||||
):
|
||||
events.append(
|
||||
Event(
|
||||
name="carnival",
|
||||
title="Rio Carnival",
|
||||
date=carnival_start,
|
||||
end_date=carnival_end,
|
||||
url="https://en.wikipedia.org/wiki/Rio_Carnival",
|
||||
)
|
||||
)
|
||||
|
||||
return events
|
||||
|
||||
|
||||
def dates_from_rrule(
|
||||
rrule: str, start: date, end: date
|
||||
) -> typing.Sequence[datetime | date]:
|
||||
|
@ -333,6 +360,7 @@ async def get_data(
|
|||
events += economist.publication_dates(last_week, next_year)
|
||||
events += meetup.get_events(my_data)
|
||||
events += hn.whoishiring(last_year, next_year)
|
||||
events += rio_carnival_events(last_year, next_year)
|
||||
|
||||
events += domains.renewal_dates(my_data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue