Rework a bunch of scripts into a single website script
This commit is contained in:
parent
f83c6ebbe5
commit
a9f52aad98
12 changed files with 275 additions and 92 deletions
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def next_sunday_noon(from_date: Optional[datetime.date] = None) -> datetime.datetime:
|
||||
'''
|
||||
Return a `datetime` for noon on the upcoming Sunday. Use today if no
|
||||
`from_date` is given.
|
||||
'''
|
||||
|
||||
today = from_date or datetime.date.today()
|
||||
|
||||
current_weekday = today.weekday()
|
||||
if current_weekday == 6:
|
||||
days_to_next_sunday = 6
|
||||
else:
|
||||
days_to_next_sunday = 6 - current_weekday
|
||||
|
||||
delta = datetime.timedelta(days=days_to_next_sunday)
|
||||
|
||||
noon = datetime.time(hour=12)
|
||||
|
||||
timezone = datetime.datetime.now().astimezone().tzinfo
|
||||
next_sunday_noon = datetime.datetime.combine(
|
||||
today + delta,
|
||||
noon,
|
||||
tzinfo=timezone
|
||||
)
|
||||
|
||||
return next_sunday_noon
|
Loading…
Add table
Add a link
Reference in a new issue