zs

Zeitungsschau rss to email converter
git clone git://r-36.net/zs
Log | Files | Refs | LICENSE

commit 3626c9f3dded687c9ef6be241306f401dea61e0b
parent eb1dfe87f3b96659a24e5c1c91b4623260ff24b0
Author: Christoph Lohmann <20h@r-36.net>
Date:   Mon,  4 Jun 2018 18:19:56 +0200

Add workaround for dateutil.parser warning about timezone.

Diffstat:
zeitungsschau/feed.py | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/zeitungsschau/feed.py b/zeitungsschau/feed.py @@ -9,6 +9,7 @@ from lxml import objectify from lxml import etree from datetime import datetime import dateutil.parser +from dateutil.tz import gettz import requests import hashlib import pytz @@ -17,10 +18,18 @@ import html import urllib.parse import socket import json +import pytz def parseiso(dstr, now): + def gettzinfo(zone, offset): + try: + return gettz(zone) + except: + return None + try: - return dateutil.parser.parse(str(dstr), default=now) + return dateutil.parser.parse(str(dstr), default=now, + tzinfos=gettzinfo) except ValueError: # Invalid time format. Could not be parsed. return now