1
0
mirror of https://gitlab.com/MisterBiggs/multi-bot-tutorial.git synced 2025-06-15 22:56:45 +00:00

improved countdown

This commit is contained in:
Anson 2019-07-11 21:47:22 -07:00
parent 3a6a575b56
commit 52c2a99f3a

View File

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