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

Open
ieb opened this Issue Oct 17, 2012 · 3 comments

Projects

None yet

3 participants

@ieb

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

Partial solution is to do
Alarm.ignore_exceptions = True

before starting the parse.

@fsiler

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

@thet
Plone Collective member

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

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