Add event for Hacker News 'Who is Hiring?'

Closes: #78
This commit is contained in:
Edward Betts 2023-12-01 10:35:58 +00:00
parent af329e4184
commit d70a18ad82
2 changed files with 32 additions and 0 deletions

View file

@ -24,6 +24,7 @@ from . import (
economist,
fx,
gwr,
hn,
meetup,
stock_market,
subscription,
@ -261,6 +262,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml"))
events += economist.publication_dates(last_week, next_year)
events += meetup.get_events(my_data)
events += hn.whoishiring(last_year, next_year)
events += domains.renewal_dates(my_data)

30
agenda/hn.py Normal file
View file

@ -0,0 +1,30 @@
"""Hacker News: Who Is Hiring post."""
from datetime import date, datetime, time, timedelta
import pytz
from dateutil.relativedelta import relativedelta
from .types import Event
eastern_time = pytz.timezone("America/New_York")
def whoishiring(start_date: date, end_date: date) -> list[Event]:
"""Who Is Hiring post."""
events: list[Event] = []
cur = start_date.replace(day=1)
t = time(11, 0)
while cur < end_date:
cur += relativedelta(months=1)
weekday = cur.weekday()
event_date = cur if 0 <= weekday <= 4 else cur + timedelta(days=7 - weekday)
events.append(
Event(
name="whoishiring",
date=eastern_time.localize(datetime.combine(event_date, t)),
url="https://news.ycombinator.com/submitted?id=whoishiring",
)
)
return events