diff --git a/functions.py b/functions.py index 2efc342..40dcca1 100644 --- a/functions.py +++ b/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