From 4fdecc4f30d2cfe9599c929137461668d1376ba2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 20 Oct 2020 13:22:52 +0100 Subject: [PATCH] Handle dates with offset --- newswire.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/newswire.py b/newswire.py index d43dacbb..303a9865 100644 --- a/newswire.py +++ b/newswire.py @@ -339,8 +339,13 @@ def getRSSfromDict(baseDir: str, newswire: {}, None, domainFull, 'Newswire', translate) for published, fields in newswire.items(): - published = published.replace('+00:00', 'Z').strip() - published = published.replace(' ', 'T') + if '+00:00' in published: + published = published.replace('+00:00', 'Z').strip() + published = published.replace(' ', 'T') + else: + publishedWithOffset = \ + datetime.datetime.strptime(published, "%Y-%m-%d %H:%M:%S%z") + published = publishedWithOffset.strftime("%Y-%m-%dT%H:%M:%SZ") try: pubDate = datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ") except BaseException: