Question

I'm trying to import ical data to one of my Django apps. But it fail to consider DST (I think) so it show the time one hour wrong. If think this worked during winter time. This is a sample of importing the data:

In [1]: from events.models import Events

In [2]: from icalendar import Calendar

In [3]: cal = Calendar.from_ical(open('/tmp/test.ics', 'rb').read())
20130612T183000
20130612T193000

In [4]: from_ical_dt = cal.walk()[1].get('dtstart').dt  # Get first entry

In [5]: from_ical_dt
Out[5]: datetime.datetime(2013, 6, 12, 18, 30, tzinfo=<DstTzInfo 'Europe/Stockholm' CET+1:00:00 STD>)

In [6]: new_event = Events(dtstart=from_ical_dt, title=u'testevent')

In [7]: new_event.save()

In [8]: new_event.dtstart
Out[8]: datetime.datetime(2013, 6, 12, 18, 30, tzinfo=<DstTzInfo 'Europe/Stockholm' CET+1:00:00 STD>)

This event is meant to take place at 18:30. So far so good, I think! The ical-module seems to import it correctly. At summer Sweden is +1 UTC and in winter +2 UTC (it's summer time now).

I also think Django saves it correctly(?) as 17:30 UTC.

In [9]: for e in Events.objects.all():
   ....:     print e.dtstart, e.title
   ....:     
2013-06-12 17:30:00+00:00 testevent

But yet, in the admin view of my application this comes out as 19:30:

View of admin interface

This is some of the lines from my settings.py:

TIME_ZONE = 'Europe/Stockholm'
USE_TZ = True

Where lays the problem? Why isn't Django showing this as 18.30? Both my actual application template and the admin interface is off with one hour.

Was it helpful?

Solution

Answer is here: https://code.djangoproject.com/ticket/20602

bla bla fill up so SO will let me submit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top