Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yearly repeating events raise an error #47

Closed
ndw opened this issue Mar 15, 2019 · 4 comments · Fixed by #133
Closed

Yearly repeating events raise an error #47

ndw opened this issue Mar 15, 2019 · 4 comments · Fixed by #133

Comments

@ndw
Copy link
Collaborator

ndw commented Mar 15, 2019

Consider this fragment:

RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20190328
DTEND;VALUE=DATE:20170330
DTSTART;VALUE=DATE:20170329

When icalevents loads this event, it will normalize the date into a datetime. But when dateutil.rrule is called subsequently, it will object:

RRULE UNTIL values must be specified in UTC when DTSTART is timezone-aware

Unfortunately, there are several places where start and end times are compared and the possibility of a mixture of date and datetime objects isn't handled.

@Currywurst
Copy link

Currywurst commented Mar 29, 2019

I got this too and fixed it by adding few lines after event.all_day and before try: event.location in the file icalparser.py:

event.all_day = type(component.get('dtstart').dt) is date

`

if component.get('rrule'):

    event.recurring = True
    if( component.get('rrule').get('until') ):
        iIndexListUntil = 0
        for x in component.get('rrule').get('until'):
            currentUntil = component.get('rrule').get('until')[iIndexListUntil]
            if not hasattr(currentUntil, 'tzinfo'):
                component.get('rrule').get('until')[iIndexListUntil] = normalize( currentUntil, tz=tz )
            iIndexListUntil += 1

`
try:
event.location = str(component.get('location'))
except UnicodeEncodeError as e:
event.location = str(component.get('location').encode('utf-8'))

So it adds timezone informations if until does not have one

tdaff added a commit to tdaff/icalevents that referenced this issue Apr 2, 2019
Since DTSTART is always given tzinfo, any UNTIL in an RRULE
must be tz-aware and in UTC.

See: jazzband#47
@kujiy
Copy link

kujiy commented Jul 22, 2019

Weekly would occur the same also

DTSTART;VALUE=DATE:20190706
DTEND;VALUE=DATE:20190713
RRULE:FREQ=WEEKLY;INTERVAL=5;BYDAY=SA

I haven't looked deeply yet but just let me take a memo.

@cancan101
Copy link

This still seems to be an issue even on 0.1.25:
With this rule string:

FREQ=WEEKLY;UNTIL=20200627;BYDAY=MO,WE;WKST=SU

@cancan101
Copy link

I ended up using:

        def fix_rule(rule):
            if 'UNTIL' in rule:
                rule['UNTIL'] = [normalize(r, tz=tz) for r in rule['UNTIL']]
            return rule

        # If dtstart is a datetime, make sure it's in a timezone.
        rdtstart = component['dtstart'].dt
        if type(rdtstart) is datetime:
            rdtstart = normalize(rdtstart, tz=tz)
            rrules = [fix_rule(x) for x in rrules]```

capuanob pushed a commit to ennamarie19/icalevents that referenced this issue Mar 6, 2023
Since DTSTART is always given tzinfo, any UNTIL in an RRULE
must be tz-aware and in UTC.

See: jazzband#47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants