#!/usr/bin/perl -w # # Author: Petter Reinholdtsen # Date: 2002-01-10 # # Convert plan calender data to icalender format. # # plan, # icalendar, RFC 2445, iCalendar> use Date::Parse; use Date::Format; my @events; my $mailto = "pere\@hungry.com"; read_planfile(".plan.dir/dayplan"); write_icalendar(); sub read_planfile { my ($planfile) = @_; open(PLAN, "<$planfile") || die "Unable to read $planfile"; my $planver = ; chomp $planver; while () { chomp; if (m%\d+/\d+/\d+\s%) { my ($date, $start, $duration) = split(/\s+/); my $info = ; chomp $info; my ($dontknow, $msg) = $info =~ m/^(.)\t(.+)$/; print STDERR "E: $date $start $duration $msg\n"; my $timestamp = str2time("$date $start"); $isostartstamp = time2str("%Y%m%dT%H%M%S", $timestamp); my @f = split(/:/, $duration); $timestamp += ($f[0]*60*60 + $f[1]*60 +$f[2]); $isoendstamp = time2str("%Y%m%dT%H%M%S", $timestamp); print STDERR "IE: $isostartstamp $isoendstamp\n"; push(@events, { organizer => "$mailto", summary => $msg, dtstart => $isostartstamp, dtend => $isoendstamp, priority => '1' }); } } close(PLAN); } # BEGIN:VCALENDAR # PRODID # :-//K Desktop Environment//NONSGML KOrganizer//EN # VERSION # :2.0 # BEGIN:VEVENT # CREATED # :20020110T153939 # UID # :KOrganizer-141229514.660 # SEQUENCE # :0 # LAST-MODIFIED # :20020110T153939 # DTSTAMP # :20020110T153952 # ORGANIZER # :MAILTO:pre@diskless.uio.no # SUMMARY # :SL-veiledning # PRIORITY # :1 # DTSTART # :20020114T151500 # DTEND # :20020114T160000 # END:VEVENT # END:VCALENDAR sub write_icalendar { print <{organizer} SUMMARY :$event->{summary} PRIORITY :$event->{priority} DTSTART :$event->{dtstart} DTEND :$event->{dtend} END:VEVENT EOF $count++; } print "END:VCALENDAR\n"; }