utc offset adjust

main
Bob Mottram 2020-11-22 20:18:10 +00:00
parent fb5cb31ba1
commit 7703a002cd
2 changed files with 3 additions and 1 deletions

View File

@ -190,6 +190,7 @@ def parseFeedDate(pubDate: str) -> str:
pubDateStr = None
if publishedDate:
publishedDate = publishedDate - publishedDate.utcoffset()
# convert local date to UTC
publishedDate = publishedDate.replace(tzinfo=timezone.utc)
pubDateStr = str(publishedDate)

View File

@ -2394,12 +2394,13 @@ def testParseFeedDate():
pubDate = "Sun, 22 Nov 2020 19:51:33 +0100"
publishedDate = parseFeedDate(pubDate)
assert publishedDate == "2020-11-22 19:51:33+00:00"
assert publishedDate == "2020-11-22 18:51:33+00:00"
def runAllTests():
print('Running tests...')
testParseFeedDate()
return
testFirstParagraphFromString()
testGetNewswireTags()
testHashtagRuleTree()