1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2024-12-22 04:02:19 +01:00

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
This commit is contained in:
Alan Orth 2021-02-04 21:39:14 +02:00
parent dbbbc0944a
commit de92f32ab6
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -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}")