From 4ec1fca1384c81aab33d4072491ae9bd94c1ed88 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 23 Aug 2005 08:46:34 +0000 Subject: [PATCH] Quick hack to improve vCal output --- perl/schedproc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/perl/schedproc b/perl/schedproc index a61b453..dc5df8c 100755 --- a/perl/schedproc +++ b/perl/schedproc @@ -87,6 +87,27 @@ sub generate_id { return $id; } +sub first_class { + my %class = @_; + $class{'duration'} =~ /(\d\d\d\d)(\d\d)(\d\d)-(\d\d\d\d)(\d\d)(\d\d)/; + my $days = Delta_Days($1,$2,$3,$4,$5,$6); + my $firstday = Date::Calc->new($1,$2,$3); + my $lastday = Date::Calc->new($4,$5,$6); + my $today; + my @days=(); + foreach(split(" ",$class{'days'})) { + push @days, Decode_Day_of_Week($_); + } + my @off = (); + @off = @{$class{'off'}} if ($class{'off'}); + for($today = $firstday; $today < $lastday; $today++) { + next unless(grep($_ == Day_of_Week($today->date), @days)); + next if(grep($_ == "$today", @off)); + return $today; + } + return undef; +} + sub next_class { my %class = @_; $class{'duration'} =~ /(\d\d\d\d)(\d\d)(\d\d)-(\d\d\d\d)(\d\d)(\d\d)/; @@ -362,8 +383,8 @@ sub do_vcalendar_schedule { print "DESCRIPTION:", $row->{'id'}, "\r\n"; print "LOCATION:", $row->{'location'}, "\r\n"; print "CATEGORIES:Education\r\n"; - print "DTSTART:", $startdate."T".$starttime, "00\r\n"; - print "DTEND:", $startdate."T".$stoptime, "00\r\n"; + print "DTSTART:", first_class(%$row)."T".$starttime, "00\r\n"; + print "DTEND:", first_class(%$row)."T".$stoptime, "00\r\n"; print "RRULE:W1 ", $row->{'days'} . " $stopdate", "T000000\r\n"; print("EXDATE:$day\r\n") if($day); print "ATTENDEE;ROLE=OWNER;STATUS=CONFIRMED:", $opts{'name'}, "\r\n" if(defined($opts{'name'})); -- 2.30.2