From 9accbf4456638bc95cf58e375e3717be4bc4b10e Mon Sep 17 00:00:00 2001 From: manetta Date: Mon, 21 Feb 2022 15:30:36 +0100 Subject: [PATCH] trying to get around the pytz timezone warning The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html --- feedtools.py | 8 +++++--- requirements.txt | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/feedtools.py b/feedtools.py index e2dc973..935744f 100644 --- a/feedtools.py +++ b/feedtools.py @@ -1,7 +1,8 @@ import feedparser from simpledatabase import SimpleDatabase import json -from datetime import date, timedelta +from datetime import datetime, date, timedelta +from backports.zoneinfo import ZoneInfo def update(): """ Update all feeds """ @@ -14,6 +15,7 @@ def update(): for x, feed in enumerate(feeds): parsed = feedparser.parse(feed) + # print(parsed) x = str(x) tmp['feeds'][x] = {} @@ -26,7 +28,7 @@ def update(): year = post['published_parsed'][0] month = post['published_parsed'][1] day = post['published_parsed'][2] - post_date = date(year, month, day) + post_date = datetime(year, month, day, tzinfo=ZoneInfo("Europe/Amsterdam")) if not str(post_date) in tmp['all_posts_sorted']: tmp['all_posts_sorted'][str(post_date)] = [] @@ -82,7 +84,7 @@ def today(): return request def past(days): - """ Collect posts from this week """ + """ Collect posts from a number of past """ db = load() point_in_the_past = date.today() - timedelta(int(days)) request = [] diff --git a/requirements.txt b/requirements.txt index 90fe8cd..d48f211 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ flask feedparser pathlib -Flask-APScheduler \ No newline at end of file +Flask-APScheduler +backports.zoneinfo \ No newline at end of file