From f67ce00fc7903b70ac433f4e1e5c717fae354cff Mon Sep 17 00:00:00 2001 From: Ayyub Ibrahim Date: Sun, 31 Dec 2023 23:55:29 -0600 Subject: [PATCH] added default value for dates --- packages/googlecloud/functions/getanswer/inquirer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/googlecloud/functions/getanswer/inquirer.py b/packages/googlecloud/functions/getanswer/inquirer.py index d219915d..db223fd5 100644 --- a/packages/googlecloud/functions/getanswer/inquirer.py +++ b/packages/googlecloud/functions/getanswer/inquirer.py @@ -16,10 +16,13 @@ def convert_date_format(date_str): """Convert date from 'MM-DD-YYYY' to 'MM/DD/YYYY' format.""" + if date_str is None or not isinstance(date_str, str): + return "date not available" + try: return datetime.strptime(date_str, "%m-%d-%Y").strftime("%m/%d/%Y") except ValueError: - return date_str # Return original string if format does not match + return "date not available" def timestamp_to_seconds(timestamp):