How to match dateuilts.rrule and python icalendar

I am dealing with some problems.

I have an ical event.

BEGIN:VEVENT UID:Event/termine/gps/ akt@portal.augusta.de DTSTART;TZID=CET:20150529T190000 DTEND;TZID=CET:20150529T220000 CATEGORIES:Arbeitsgruppe DTSTAMP:20110620T075538Z EXDATE;TZID=CET:20151225T190000 LAST-MODIFIED:20150424T201707Z LOCATION:Vereinsrรคume des Augsburger Computer Forum eV PRIORITY:5 RRULE:FREQ=MONTHLY;BYDAY=-1FR SUMMARY:GPS-Arbeitsgruppe URL:https://www.augusta.de/termine/gps END:VEVENT 

As you can see, RRule repeats this event every last Friday of the month.

I analyzed this with icalendar.

I use:

 start = iobj.get( 'DTSTART' ).dt rrset = rruleset() rrule = iobj.get( 'RRULE' ) exdate = iobj.get( 'EXDATE' ) rrset.rrule( rrule.rrulestr( rule.to_ical(), dtstart = start ) ) for edate in exdate.dts : rrset.exdate( edate.dt ) 

Everything still works great.

When I try to get the following answer of 10 dates:

 list(rrset)[:10] 

I get:

 [datetime.datetime(2015, 5, 29, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 6, 26, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 7, 31, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 8, 28, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 9, 25, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 10, 30, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 11, 27, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2015, 12, 25, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2016, 1, 29, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>), datetime.datetime(2016, 2, 26, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>)] 

Which looks at first glance, but with a deeper inspection, the problem starts on October 30, daylight saving time ends on October 25, but the tzinfo of the datetime object is still "DstTzInfo" CET 'CEST + 2: 00: 00 DST "

The second problem is that December 25th is on this list instead of the missing pointer in EXDATE. The problematic seams that should be tatami when parsing the rule for the expiration of summer time are calculated correctly, and therefore the shutter speed 19: 00: 00 + 01: 00 does not correspond to the estimated repetition time 19: 00: 00 + 02: 00.

Am I doing something wrong?

Converting everyone to UTC and processing there does not help, because 17:00:00 UTC does not coincide with 18:00:00 UTC.

+6
source share

Source: https://habr.com/ru/post/988173/


All Articles