agenda/agenda/hn.py

31 lines
871 B
Python

"""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