Certains ical annoncent une heure UTC mais sont en fait des heures Europe/Pari

This commit is contained in:
Jean-Marie Favreau 2025-02-23 11:03:46 +01:00
parent ddf17fd0f4
commit 491ffa44ec
4 changed files with 29 additions and 1 deletions

View File

@ -145,6 +145,8 @@ def run_recurrent_import_internal(rimport, downloader, req_id):
extractor = ICALNoBusyExtractor()
elif rimport.processor == RecurrentImport.PROCESSOR.ICALNOVC:
extractor = ICALNoVCExtractor()
elif rimport.processor == RecurrentImport.PROCESSOR.ICALNAIVETZ:
extractor = ICALNaiveTimezone()
elif rimport.processor == RecurrentImport.PROCESSOR.LACOOPE:
extractor = lacoope.CExtractor()
elif rimport.processor == RecurrentImport.PROCESSOR.LACOMEDIE:

View File

@ -18,6 +18,7 @@ logger = get_task_logger(__name__)
class ICALExtractor(Extractor):
def __init__(self):
super().__init__()
self.naive_timezone = False
self.to_timezone = pytz.timezone("Europe/Paris")
@ -54,6 +55,7 @@ class ICALExtractor(Extractor):
if item is not None:
if isinstance(item, datetime):
if not self.naive_timezone:
item = self.to_timezone.normalize(item)
day = item.date()
time = item.time()
@ -290,3 +292,8 @@ class ICALNoVCExtractor(ICALExtractor):
image,
image_alt,
)
class ICALNaiveTimezone(ICALExtractor):
def __init__(self):
super().__init__()
self.naive_timezone = True

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.9 on 2025-02-23 10:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0148_alter_recurrentimport_source'),
]
operations = [
migrations.AlterField(
model_name='recurrentimport',
name='processor',
field=models.CharField(choices=[('ical', 'ical'), ('icalnobusy', 'ical no busy'), ('icalnovc', 'ical no VC'), ('ical naive tz', 'ical naive timezone'), ('lacoope', 'lacoope.org'), ('lacomedie', 'la comédie'), ('lefotomat', 'le fotomat'), ('lapucealoreille', "la puce à l'oreille"), ('Plugin wordpress MEC', 'Plugin wordpress MEC'), ('Facebook events', "Événements d'une page FB"), ('Billetterie CF', 'Billetterie Clermont-Ferrand'), ('arachnee', 'Arachnée concert'), ('rio', 'Le Rio'), ('raymonde', 'La Raymonde'), ('apidae', 'Agenda apidae tourisme'), ('iguana', 'Agenda iguana (médiathèques)'), ('Mille formes', 'Mille formes'), ('Amis cerises', 'Les Amis du Temps des Cerises'), ('Mobilizon', 'Mobilizon')], default='ical', max_length=20, verbose_name='Processor'),
),
]

View File

@ -2147,6 +2147,7 @@ class RecurrentImport(models.Model):
ICAL = "ical", _("ical")
ICALNOBUSY = "icalnobusy", _("ical no busy")
ICALNOVC = "icalnovc", _("ical no VC")
ICALNAIVETZ = "ical naive tz", _("ical naive timezone")
LACOOPE = "lacoope", _("lacoope.org")
LACOMEDIE = "lacomedie", _("la comédie")
LEFOTOMAT = "lefotomat", _("le fotomat")