Add /parse command

This commit is contained in:
2022-10-30 20:03:47 +01:00
parent bf767b622a
commit 8f01d1825f
2 changed files with 63 additions and 6 deletions

View File

@ -37,12 +37,25 @@ def calculate(job: Job) -> str:
# Get time and date the job will run and calculate how many days,
# hours and seconds.
countdown = trigger_time - datetime.datetime.now(tz=pytz.timezone(config_timezone))
return countdown(trigger_time)
def countdown(trigger_time: datetime) -> str:
"""
Calculate days, hours and minutes to a date.
Args:
trigger_time: The date.
Returns:
A string with the days, hours and minutes.
"""
countdown_time = trigger_time - datetime.datetime.now(tz=pytz.timezone(config_timezone))
days, hours, minutes = (
countdown.days,
countdown.seconds // 3600,
countdown.seconds // 60 % 60,
countdown_time.days,
countdown_time.seconds // 3600,
countdown_time.seconds // 60 % 60,
)
# TODO: Explain this.