END:VTIMEZONE$r
EOF
;
+ my $now = Date::Calc->now();
+ $now = sprintf ("%02d%02d%02dT%02d%02d%02dZ", $now->datetime());
my %days = (M => "MO", T => "TU", W => "WE", R => "TH", F => "FR", S => "SA", U => "SU");
my $file = $opts{'out'};
my @schedule = get_schedule(@_);
open(STDOUT, ">" . $file) || die $! if(defined($file) && (! -d $file));
open(STDOUT, ">/dev/null") || die $! if(defined($file) && (-d $file));
- print "BEGIN:VCALENDAR$r\nVERSION:2.0$r\n$timezone";
+ print "BEGIN:VCALENDAR$r\nVERSION:2.0$r\nMETHOD:PUBLISH$r\n$timezone";
foreach my $row (@schedule) {
map { s/\n/-/g; $_} %$row;
my @day = ();
@day = @{$row->{'off'}} if ($row->{'off'});
+ my $day = "";
+ if(exists($day[0])) {
+ $day = join(",", @day);
+ $day =~ s/\b(\d{8})\b/$1T000000/g;
+ }
my ($starttime, $stoptime)=($row->{'begin'}, $row->{'end'});
my ($startdate, $stopdate)=split(/-/, $row->{'duration'});
$starttime =~ s/://;
if(defined($file) && (-d $file)) {
open FH, ">$file/" . $row->{'id'} . ".vcs" or die "$!";
select FH;
- print "BEGIN:VCALENDAR$r\nVERSION:2.0$r\n$timezone";
+ print "BEGIN:VCALENDAR$r\nVERSION:2.0$r\nMETHOD:PUBLISH$r\n$timezone";
}
print "BEGIN:VEVENT$r\n";
+ print "ORGANIZER:MAILTO:" . $opts{'email'} . "$r\n" if $opts{'email'};
+ print "UID:" . $row->{'id'} . "\@from.sctweb$r\n";
+ print "DTSTAMP:$now$r\n";
print "SUMMARY:", $row->{'title'}, "$r\n";
print "DESCRIPTION:", $row->{'id'}, "$r\n";
print "LOCATION:", $row->{'location'}, "$r\n";
print "DTEND;TZID=\"$tzn\":", $first."T".$stoptime, "00$r\n";
$row->{'days'} =~ s/([MTWRFS])/,$days{$1}/g;
$row->{'days'} =~ s/^,//;
- $stopdate++;
+ #$stopdate++;
print "RRULE:FREQ=WEEKLY;UNTIL=${stopdate}T000000Z;BYDAY=", $row->{'days'}, "$r\n";
- foreach my $day (@day) {
- print("EXDATE;TZID=\"$tzn\":${day}T$starttime$r\n");
- }
+ print("EXDATE;TZID=\"$tzn\":$day$r\n") if($day);
print "ATTENDEE;CN=".$row->{'instructor'}.";RSVP=FALSE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:" . (get_faculty_email($row->{'instructor'}) || "fake\@ddress"), "$r\n";
print "ATTENDEE;CN=".$opts{'name'}.";RSVP=FALSE;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:mailto:" . ($opts{'email'} || "fake\@ddress"), "$r\n" if $opts{'name'};
print "END:VEVENT$r\n";