From c2e67d2e377ac9fcef4efdd7e803f438255770a6 Mon Sep 17 00:00:00 2001 From: Seele <48525679+Seele0oO@users.noreply.github.com> Date: Fri, 10 Feb 2023 21:01:23 +0800 Subject: [PATCH] add different tz support the unit test is pass,but I don't test it as a python package. --- tgarchive/__init__.py | 1 + tgarchive/build.py | 5 ++++- tgarchive/example/config.yaml | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tgarchive/__init__.py b/tgarchive/__init__.py index dc67f22..4c7dbaa 100644 --- a/tgarchive/__init__.py +++ b/tgarchive/__init__.py @@ -32,6 +32,7 @@ "rss_feed_entries": 100, "publish_dir": "site", + "publish_timezone": "America/New_York", "site_url": "https://mysite.com", "static_dir": "static", "telegram_url": "https://t.me/{id}", diff --git a/tgarchive/build.py b/tgarchive/build.py index 2dc971b..779deff 100644 --- a/tgarchive/build.py +++ b/tgarchive/build.py @@ -10,6 +10,7 @@ from feedgen.feed import FeedGenerator from jinja2 import Template +import pytz from .db import User, Message @@ -143,7 +144,9 @@ def _build_rss(self, messages, rss_file, atom_file): e = f.add_entry() e.id(url) e.title("@{} on {} (#{})".format(m.user.username, m.date, m.id)) - e.published(m.date.replace(tzinfo=timezone.utc)) + # e.published(m.date.replace(tzinfo=timezone.utc)) + # e.published(m.date.replace(tzinfo=self.config["publish_timezone"])) + e.published(m.date.replace(tzinfo=pytz.utc).astimezone(pytz.timezone(self.config["publish_timezone"]))) e.link({"href": url}) media_mime = "" diff --git a/tgarchive/example/config.yaml b/tgarchive/example/config.yaml index 7d840b5..30de625 100644 --- a/tgarchive/example/config.yaml +++ b/tgarchive/example/config.yaml @@ -50,6 +50,7 @@ fetch_wait: 5 fetch_limit: 0 publish_dir: "site" +publish_timezone: "America/New_York" static_dir: "static" per_page: 500 show_day_index: True