• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/iCal/H15-Jun-2013-581282

t/H15-Jun-2013-1,1821,129

ChangeLogH A D15-Jun-20131.7 KiB6539

LICENSEH A D15-Jun-201320.1 KiB384309

MANIFESTH A D15-Jun-20131.6 KiB5857

META.ymlH A D15-Jun-2013628 2928

Makefile.PLH A D15-Jun-2013730 2119

READMEH A D15-Jun-20136.4 KiB191155

README

1NAME
2    iCal::Parser - Parse iCalendar files into a data structure
3
4SYNOPSIS
5      use iCal::Parser
6
7      my $parser=iCal::Parser->new();
8      my $hash=$parser->parse($file);
9
10      $parser->parse($another_file);
11      my $combined=$parser->calendar;
12
13      my $combined=iCal::Parser->new->parse(@files);
14      my $combined=iCal::Parser->new->parse_files(@files);
15      my $combined=iCal::Parser->new->parse_strings(@strings);
16
17DESCRIPTION
18    This module processes iCalendar (vCalendar 2.0) files as specified in
19    RFC 2445 into a data structure. It handles recurrences (`RRULE's),
20    exclusions (`EXDATE's), event updates (events with a `RECURRENCE-ID'),
21    and nested data structures (`ATTENDEES' and `VALARM's). It currently
22    ignores the `VTIMEZONE', `VJOURNAL' and `VFREEBUSY' entry types.
23
24    The data structure returned is a hash like the following:
25
26        {
27          calendars=>[\%cal, ...],
28          events=>{yyyy=>{mm=>{dd}=>{UID=>\%event}}
29          todos=>[\%todo, ...]
30        }
31
32    That is, it contains an array of calendar hashes, a hash of events key
33    by `year=>month=>day=>eventUID', and an array of todos.
34
35    Calendars, events and todos are "rolled up" version os the hashes
36    returned from Text::vFile::asData, with dates replaced by `DateTime'
37    objects.
38
39    During parsing, events in the input calendar are expanded out into
40    multiple events, one per day covered by the event, as follows:
41
42    *   If the event is a one day "all day" event (in ical, the event is
43        24hrs long, starts at midnight on the day and ends a midnight of the
44        next day), it contains no `hour' field and the `allday' field is set
45        to `1'.
46
47    *   If the event is a recurrence (`RRULE'), one event per day is created
48        as per the `RRULE' specification.
49
50    *   If the event spans more than one day (the start and end dates are on
51        different days, but does not contain an `RRULE'), it is expanded
52        into multiple events, the first events end time is set to midnight,
53        subsequent events are set to start at midnight and end at midnight
54        the following day (same as an "allday" event, but the `allday' field
55        is not set), and the last days event is set to run from midnight to
56        the end time of the original multi-day event.
57
58    *   If the event is an update (it contains a `RECURRENCE-ID'), the
59        original event is updated. If the referenced event does not exist
60        (e.g., it was deleted after the update), then the event is added as
61        a new event.
62
63    An example of each hash is below.
64
65  Calendar Hash
66        {
67            'X-WR-CALNAME' => 'Test',
68            'index' => 1,
69            'X-WR-RELCALID' => '7CCE8555-3516-11D9-8A43-000D93C45D90',
70            'PRODID' => '-//Apple Computer\\, Inc//iCal 1.5//EN',
71            'CALSCALE' => 'GREGORIAN',
72            'X-WR-TIMEZONE' => 'America/New_York',
73            'X-WR-CALDESC' => 'My Test Calendar',
74            'VERSION' => '2.0'
75        }
76
77  Event Hash
78    Note that `hours' and `allday' are mutually exclusive in the actual
79    data. The `idref' field contains the `id' of the calendar the event came
80    from, which is useful if the hash was created from multiple calendars.
81
82        {
83            'SUMMARY' => 'overnight',
84            'hours' => '15.00',
85            'allday' => 1,
86            'UID' => '95CCBF98-3685-11D9-8CA5-000D93C45D90',
87            'idref' => '7CCE8555-3516-11D9-8A43-000D93C45D90',
88            'DTSTAMP' => \%DateTime,
89            'DTEND' => \%DateTime,
90            'DTSTART' => \%DateTime
91            'ATTENDEE' => [
92               {
93                  'CN' => 'Jay',
94                  'value' => 'mailto:jayl@my.server'
95               },
96              ],
97              'VALARM' => [
98                {
99                  'when' => \%DateTime,
100                  'SUMMARY' => 'Alarm notification',
101                  'ACTION' => 'EMAIL',
102                  'DESCRIPTION' => 'This is an event reminder',
103                  'ATTENDEE' => [
104                     {
105                       'value' => 'mailto:cpan@my.server'
106                     }
107                  ]
108               }
109             ],
110        }
111
112  Todo Hash
113        {
114            'URL' => 'mailto:me',
115            'SUMMARY' => 'todo 1',
116            'UID' => 'B78E68F2-35E7-11D9-9E64-000D93C45D90',
117            'idref' => '7CCE8555-3516-11D9-8A43-000D93C45D90',
118            'STATUS' => 'COMPLETED',
119            'COMPLETED' => \%DateTime,
120            'DTSTAMP' => \%DateTime,
121            'PRIORITY' => '9',
122            'DTSTART' => \%DateTime,
123            'DUE' => \%DateTime,
124            'DESCRIPTION' => 'not much',
125            'VALARM' => [
126               {
127                  'when' => \%DateTime,
128                  'ATTACH' => 'file://localhost/my-file',
129                  'ACTION' => 'PROCEDURE'
130               }
131            ],
132        },
133
134Methods
135  new(%opt_args)
136    Optional Arguments
137    start {yyymmdd|DateTime}
138        Only include events on or after `yyymmdd'. Defaults to Jan of this
139        year.
140
141    end {yyyymmdd|DateTime}
142        Only include events before `yyymmdd'.
143
144    no_events
145        Don't include events in the output (todos only).
146
147    no_todos
148        Don't include todos in the output (events only).
149
150    months n
151        DateTime::Sets (used for calculating recurrences) are limited to
152        approximately 200 entries. If an `end' date is not specified, the
153        `to' date is set to the `start' date plus this many months. The
154        default is 60.
155
156    tz (string|DateTime::TimeZone)
157        Use tz as timezone for date values. The default is 'local', which
158        will adjust the parsed dates to the current timezone.
159
160    debug
161        Set to non-zero for some debugging output during processing.
162
163  parse({file|file_handle}+)
164    Parse the input files or opened file handles and return the generated
165    hash.
166
167    This function can be called mutitple times and the calendars will be
168    merge into the hash, each event tagged with the unique id of its
169    calendar.
170
171  parse_files({file|file_handle}+)
172    Alias for `parse()'
173
174  parse_strings(string+)
175    Parse the input strings (each assumed to be a valid iCalendar) and
176    return the generated hash.
177
178AUTHOR
179    Rick Frankel, cpan@rickster.com
180
181COPYRIGHT
182    This program is free software; you can redistribute it and/or modify it
183    under the same terms as Perl itself.
184
185    The full text of the license can be found in the LICENSE file included
186    with this module.
187
188SEE ALSO
189    Text::vFile::asData, DateTime::Set, DateTime::Span, iCal::Parser::SAX
190
191