Add error handling for possible string/datetime created at stamps

This commit is contained in:
Andrew Shumway
2025-01-15 12:49:47 -07:00
parent 345ae88ffc
commit 3fd8009e33
2 changed files with 13 additions and 3 deletions

View File

@@ -103,8 +103,19 @@ def dao_create_notification(notification):
orig_time = notification.created_at
now_time = utc_now()
print(hilite(f"original time: {orig_time} - {type(orig_time)} \n now time: {now_time} - {type(now_time)}"))
diff_time = now_time - datetime.strptime(orig_time, "%Y-%m-%D-%H-%M-%S")
print(
hilite(
f"original time: {orig_time} - {type(orig_time)} \n now time: {now_time} - {type(now_time)}"
)
)
try:
diff_time = now_time - orig_time
except TypeError:
try:
orig_time = datetime.strptime(orig_time, "%Y-%m-%dT%H:%M:%S.%fZ")
except ValueError:
orig_time = datetime.strptime(orig_time, "%Y-%m-%d")
diff_time = now_time - orig_time
current_app.logger.error(
f"dao_create_notification orig created at: {orig_time} and now created at: {now_time}"
)