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

Alarm Trigger field from Apple OSX iCal breaks with Value Error #69

Closed
ieb opened this issue Oct 17, 2012 · 5 comments
Closed

Alarm Trigger field from Apple OSX iCal breaks with Value Error #69

ieb opened this issue Oct 17, 2012 · 5 comments

Comments

@ieb
Copy link

ieb commented Oct 17, 2012

When
BEGIN:VALARM
X-WR-ALARMUID:5809BC21-BA9F-4CC8-A0D2-46AD04002214
TRIGGER:P1501W3DT7H28M16S
ATTACH;VALUE=URI:
ACTION:AUDIO
END:VALARM

is parsed with Calendar.from_string(...) it generates
raise ValueError('Invalid iCalendar duration: %s' % ical)
ValueError: Invalid iCalendar duration: P1501W3DT7H28M16S

4.3.6 Duration

Value Name: DURATION

Purpose: This value type is used to identify properties that contain
a duration of time.

Formal Definition: The value type is defined by the following
notation:

 dur-value  = (["+"] / "-") "P" (dur-date / dur-time / dur-week)

 dur-date   = dur-day [dur-time]
 dur-time   = "T" (dur-hour / dur-minute / dur-second)
 dur-week   = 1*DIGIT "W"
 dur-hour   = 1*DIGIT "H" [dur-minute]
 dur-minute = 1*DIGIT "M" [dur-second]
 dur-second = 1*DIGIT "S"
 dur-day    = 1*DIGIT "D"

Description: If the property permits, multiple "duration" values are
specified by a COMMA character (US-ASCII decimal 44) separated list
of values. The format is expressed as the [ISO 8601] basic format for
the duration of time. The format can represent durations in terms of
weeks, days, hours, minutes, and seconds.

IIUC the Applie iCal format is not to the spec since it splits up a
P1501W3D
&
T7H28M16S

T7H28M16S looks Ok

P1501W3D looks wrong.

1 Week 3 Days but what is the 150 ?

Is there any way to ignore the component if parsing the duration fails ?

@ieb
Copy link
Author

ieb commented Oct 17, 2012

Partial solution is to do
Alarm.ignore_exceptions = True

before starting the parse.

@fsiler
Copy link

fsiler commented Nov 20, 2012

If I can patch this will you take the pull request? Had same issue, pretty problematic, but the ignore_exceptions hack does work.

@thet
Copy link
Member

thet commented Nov 23, 2012

sure, pull requests are very welcome. please take a look at the CONTRIBUTING file https://github.com/collective/icalendar/blob/master/CONTRIBUTING.rst

@natashamm
Copy link
Contributor

I also can't reproduce this error (Note: from_string has been replaced with from_ical since then)

You can try it out:

from icalendar import Event


event_string = """
BEGIN:VALARM
X-WR-ALARMUID:5809BC21-BA9F-4CC8-A0D2-46AD04002214
TRIGGER:P1501W3DT7H28M16S
ATTACH;VALUE=URI:
ACTION:AUDIO
END:VALARM
"""

print(Event.from_ical(event_string))

Prints out the following without any errors:

VALARM({'X-WR-ALARMUID': vText('b'5809BC21-BA9F-4CC8-A0D2-46AD04002214''), 'TRIGGER': vDDDTypes(10510 days, 7:28:16, Parameters({})), 'ATTACH': '', 'ACTION': vText('b'AUDIO'')})

@niccokunzmann
Copy link
Member

The TRIGGER parses nicely now. Thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants