From 586549a7f9a3a042a44f667c64d6b250d52b93a1 Mon Sep 17 00:00:00 2001 From: tiyn Date: Sun, 21 Apr 2024 02:14:11 +0200 Subject: [PATCH] added changable timezone for rss feed --- src/config.py | 3 +++ src/content.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config.py b/src/config.py index 274cda3..d486082 100644 --- a/src/config.py +++ b/src/config.py @@ -21,3 +21,6 @@ MAIL = "dummy@mail.com" # Directory to store entries in ENTRY_DIR = "templates/entry" + +# Set the timezone of your blog +TIMEZONE = "+0000" diff --git a/src/content.py b/src/content.py index dac1086..bc92506 100644 --- a/src/content.py +++ b/src/content.py @@ -15,6 +15,7 @@ WEBSITE = config.WEBSITE ENTRY_DIR = config.ENTRY_DIR LANGUAGE = config.LANGUAGE LOCAL = "de_DE.UTF-8" if LANGUAGE == "de-de" else "en_US.UTF-8" +TIMEZONE = config.TIMEZONE locale.setlocale(locale.LC_TIME, LOCAL) @@ -184,7 +185,6 @@ def get_rss_string(): Returns: string: rss-string of everything that is in the ENTRY_DIR. """ - locale.setlocale(locale.LC_TIME, "en_US.UTF-8") path_ex = ENTRY_DIR content_string = "" if path.exists(path_ex): @@ -202,9 +202,11 @@ def get_rss_string(): content_string += "" + title + "\n" content_string += "" + WEBSITE + \ "/index.html#" + filename + "\n" + locale.setlocale(locale.LC_TIME, "en_US.UTF-8") content_string += "" + \ datetime.fromtimestamp(os.path.getmtime(file)).strftime( - "%a, %d %b %Y %H:%M:%S") + " +0100\n" + "%a, %d %b %Y %H:%M:%S") + " " + TIMEZONE + "\n" + locale.setlocale(locale.LC_TIME, LOCAL) content_string += "\n\n\n\n\n" html_string = "" for line in text: @@ -212,7 +214,6 @@ def get_rss_string(): content_string += absolutize_html(html_string) content_string += "\n\n]]>\n\n" content_string += "\n" - locale.setlocale(locale.LC_TIME, LOCAL) return content_string