summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2022-05-10 00:18:31 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2022-05-10 00:18:31 +0200
commit187bc63d23ef3aca9089f106daa7252d61a7d084 (patch)
treefa84b5b8f88c80278e2957f26f99516a8f8340ee
parent8e99adefe88de9caf51ad13a847149da5eedb1d8 (diff)
downloadquatuorbellefeuille.com-187bc63d23ef3aca9089f106daa7252d61a7d084.tar.xz
Fix date handling in feeds
Cf. comment in new zoned_datetime function. Also fix a concert pubDate.
-rwxr-xr-xadmin/feeds/build-feed.py34
-rw-r--r--admin/feeds/concerts-pubdates.json2
-rw-r--r--en/feed.xml17
-rw-r--r--feed.xml17
4 files changed, 34 insertions, 36 deletions
diff --git a/admin/feeds/build-feed.py b/admin/feeds/build-feed.py
index e010b63..6c95161 100755
--- a/admin/feeds/build-feed.py
+++ b/admin/feeds/build-feed.py
@@ -18,25 +18,21 @@ from helpers import (
)
-# TODO: handle timezones correctly.
-# Places to disambiguate:
-#
-# - concerts.in:
-# either add the zone explicitly, or deduce it from the place,
-# assuming all times in concerts.in are local times.
-#
-# - concerts-pubdates.json:
-# just add the zone explicitly.
-#
-# Until then, assume all these "naive times" describe the same timezone
-# (CET/CEST).
-
-
-TIMEZONE = datetime.now().astimezone().tzinfo
-NOW = datetime.now(tz=TIMEZONE)
-DATE_FORMAT = '%-d %b %Y %H:%M %z'
+def zoned_datetime(dt):
+ # Assume that whoever wrote the naive timestamp that this datetime
+ # was generated from had the same local time we do.
+
+ # Note: even if we assume that all timestamps in concerts.in and
+ # concerts-pubdates.json come from the same "zone" (Europe/Paris),
+ # the *time offset* can differ (CET vs CEST), so we can't just
+ # define a global TIMEZONE = datetime.now().tzinfo and slap that
+ # on every datetime.
+
+ return dt.replace(tzinfo=dt.astimezone().tzinfo)
-# TODO: add item pubDate
+
+NOW = zoned_datetime(datetime.now())
+DATE_FORMAT = '%-d %b %Y %H:%M %z'
LOCALIZED_TEXT = {
@@ -132,7 +128,7 @@ def generate_concert(concert, concerts_url, pubdates, lang):
pubdate_str = pubdates[concert.time.isoformat(timespec='minutes')]
if pubdate_str is not None:
- pubdate = datetime.fromisoformat(pubdate_str).replace(tzinfo=TIMEZONE)
+ pubdate = zoned_datetime(datetime.fromisoformat(pubdate_str))
item.append(E.pubDate(pubdate.strftime(DATE_FORMAT)))
return item
diff --git a/admin/feeds/concerts-pubdates.json b/admin/feeds/concerts-pubdates.json
index 4232ed7..b3dafd9 100644
--- a/admin/feeds/concerts-pubdates.json
+++ b/admin/feeds/concerts-pubdates.json
@@ -11,5 +11,5 @@
"2021-10-28T18:00": null,
"2021-12-12T16:00": "2021-11-23T23:28",
"2021-12-31T20:00": null,
- "2022-05-07T17:00": null
+ "2022-05-07T20:30": "2022-04-03T20:04"
}
diff --git a/en/feed.xml b/en/feed.xml
index b427889..bcb65e5 100644
--- a/en/feed.xml
+++ b/en/feed.xml
@@ -8,8 +8,8 @@
<url>https://quatuorbellefeuille.com/images/logo.svg</url>
<link>https://quatuorbellefeuille.com/en/concerts.html</link>
</image>
- <lastBuildDate>23 Feb 2022 20:28 +0100</lastBuildDate>
- <pubDate>23 Feb 2022 20:28 +0100</pubDate>
+ <lastBuildDate>10 May 2022 00:17 +0200</lastBuildDate>
+ <pubDate>10 May 2022 00:17 +0200</pubDate>
<language>en</language>
<item>
<title>October 5 2019 in Le Buisson de Cadouin</title>
@@ -211,17 +211,18 @@
<link>https://quatuorbellefeuille.com/en/concerts.html#concert-2022-05-07</link>
<description><![CDATA[
<p>Saturday May 7, 2022</p>
- <p>05:00 pm</p>
+ <p>08:30 pm</p>
<p>Le Pianorium<br/>4 rue du Stade<br/>35190 Saint-Domineuc</p>
<ol>
- <li>Haydn 1<sup>st</sup> movement of quartet Op. 76 No. 1</li>
- <li>Mendelssohn quartet No. 3, Op. 44 No. 1</li>
- <li>Schubert quartettsatz</li>
- <li>Shostakovich quartet</li>
+ <li>Haydn quartet Op. 76 No. 1</li>
+ <li>Shostakovich quartet No. 7</li>
+ <li>Schubert quartet No. 14, Death and the Maiden</li>
</ol>
- <p>Free admission, subject to the number of available places.</p>
+ <p>Price for admission: €12; reduced rate: €6. See conditions on <a href="https://pianorium.fr/infos-partiques/" target="_blank">pianorium.fr</a>
+ </p>
<p>Contact <a href="mailto:info@pianorium.fr">info@pianorium.fr</a> to make a reservation.</p>
]]></description>
+ <pubDate>3 Apr 2022 20:04 +0200</pubDate>
</item>
</channel>
</rss> \ No newline at end of file
diff --git a/feed.xml b/feed.xml
index 026e284..63dcb6a 100644
--- a/feed.xml
+++ b/feed.xml
@@ -8,8 +8,8 @@
<url>https://quatuorbellefeuille.com/images/logo.svg</url>
<link>https://quatuorbellefeuille.com/concerts.html</link>
</image>
- <lastBuildDate>23 Feb 2022 20:27 +0100</lastBuildDate>
- <pubDate>23 Feb 2022 20:27 +0100</pubDate>
+ <lastBuildDate>10 May 2022 00:17 +0200</lastBuildDate>
+ <pubDate>10 May 2022 00:17 +0200</pubDate>
<language>fr</language>
<item>
<title>5 octobre 2019 à Le Buisson de Cadouin</title>
@@ -211,18 +211,19 @@
<link>https://quatuorbellefeuille.com/concerts.html#concert-2022-05-07</link>
<description><![CDATA[
<p>Samedi 7 mai 2022</p>
- <p>17h00</p>
+ <p>20h30</p>
<p>Le Pianorium<br/>4 rue du Stade<br/>35190 Saint-Domineuc</p>
<ol>
- <li>Haydn 1<sup>er</sup> mouvement du quatuor op.76 n°1</li>
- <li>Mendelssohn quatuor n°3, op.44 n°1</li>
- <li>Schubert quartettsatz</li>
- <li>Chostakovitch quatuor</li>
+ <li>Haydn quatuor op.76 n°1</li>
+ <li>Chostakovitch quatuor n°7</li>
+ <li>Schubert quatuor n°14, La Jeune fille et la Mort</li>
</ol>
- <p>Entrée libre dans la limite des places disponibles.</p>
+ <p>Prix de la place : 12€ ; tarif réduit : 6€. Voir conditions sur <a href="https://pianorium.fr/infos-partiques/" target="_blank">pianorium.fr</a>
+ </p>
<p>Réservation possible à l'adresse suivante : <a href="mailto:info@pianorium.fr">info@pianorium.fr</a>
</p>
]]></description>
+ <pubDate>3 Apr 2022 20:04 +0200</pubDate>
</item>
</channel>
</rss> \ No newline at end of file