From 187bc63d23ef3aca9089f106daa7252d61a7d084 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 10 May 2022 00:18:31 +0200 Subject: Fix date handling in feeds Cf. comment in new zoned_datetime function. Also fix a concert pubDate. --- admin/feeds/build-feed.py | 34 +++++++++++++++------------------- admin/feeds/concerts-pubdates.json | 2 +- en/feed.xml | 17 +++++++++-------- feed.xml | 17 +++++++++-------- 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 @@ https://quatuorbellefeuille.com/images/logo.svg https://quatuorbellefeuille.com/en/concerts.html - 23 Feb 2022 20:28 +0100 - 23 Feb 2022 20:28 +0100 + 10 May 2022 00:17 +0200 + 10 May 2022 00:17 +0200 en October 5 2019 in Le Buisson de Cadouin @@ -211,17 +211,18 @@ https://quatuorbellefeuille.com/en/concerts.html#concert-2022-05-07 Saturday May 7, 2022

-

05:00 pm

+

08:30 pm

Le Pianorium
4 rue du Stade
35190 Saint-Domineuc

    -
  1. Haydn 1st movement of quartet Op. 76 No. 1
  2. -
  3. Mendelssohn quartet No. 3, Op. 44 No. 1
  4. -
  5. Schubert quartettsatz
  6. -
  7. Shostakovich quartet
  8. +
  9. Haydn quartet Op. 76 No. 1
  10. +
  11. Shostakovich quartet No. 7
  12. +
  13. Schubert quartet No. 14, Death and the Maiden
-

Free admission, subject to the number of available places.

+

Price for admission: €12; reduced rate: €6. See conditions on pianorium.fr +

Contact info@pianorium.fr to make a reservation.

]]>
+ 3 Apr 2022 20:04 +0200
\ 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 @@ https://quatuorbellefeuille.com/images/logo.svg https://quatuorbellefeuille.com/concerts.html - 23 Feb 2022 20:27 +0100 - 23 Feb 2022 20:27 +0100 + 10 May 2022 00:17 +0200 + 10 May 2022 00:17 +0200 fr 5 octobre 2019 à Le Buisson de Cadouin @@ -211,18 +211,19 @@ https://quatuorbellefeuille.com/concerts.html#concert-2022-05-07 Samedi 7 mai 2022

-

17h00

+

20h30

Le Pianorium
4 rue du Stade
35190 Saint-Domineuc

    -
  1. Haydn 1er mouvement du quatuor op.76 n°1
  2. -
  3. Mendelssohn quatuor n°3, op.44 n°1
  4. -
  5. Schubert quartettsatz
  6. -
  7. Chostakovitch quatuor
  8. +
  9. Haydn quatuor op.76 n°1
  10. +
  11. Chostakovitch quatuor n°7
  12. +
  13. Schubert quatuor n°14, La Jeune fille et la Mort
-

Entrée libre dans la limite des places disponibles.

+

Prix de la place : 12€ ; tarif réduit : 6€. Voir conditions sur pianorium.fr +

Réservation possible à l'adresse suivante : info@pianorium.fr

]]>
+ 3 Apr 2022 20:04 +0200
\ No newline at end of file -- cgit v1.2.3