From c90c36076eaed6d3d412942f5da56d2d74d9073e Mon Sep 17 00:00:00 2001 From: Janne Karjalainen Date: Wed, 6 Oct 2021 10:54:04 +0300 Subject: [PATCH] Fix EUDAT extended updated field --- .../modules/records/serializers/schemas/eudatextended.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/b2share/modules/records/serializers/schemas/eudatextended.py b/b2share/modules/records/serializers/schemas/eudatextended.py index 565028b9d..08971f39c 100644 --- a/b2share/modules/records/serializers/schemas/eudatextended.py +++ b/b2share/modules/records/serializers/schemas/eudatextended.py @@ -3,7 +3,7 @@ from .eudatcore import EudatCoreSchema from lxml import etree from .dc import record_url - +from datetime import datetime def add_affiliations(source, target): if source.get('affiliations', []): @@ -116,6 +116,7 @@ def contributors(self, metadata, root): root.append(contributors) def dates(self, obj, root): + from dateutil import parser metadata = obj['metadata'] dates = E.dates() if 'dates' in metadata: @@ -125,8 +126,9 @@ def dates(self, obj, root): date.set('dateInformation', d['date_information']) dates.append(date) dates.append(E.date(obj['created'],dateType='Created', dateInformation='Creation')) - if obj['updated'] > obj['created']: - dates.append(E.date(obj['updated'],dateType='Updated', dateInformation='Updated with latest properties')) + d = parser.parse(obj['updated']) - parser.parse(obj['created']) + if d.days > 0: + dates.append(E.date(obj['updated'], dateType='Updated', dateInformation='Updated with latest properties')) root.append(dates) def resource_types(self, metadata, root):