From 2eeeebc3d105e2b9d6d9675f7d902a3a9edb3dca Mon Sep 17 00:00:00 2001 From: spameier Date: Fri, 31 Mar 2023 22:22:30 +0200 Subject: [PATCH] fix: handle unexpected release date --- suisa_sendemeldung/suisa_sendemeldung.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suisa_sendemeldung/suisa_sendemeldung.py b/suisa_sendemeldung/suisa_sendemeldung.py index f713fc72..a30e69f5 100644 --- a/suisa_sendemeldung/suisa_sendemeldung.py +++ b/suisa_sendemeldung/suisa_sendemeldung.py @@ -376,7 +376,10 @@ def funge_release_date(release_date: str = ""): if len(release_date) == 10: # we can make it look like what suisa has in their examples if it's the right length - return datetime.strptime(release_date, "%Y-%m-%d").strftime("%Y%m%d") + try: + return datetime.strptime(release_date, "%Y-%m-%d").strftime("%Y%m%d") + except ValueError: + return "" # we discard other records since there is no way to convert records like a plain # year into dd/mm/yyyy properly without further guidance from whomever ingests # the data, in some cases this means we discard data that only contain a year