Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > iCalendar module?

Reply
Thread Tools

iCalendar module?

 
 
hymie!
Guest
Posts: n/a
 
      05-23-2013
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 http://www.velocityreviews.com/forums/(E-Mail Removed)
-------------------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Peter J. Holzer
Guest
Posts: n/a
 
      05-24-2013
On 2013-05-23 19:50, hymie! <(E-Mail Removed)> wrote:
> 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


--
_ | Peter J. Holzer | Fluch der elektronischen Textverarbeitung:
|_|_) | Sysadmin WSR | Man feilt solange an seinen Text um, bis
| | | (E-Mail Removed) | die Satzbestandteile des Satzes nicht mehr
__/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel
 
Reply With Quote
 
 
 
 
hymie!
Guest
Posts: n/a
 
      05-28-2013
In our last episode, the evil Dr. Lacto had captured our hero,
"Peter J. Holzer" <(E-Mail Removed)>, who said:
>On 2013-05-23 19:50, hymie! <(E-Mail Removed)> wrote:
>> 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 Removed)
-------------------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python libraries for iCalendar, which one to use? tinnews@isbd.co.uk Python 0 05-14-2008 02:17 PM
iCalendar problem Johannes ASP .Net 0 02-10-2006 11:12 AM
[ANN] iCalendar package 0.9 Max M Python 2 01-18-2005 09:41 AM
library for writing / reading iCalendar files Ksenia Marasanova Python 0 10-20-2004 08:37 PM
API for RFC 2445 iCalendar Stefan Neuhaus Java 0 12-19-2003 09:38 AM



Advertisments