Füge Zeitzonenunterstützung für Veröffentlichungs- und Erstellungsdaten hinzu und optimiere die RFC 2822 Datumsformatierung.

This commit is contained in:
2025-07-06 11:31:59 +02:00
parent 85cd600630
commit d205ec25ff

View File

@ -135,7 +135,8 @@ class LocalPodcastGenerator:
file_size = file_path.stat().st_size
# Änderungsdatum als Veröffentlichungsdatum
pub_date = datetime.fromtimestamp(file_path.stat().st_mtime)
from datetime import timezone
pub_date = datetime.fromtimestamp(file_path.stat().st_mtime, tz=timezone.utc)
return {
'title': title,
@ -281,16 +282,9 @@ class LocalPodcastGenerator:
def format_rfc2822_date(self, dt):
"""Formatiert ein Datum im RFC 2822 Format für RSS."""
# RFC 2822 Format: "Wed, 02 Oct 2002 08:00:00 EST"
# Verwende englische Wochentag/Monat-Namen und GMT
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
weekday = weekdays[dt.weekday()]
month = months[dt.month - 1]
return f"{weekday}, {dt.day:02d} {month} {dt.year} {dt.hour:02d}:{dt.minute:02d}:{dt.second:02d} GMT"
# RFC 2822 Format: "Wed, 02 Oct 2002 08:00:00 +0000"
# Verwende die eingebaute strftime Funktion für korrekte Formatierung
return dt.strftime('%a, %d %b %Y %H:%M:%S +0000')
def format_duration(self, seconds):
"""Formatiert die Dauer in HH:MM:SS Format."""
@ -352,7 +346,8 @@ Ich spezialisiere mich auf House Music, die mehr als nur Beats bietet sie er
# Wichtig: lastBuildDate für bessere Erkennung von Updates (RFC 2822 konform)
# Verwende aktuelles Datum für die Feed-Erstellung
current_date = datetime.now()
from datetime import timezone
current_date = datetime.now(timezone.utc)
last_build = ET.SubElement(channel, "lastBuildDate")
last_build.text = self.format_rfc2822_date(current_date)