diff options
| author | erdgeist <erdgeist@bauklotz.local> | 2009-03-18 21:08:35 +0100 |
|---|---|---|
| committer | erdgeist <erdgeist@bauklotz.local> | 2009-03-18 21:08:35 +0100 |
| commit | f1f1fddf17161222617ba7b658e5da8b671960fa (patch) | |
| tree | ed42e03f229439a1977b201e411a2b736b170a45 /lib | |
| parent | db6f0a7554dbebe2c9bb118cc40736b6c148c6c5 (diff) | |
Add a duration parser to libical wrapper
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/chaos_calendar/ical_occurrences.c | 12 | ||||
| -rw-r--r-- | lib/chaos_calendar/ical_occurrences.i | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/chaos_calendar/ical_occurrences.c b/lib/chaos_calendar/ical_occurrences.c index 6515451..e59c1ed 100644 --- a/lib/chaos_calendar/ical_occurrences.c +++ b/lib/chaos_calendar/ical_occurrences.c | |||
| @@ -62,3 +62,15 @@ VALUE occurrences( VALUE dtstart, VALUE dtend, char *rrule ) { | |||
| 62 | icalrecur_iterator_free(ritr); | 62 | icalrecur_iterator_free(ritr); |
| 63 | return occurr; | 63 | return occurr; |
| 64 | } | 64 | } |
| 65 | |||
| 66 | VALUE duration_to_fixnum( char * duration ) { | ||
| 67 | icalerror_clear_errno(); | ||
| 68 | icalerror_set_error_state( ICAL_MALFORMEDDATA_ERROR, ICAL_ERROR_NONFATAL); | ||
| 69 | |||
| 70 | struct icaldurationtype dur_struct = icaldurationtype_from_string( duration ); | ||
| 71 | |||
| 72 | if( icaldurationtype_is_bad_duration( dur_struct ) ) | ||
| 73 | rb_raise(rb_eArgError, "Malformed Duration"); | ||
| 74 | |||
| 75 | return LONG2FIX(icaldurationtype_as_int( dur_struct )); | ||
| 76 | } | ||
diff --git a/lib/chaos_calendar/ical_occurrences.i b/lib/chaos_calendar/ical_occurrences.i index 3f87628..1e91701 100644 --- a/lib/chaos_calendar/ical_occurrences.i +++ b/lib/chaos_calendar/ical_occurrences.i | |||
| @@ -2,5 +2,5 @@ | |||
| 2 | 2 | ||
| 3 | %inline { | 3 | %inline { |
| 4 | VALUE occurrences( VALUE dtstart, VALUE dtend, char * rrule ); | 4 | VALUE occurrences( VALUE dtstart, VALUE dtend, char * rrule ); |
| 5 | VALUE duration_to_fixnum( char * duration ); | ||
| 5 | } | 6 | } |
| 6 | |||
