From fbfdae266fccd249fb7433c302dd056ec0b263bc Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Wed, 16 Apr 2008 14:50:28 +1200 Subject: [PATCH 1/1] First commit. --- bin/summary-ics.pl | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 bin/summary-ics.pl diff --git a/bin/summary-ics.pl b/bin/summary-ics.pl new file mode 100755 index 0000000..f1efb99 --- /dev/null +++ b/bin/summary-ics.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl -w + +use strict; +use Data::ICal; +use Getopt::Long; +use Date::Manip; + +my $start = undef; +my $end = undef; + +GetOptions( + 'start' => \$start, + 'end' => \$end, +); + +$start ||= UnixDate(ParseDate('last month'), '%Y-%m-01'); +$end ||= UnixDate(ParseDate('now'), '%Y-%m-01'); + +$start = ParseDate($start); +$end = ParseDate($end); + +my $filename = shift; + +die "Please tell me a filename to work on!\n" + unless defined $filename; +die "I can't find the file: $filename\n" + unless -f $filename; + +print "Processing date range: " . UnixDate($start, '%Y-%m-%d') . " - " . UnixDate($end, '%Y-%m-%d') . "\n"; + +my $calendar = Data::ICal->new(filename => $filename); + +use Data::Dumper; +for my $entry (@{ $calendar->entries() }) { + if ($entry->ical_entry_type eq 'VEVENT') { + my $summary = return_property($entry, 'Summary'); + my $description = return_property($entry, 'Description'); + my $dtstart = return_property($entry, 'dtstart'); + print "event: $summary - $dtstart - $description\n"; + #print Dumper($entry); + } else { + print "not event\n"; + } +} + +sub return_property { + my $entry = shift; + my $property = shift; + + my $properties = $entry->property($property); + + return "" + unless defined $properties; + + if (scalar(@{ $properties }) > 0) { + return @{ $properties }[0]->value(); + } else { + return ""; + } +} -- 2.30.2