From de92f32ab6ce1e6a82a9a11df85aa25d62894696 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 4 Feb 2021 21:39:14 +0200 Subject: [PATCH] csv_metadata_quality/check.py: More date formats We should also allow ISO 8601 extended in combined date and time format. DSpace does not have a problem with dates in this format and I have found some metadata that uses this date format. For example: 2020-08-31T11:04:56Z See: https://en.wikipedia.org/wiki/ISO_8601 --- csv_metadata_quality/check.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/csv_metadata_quality/check.py b/csv_metadata_quality/check.py index ef43a21..16a881f 100755 --- a/csv_metadata_quality/check.py +++ b/csv_metadata_quality/check.py @@ -135,6 +135,14 @@ def date(field, field_name): # Check if date is valid YYYY-MM-DD format datetime.strptime(field, "%Y-%m-%d") + return field + except ValueError: + pass + + try: + # Check if date is valid YYYY-MM-DDTHH:MM:SSZ format + datetime.strptime(field, "%Y-%m-%dT%H:%M:%SZ") + return field except ValueError: print(f"Invalid date ({field_name}): {field}")