iCalendar module?

H

hymie!

Greetings.

I found this ruby script
cals = Icalendar.parse($<)
cals.each do |cal|
cal.events.each do |event|
puts "Organizer: #{event.organizer}"
puts "Event: #{event.summary}"
puts "Starts: #{event.dtstart.myformat} local time"
puts "Ends: #{event.dtend.myformat}"
puts "Location: #{event.location}"
puts "Contact: #{event.contacts}"
puts "Description:\n#{event.description}"
puts ""
end
end

and I was hoping to write something similar in perl.

The question is, can somebody recommend to me a module that I can use
to read iCal files? All of the modules that I see appear to handle
creating iCal files, but not reading them and outputting something
human-readable. Although it's likely that I missed it.

--hymie! http://lactose.homelinux.net/~hymie (e-mail address removed)
-------------------------------------------------------------------------------
 
P

Peter J. Holzer

I found this ruby script
cals = Icalendar.parse($<)
cals.each do |cal|
cal.events.each do |event|
puts "Organizer: #{event.organizer}"
puts "Event: #{event.summary}"
puts "Starts: #{event.dtstart.myformat} local time" [...]

and I was hoping to write something similar in perl.

The question is, can somebody recommend to me a module that I can use
to read iCal files? All of the modules that I see appear to handle
creating iCal files, but not reading them and outputting something
human-readable. Although it's likely that I missed it.

I have used Text::vFile::asData to convert iCal MIME parts to something
I can read. It handles all the v-type formats (vCalendar, vCard, ...),
but that flexibility makes it a bit cumbersome to use. Here's a snippet
from my script (whole script available on request if anyone wants it):

....
my $data = Text::vFile::asData->new->parse(\*STDIN);

my $vcalendar = $data->{objects}[0];
die "unexpected type $vcalendar->{type}" unless $vcalendar->{type} eq 'VCALENDAR';

my $vevent;
for (@{ $vcalendar->{objects} }) {
if ($_->{type} eq 'VEVENT') {
$vevent = $_;
last; # there can be only one (or so we hope)
}
}
die "no VEVENT found" unless $vevent;

print "Summary : $vevent->{properties}{SUMMARY}[0]{value}\n";
print "\n";
print "Begin : ", fmttime($vevent->{properties}{DTSTART}[0]{value}), "\n";
print "End : ", fmttime($vevent->{properties}{DTEND}[0]{value}), "\n";
print "\n";
....

hp
 
H

hymie!

In our last episode, the evil Dr. Lacto had captured our hero,
I found this ruby script
cals = Icalendar.parse($<)
cals.each do |cal|
cal.events.each do |event|
puts "Organizer: #{event.organizer}"
puts "Event: #{event.summary}"
puts "Starts: #{event.dtstart.myformat} local time" [...]

and I was hoping to write something similar in perl.
I have used Text::vFile::asData to convert iCal MIME parts to something
I can read. It handles all the v-type formats (vCalendar, vCard, ...),

...
my $data = Text::vFile::asData->new->parse(\*STDIN);

my $vcalendar = $data->{objects}[0];
die "unexpected type $vcalendar->{type}" unless $vcalendar->{type} eq
'VCALENDAR';

my $vevent;
for (@{ $vcalendar->{objects} }) {
if ($_->{type} eq 'VEVENT') {
$vevent = $_;
last; # there can be only one (or so we hope)
}
}
die "no VEVENT found" unless $vevent;

print "Summary : $vevent->{properties}{SUMMARY}[0]{value}\n";
print "\n";
print "Begin : ", fmttime($vevent->{properties}{DTSTART}[0]{value}), "\n";
print "End : ", fmttime($vevent->{properties}{DTEND}[0]{value}), "\n";
print "\n";

Perfect! Thank you very much.

--hymie! http://lactose.homelinux.net/~hymie (e-mail address removed)
-------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top