Convert local dates to utc

main
Bob Mottram 2020-11-22 19:09:35 +00:00
parent fb29da5f7a
commit 6f5d5f1019
2 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ from socket import error as SocketError
import errno
from datetime import datetime
from datetime import timedelta
from datetime import timezone
from collections import OrderedDict
from utils import firstParagraphFromString
from utils import isPublicPost
@ -189,6 +190,8 @@ def parseFeedDate(pubDate: str) -> str:
pubDateStr = None
if publishedDate:
# convert local date to UTC
publishedDate = publishedDate.replace(tzinfo=timezone.utc)
pubDateStr = str(publishedDate)
if not pubDateStr.endswith('+00:00'):
pubDateStr += '+00:00'

View File

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