From 1811298962324b4c37f6428e8c7488da86d4a386 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 11 Oct 2019 17:54:55 +0100 Subject: [PATCH] Parse time zone --- inbox.py | 6 ++---- webinterface.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/inbox.py b/inbox.py index bf07fdee..bb8b55a8 100644 --- a/inbox.py +++ b/inbox.py @@ -164,7 +164,7 @@ def inboxPermittedMessage(domain: str,messageJson: {},federationList: []) -> boo return True -def validPublishedDate(published) -> bool: +def validPublishedDate(published: str) -> bool: currTime=datetime.datetime.utcnow() pubDate=datetime.datetime.strptime(published,"%Y-%m-%dT%H:%M:%SZ") daysSincePublished = (currTime - pubTime).days @@ -1378,9 +1378,7 @@ def inboxUpdateCalendar(baseDir: str,handle: str,postJsonObject: {}) -> None: if not tagDict.get('startTime'): continue # get the year and month from the event - eventTime= \ - datetime.datetime.strptime(tagDict['startTime'], \ - "%Y-%m-%dT%H:%M:%SZ") + eventTime=datetime.datetime.strptime(tagDict['startTime'],"%Y-%m-%dT%H:%M:%S%z") eventYear=int(eventTime.strftime("%Y")) eventMonthNumber=int(eventTime.strftime("%m")) diff --git a/webinterface.py b/webinterface.py index 0214565e..297ab9e2 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2785,7 +2785,7 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumb if tag.get('startTime'): eventTime= \ datetime.strptime(tag['startTime'], \ - "%Y-%m-%dT%H:%M:%SZ") + "%Y-%m-%dT%H:%M:%S%z") if int(eventTime.strftime("%Y"))==year and \ int(eventTime.strftime("%m"))==monthNumber: dayOfMonth=str(int(eventTime.strftime("%d")))