From 6a01fc439e391b20349679a8b09feb7ed4f61b85 Mon Sep 17 00:00:00 2001 From: pictuga Date: Fri, 20 Mar 2020 12:30:42 +0100 Subject: [PATCH] feeds: better handle "empty" datetime --- morss/feeds.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index d951fce..f3f8d46 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -469,7 +469,10 @@ class ParserHTML(ParserXML): def parse_time(value): - if isinstance(value, basestring): + if value is None or value == 0: + return None + + elif isinstance(value, basestring): if re.match(r'^[0-9]+$', value): return datetime.fromtimestamp(int(value), tz.UTC) @@ -483,7 +486,7 @@ def parse_time(value): return value else: - return False + return None class ParserJSON(ParserBase):