mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Show custom embed for weekends
This commit is contained in:
parent
a198a83153
commit
e9ea063876
2 changed files with 37 additions and 1 deletions
27
functions/les.py
Normal file
27
functions/les.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from datetime import datetime, timedelta
|
||||
from functions.timeFormatters import dateTimeNow, weekdayToInt, forward_to_weekday
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def find_target_date(arg: Optional[str]) -> datetime:
|
||||
"""
|
||||
Find the requested date out of the user's arguments
|
||||
"""
|
||||
# Start at current date
|
||||
day: datetime = dateTimeNow()
|
||||
|
||||
# If no offset was provided, check the time
|
||||
# otherwise the argument overrides it
|
||||
if arg is None:
|
||||
# When the command is used after 6 pm, show schedule
|
||||
# for the next day instead
|
||||
if day.hour > 18:
|
||||
day += timedelta(days=1)
|
||||
elif 0 <= (weekday := weekdayToInt(arg)) <= 4: # Weekday provided
|
||||
day = forward_to_weekday(day, weekday)
|
||||
elif arg.lower() == "morgen": # Tomorrow's schedule
|
||||
day += timedelta(days=1)
|
||||
elif arg.lower() == "overmorgen": # Day after tomorrow's schedule
|
||||
day += timedelta(days=2)
|
||||
|
||||
return day
|
||||
Loading…
Add table
Add a link
Reference in a new issue