#!/usr/bin/perl -wT
use strict;
# vi:sts=2:shiftwidth=2
# -*- Mode: perl -*-

###########################################################################
# (c) 2005 Brett T. Warden
# http://www.wgz.org/bwarden/
#
# License:
# Perl Artistic License
# http://www.perl.com/language/misc/Artistic.html
#
# Other licensing arrangements available upon request.
#
# Note specifically:
#  THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
#  MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
###########################################################################

use CGI;

my @ical;

for(<>) {
  tr|\r||d;
  chomp;
  next unless s|^FREEBUSY:||;
  my ($start, $end) = split('/', $_, 2) or next;
  push(@ical,
    'BEGIN:VEVENT',
    'SEQUENCE:1',
    "DTSTART:$start",
    'SUMMARY:Busy',
    "DTEND:$end",
    'END:VEVENT',
  );
}

print "BEGIN:VCALENDAR\n";
print "VERSION:2.0\n";
for my $line (@ical) {
  print $line,"\n";
}
print "END:VCALENDAR\n";
