Skip to content

Commit

Permalink
Make sure Onix ISO8601 dates containe timezone information. (#27)
Browse files Browse the repository at this point in the history
* Make sure Onix ISO8601 dates containe timezone information.
* Use to_utc function.
  • Loading branch information
jonathangreen authored Aug 23, 2021
1 parent 19e7812 commit c0d21fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/onix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Representation,
Subject,
LicensePool, EditionConstants)
from core.util.datetime_helpers import strptime_utc
from core.util.datetime_helpers import to_utc
from core.util.xmlparser import XMLParser


Expand Down Expand Up @@ -224,6 +224,12 @@ def parse(cls, file, data_source_name, default_medium=None):
issued = None
if publishing_date:
issued = dateutil.parser.isoparse(publishing_date)
if issued.tzinfo is None:
cls._logger.warning(
"Publishing date {} does not contain timezone information. Assuming UTC."
.format(publishing_date)
)
issued = to_utc(issued)

identifier_tags = parser._xpath(record, 'productidentifier')
identifiers = []
Expand Down

0 comments on commit c0d21fd

Please sign in to comment.