mirror of
https://gitlab.com/MisterBiggs/multi-bot-tutorial.git
synced 2025-06-16 15:17:25 +00:00
improved countdown
This commit is contained in:
parent
3a6a575b56
commit
52c2a99f3a
11
functions.py
11
functions.py
@ -11,7 +11,7 @@ def nextLaunch():
|
||||
"rocket": "Proton-M/Blok DM-03 ",
|
||||
"mission": " Spektr-RG",
|
||||
"date": "July 12, 2019 12:31:00 UTC",
|
||||
"countdown": "15:00:03.884469",
|
||||
"countdown": "The launch is in 14 hours and 48 minutes.",
|
||||
"video": "https://www.youtube.com/watch?v=Dy1nkGghEVk",
|
||||
}
|
||||
"""
|
||||
@ -24,7 +24,12 @@ def nextLaunch():
|
||||
|
||||
rocket, mission = data["name"].split("|")
|
||||
date = data["net"]
|
||||
countdown = datetime.strptime(date, "%B %d, %Y %H:%M:%S %Z") - datetime.today()
|
||||
|
||||
# Extract the timde delta between now and the launch, then format it into an easy to read format.
|
||||
countdown = str(
|
||||
datetime.strptime(date, "%B %d, %Y %H:%M:%S %Z") - datetime.today()
|
||||
).split(":")
|
||||
countdown = f"The launch is in {countdown[0]} hours and {countdown[1]} minutes."
|
||||
|
||||
else:
|
||||
print("error")
|
||||
@ -33,7 +38,7 @@ def nextLaunch():
|
||||
"rocket": rocket.strip(),
|
||||
"mission": mission.strip(),
|
||||
"date": date,
|
||||
"countdown": str(countdown),
|
||||
"countdown": countdown,
|
||||
"video": data["vidURLs"][0],
|
||||
}
|
||||
return launch
|
||||
|
Loading…
x
Reference in New Issue
Block a user