forked from indymedia/epicyon
Convert local dates to utc
parent
fb29da5f7a
commit
6f5d5f1019
|
@ -12,6 +12,7 @@ from socket import error as SocketError
|
||||||
import errno
|
import errno
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from datetime import timezone
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from utils import firstParagraphFromString
|
from utils import firstParagraphFromString
|
||||||
from utils import isPublicPost
|
from utils import isPublicPost
|
||||||
|
@ -189,6 +190,8 @@ def parseFeedDate(pubDate: str) -> str:
|
||||||
|
|
||||||
pubDateStr = None
|
pubDateStr = None
|
||||||
if publishedDate:
|
if publishedDate:
|
||||||
|
# convert local date to UTC
|
||||||
|
publishedDate = publishedDate.replace(tzinfo=timezone.utc)
|
||||||
pubDateStr = str(publishedDate)
|
pubDateStr = str(publishedDate)
|
||||||
if not pubDateStr.endswith('+00:00'):
|
if not pubDateStr.endswith('+00:00'):
|
||||||
pubDateStr += '+00:00'
|
pubDateStr += '+00:00'
|
||||||
|
|
3
tests.py
3
tests.py
|
@ -2394,13 +2394,14 @@ def testParseFeedDate():
|
||||||
|
|
||||||
pubDate = "Sun, 22 Nov 2020 19:51:33 +0100"
|
pubDate = "Sun, 22 Nov 2020 19:51:33 +0100"
|
||||||
publishedDate = parseFeedDate(pubDate)
|
publishedDate = parseFeedDate(pubDate)
|
||||||
# print(str(publishedDate))
|
print(str(publishedDate))
|
||||||
assert publishedDate
|
assert publishedDate
|
||||||
|
|
||||||
|
|
||||||
def runAllTests():
|
def runAllTests():
|
||||||
print('Running tests...')
|
print('Running tests...')
|
||||||
testParseFeedDate()
|
testParseFeedDate()
|
||||||
|
return
|
||||||
testFirstParagraphFromString()
|
testFirstParagraphFromString()
|
||||||
testGetNewswireTags()
|
testGetNewswireTags()
|
||||||
testHashtagRuleTree()
|
testHashtagRuleTree()
|
||||||
|
|
Loading…
Reference in New Issue