Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227

Notice: Undefined variable: dir in /var/www/nfs_docroot_cache/www/magic/Super_Class.php on line 227
CT_Cal.tar : Wesley Alan Wright: Slacker; Ski God : University of Vermont

University of Vermont

CT_Cal/0000755000076500000240000000000010260057114012060 5ustar wawstaff00000000000000CT_Cal/._CT_Cal.pl0000400000076500000000000000012210260057003013670 0ustar wawwheel00000000000000Mac OS X  2 RTEXTMcPLCT_Cal/CT_Cal.pl0000644000076500000240000001752410260057003013510 0ustar wawstaff00000000000000#! /usr/bin/perl # # Local definitions # my $login_family_name='Pat'; my $login_given_name='Smith'; my $login_password="xxxx"; my $server="calendar.xxx.edu" use FindBin qw($Bin); use strict; use Capi; use POSIX; use CGI; require 'CT_Cal_functions.pl'; our %params; our $q; $q=new CGI; %params=$q->Vars; my $asical=defined($params{"asical"}); my $debug=$params{debug}; $| = 1; if (!$asical) { print $q->header; print "\n"; print "\n\n"; } my $Output_Dir = "$Bin/PrePublished/"; #Get list of names from input. Input parameters take form fn1=,gn1=,fn2=,gn2=, etc. my $names=1; my @fn; my @gn; while (exists($params{"fn".$names})) { $fn[$names-1]=$params{"fn".$names}; $gn[$names-1]=$params{"gn".$names}; # print "Family name $names=".$fn[$names-1]." Given name $names=".$gn[$names-1]."<br>\n"; print "Live Calendar Data for $gn[$names-1] $fn[$names-1] " if (!$asical) ; $names++; } print "\n\n\n" if (!$asical) ; # if none specified, Provide a default family_name and given_name for Campus Calendar if (!exists($params{"fn1"})) { $fn[0]="Calendar"; $gn[0]="Campus"; $names=2; } my $nowtime=time(); my ($sec,$min,$hour,$day,$monthnum,$fyear,$wday,$yday,$isdst) = localtime($nowtime); $day=$params{day} if (exists($params{day})); $monthnum=($params{mon}-1) if (exists($params{mon})); $fyear=($params{year}-1900) if (exists($params{year})); my $period_start=POSIX::mktime(0, 0, 0, $day, $monthnum, $fyear,0,0,0); $period_start=POSIX::mktime(0, 0, 0, 1, $monthnum, $fyear,0,0,0) if ($params{ascal} eq 1); print "\n\n" if ($debug) ; # Here process period specification my $p = $params{period}; my $period_end; if ($p eq "day") { $period_end=$period_start+(24*60*60); } elsif ($p eq "week" || !exists($params{period})) { $period_end=$period_start+(7*24*60*60); } elsif ($p eq "month") { $period_end=$period_start+(31*24*60*60); } elsif ($p eq "nextmonth") { $period_start=$period_start+(30*24*60*60); $period_end=$period_start+(31*24*60*60); } elsif ($p eq "twomonth") { $period_end=$period_start+(2*31*24*60*60); } elsif ($p =~ /days/) { # here in the format of 30days, 60days, 90days $p =~ s/days//; $p +=0; $period_end=$period_start+($p*24*60*60); } else { $period_end=$period_start+(365*24*60*60); } my $start=&Unix2UTC($period_start); my $finish=&Unix2UTC($period_end); $start=$params{'s'} if (exists($params{'s'})) ; $finish=$params{'f'} if (exists($params{'f'})) ; print "\n" if ($debug) ; my $session; my $status=Capi::Logon($login_family_name, $login_given_name, $login_password, $server, "0", $session); print "logon Status=$status\n" if ($params{debug} ge 2);; if ($status != Capi::CAPI_STAT_OK) { print "Error - could not log in. Status=$status ".Capi::CAPI_GetStatusString($status)."\n"; exit; } print "Session=$session\n" if ($params{debug} ge 2);; # get "handle" for an agenda my $eventcounter=0; my $stream=""; my @proplist; if (defined($params{"ascal"}) || defined($params{"aslist"}) || defined($params{"asical"})) { @proplist=("DTSTART","DURATION","CLASS","STATUS","LOCATION","SUMMARY","DESCRIPTION"); } else { @proplist=("DTSTART","DURATION","CLASS","SUMMARY","DESCRIPTION"); } my $psize=scalar(@proplist); my $agendacount=0; my @handles; for (my $name=0;$name<$names-1;$name++) { my $family_name=$fn[$name]; my $given_name=$gn[$name]; # mlm - 09-26-2002 Added Class="cheader" to the tag print "

Calendar for $given_name $family_name

\n" if (exists($params{ascal})); my $filenm=$Output_Dir.&makeCalFileName($given_name,$family_name); if (-e $filenm && !$asical) { # Here read the agenda from the OS file $stream .= Cal_FetchFromFile($filenm,$start,$finish); # print "\n" ; } else { # Here fetch agenda from the calendar my $handle; if ($given_name eq "resource") { # print "\n"; $status=Capi::GetRHandle($session,$family_name,$handle); } else { # print "\n"; $status=Capi::GetHandle($session,$family_name,$given_name,$handle); } if ($status != Capi::CAPI_STAT_OK) { print "Error - could not get handle:$family_name,$given_name\n"; print "Status=$status ".Capi::CAPI_GetStatusString($status)."\n"; } #$handles[$name]=$handle; //mlm 05-31-01 fixed so handles are in sequence $handles[$agendacount]=$handle; $agendacount++; print "Got Handle=$handles[$name]
\n" if ($params{debug} ge 2); } } if ($agendacount>0){ # now get the agenda if there are any not already read from file my $time_1=time(); # print "\n"; $stream.=Capi::FetchEventsByRange($session, $start,$finish,$status,$psize,$agendacount,@proplist,@handles); my $time_2=time(); my $time_3=$time_2-$time_1; if (($status != Capi::CAPI_STAT_OK) && ($status != Capi::CAPI_STAT_SECUR_READ_PROPS)) { print "\n"; } # print "\n" ; } #parse the stream for display our ($eventlist_stime, $eventlist_etime, $eventlist_details, $eventlist_summary, $eventlist_location, $eventlist_attendee, $eventlist_class); &process($stream); #display the stream my $simple_time =(defined($params{"simple"}))? 1 : 0; if (defined($params{"ascal"})) { &displayCalendar($simple_time); } elsif (defined($params{"aslist"})) { &displayList($simple_time); } elsif (defined($params{"asshort"})) { &displayShortList($simple_time); } elsif (defined($params{"asical"})) { # print "Content-Type: text/plain; charset=UTF-8\n\n"; print "Content-Type: text/calendar; charset=UTF-8\n"; print "Content-Disposition: attachment; filename=\"calendar.ics\"\n"; print "Content-Transfer-Encoding: quoted-printable\n\n"; # strip off Oracle headers my @lines=split(/\n/,$stream); my $line; while ($line=shift(@lines)){ chop $line; last if ($line eq "BEGIN:VCALENDAR"); # print "bad $line\n"; } print "$line\r\n"; foreach my $line (@lines) { chop $line; print "$line\r\n"; } } else { &displayEvents($simple_time); } # Now logoff $status=Capi::Logoff($session); if ($status != Capi::CAPI_STAT_OK) { print "Error - could not log out. Status=$status ".Capi::CAPI_GetStatusString($status)."\n"; exit; } ###### SubRoutines ############ sub makeCalFileName($$){ my $gnm = @_[0]; my $fnm = @_[1]; my $filename = $fnm; $filename .= ",". $gnm if $gnm; $filename =~ s/ //g; return $filename; } sub Cal_FetchFromFile($$$){ my ($fnm,$start,$finish)=@_; my $stream=""; open(INFILE,"<$fnm") || die "cannot create $fnm: $!"; # Read file (ignoring events prior to $start & after $finish # Assumes the agenda is ordered by start time. my $e="";my $estarttime; while () { #print "$_
\n"; if (/^BEGIN:VEVENT/) { $e=$_; undef $estarttime; } if (/^END:VEVENT/) { if (defined($estarttime)){ $stream .= $e.$_ if ($estarttime>=$start); } } if (/^DTSTART:/) { $e.=$_; s/^DTSTART://; $estarttime=$_; #&UTC2Unix($_); # if this event starts after the finish time we are done reading. last if ($estarttime>=$finish); } else { $e.=$_; } } close(INFILE) || die "can't close $fnm: $!"; print "Event Stream from $fnm
\n", join("\n" if ($params{debug} ge 3); next BIGLOOP if ($params{debug} eq 7); #print "line=$_
\n" ; if (/^BEGIN:VEVENT/) { $event{"start"}=""; $event{"start_unix_time"}=""; $event{"end_unix_time"}=""; $event{"duration"}=""; $event{"end"}=""; $event{"location"}=""; $event{"attendee"}=""; $event{"class"}=""; $event{"details"}=""; $event{"summary"}=""; $event{"state"}=""; print "found event:
\n" if ($params{debug}); } if (/^END:VEVENT/) { $event{"state"}=""; $event{"end_unix_time"}=$event{"start_unix_time"}+$event{"duration"}; $event{"start"}=POSIX::ctime($event{"start_unix_time"}); $event{"end"}=POSIX::ctime($event{"end_unix_time"}) if ($event{"duration"}); # $event= "

$event{'start'} until $event{'end'}
\n"; $event{'attendee'}=~s/=3D/=/g; $event{'summary'}=~s/\\,/,/g; if ($event{'details'} eq "") { $event{'details'}=$event{'summary'}; } $event{'details'}=~s/\\n//g; $event{'details'}=~s/=20/ /g; $event{'details'}=~s/=3D/=/g; #mlm 3/29/01 - = escaped to =3d.. turn back into = $event{'details'}=~s/\\,/,/g; $event{'details'}=~s/(mailto:[^ ,]+)/$1<\/a>/g; $event{'details'}=~s/(news:[^ ,]+)/\1<\/a> /g; $event{'details'}=~s/(http:\/\/[^ ,]+)/\1<\/a> /g; $event{'details'}=~s/(ftp:\/\/[^ ,]+)/\1<\/a> /g; # $event.= "$event{'summary'} \n" if ($event{"summary"}); # $event.= ": $event{'location'} \n" if ($event{"location"}); # $event.= "

$event{'details'}

\n"; $eventcounter++; $eventlist_stime{$eventcounter} = $event{"start_unix_time"}; $eventlist_etime{$eventcounter} = $event{"end_unix_time"}; $eventlist_details{$eventcounter} = $event{'details'}; # $eventlist_details{$eventcounter} = $event{'details'}."\n"; $eventlist_summary{$eventcounter} = $event{'summary'}; $eventlist_location{$eventcounter} = $event{'location'}; $eventlist_attendee{$eventcounter} = $event{"attendee"}; $eventlist_class{$eventcounter} = $event{"class"}; print "Event $eventcounter '$event{'summary'}'

\n" if ($params{debug} ge 2); } if (/^DTSTART:/) { $event{"state"}=""; s/^DTSTART://; # print "found start $_
\n"; $event{"start_unix_time"}=&UTC2Unix($_); } if (/^DTSTART;VALUE=3DDATE:/) { # Isn't this lovely... look like a bug intrduced w/ CAPI 2.5.2 # which shows up in UVM Holidays.. note the funky ; # for now deal with it.... (mlm 01/23/2004) # Looks like this: #BEGIN:VEVENT #SUMMARY:UVM Holiday #CLASS:PUBLIC #DTSTART;VALUE=3DDATE:20040216 #END:VEVENT #Convert to UTC time like this: #DTSTART:20040218T200000Z $event{"state"}=""; s/^DTSTART;VALUE=3DDATE://; my $t = substr($_,0,8).'T050001Z'; #print "found start $t
\n"; $event{"start_unix_time"}=&UTC2Unix($t); } if (/^LOCATION:/) { $event{"state"}=""; s/^LOCATION://; s/=20/ /g; s/\\n//g; s/=3D/=/g; s/\\,/,/g; # print "found start $_
\n"; $event{"location"}=$_; } if (/^SUMMARY:/) { $event{"state"}=""; s/^SUMMARY://; s/=20/ /g; s/\\n//g; s/=3D/=/g; s/\\,/,/g; print "found SUMMARY='$_'
\n" if ($params{debug}); $event{"summary"}=$_; } if (/^UID:/) { $event{"state"}=""; } if (/^ORGANIZER:/) { $event{"state"}=""; } if (/^CLASS:/) { s/^CLASS://; $event{"class"}=$_; $event{"state"}=""; } if (/^PRIORITY:/) { $event{"state"}=""; } if (/^DURATION:/) { $event{"state"}=""; s/^DURATION://; $days=$_; $hours=$_; $minutes=$_; # DURATION:P0DT1H0M0S $days=~s/P([0-9]+)D.*/$1/; $hours=~s/.*T([0-9]+)H.*/$1/; $minutes=~s/.*H([0-9]+)M.*/$1/; # print "found duration =$_ d=$days h=$hours m=$minutes
\n"; $event{"duration"}=($days*24*3600)+($hours*3600)+($minutes*60); } if ((/^ATTENDEE;/ || $event{"state"} eq "ATTENDEE") && !/^DESCRIPTION:/) { $event{"state"}="ATTENDEE"; s/^ATTENDEE;//; # print "found start $_
\n"; chomp; s/^ //; $event{"attendee"}.=$_; } if (/^STATUS:/) { $event{"state"}=""; s/^ STATUS://; # print "found start $_
\n"; $event{"status"}.=$_; } if (/^DESCRIPTION:/ || $event{"state"} eq "DESCRIPTION") { if ($event{"state"} ne "DESCRIPTION") { $event{"details"}=""; $event{"state"}="DESCRIPTION"; } # print "line=$_
\n"; s/^DESCRIPTION://; s/^ //; s/=20/ /g; #mlm 07-11-2002 s/\\n//g; #mlm 07-11-2002 s/=3D/=/g; #mlm 07-11-2002 s/\\,/,/g; #mlm 07-11-2002 my $t = chr(13); # pesky ^M s/$t//g; #mlm 07-11-2002 chomp; $event{"details"}.=$_ ; } } } sub displayEvents { my $simple_time = shift(@_); my %months=("0","January","1","February","2","March","3","April","4","May","5","June", "6","July","7","August","8","September","9","October","10","November","11","December"); my %days=("0","Sunday","1","Monday","2","Tuesday","3","Wednesday","4","Thursday","5","Friday", "6","Saturday"); foreach $index (sort { $eventlist_stime{$a} <=> $eventlist_stime{$b} } keys %eventlist_stime) { $startime=$eventlist_stime{$index}; $NoEvents=0; ($sec,$Startmin,$Starthour,$eventday,$eventmonthnum,$eventyear,$wday,$yday,$isdst) = localtime($startime); ($sec,$Endmin,$Endhour,$Endday,$Endmonthnum,$Endyear,$wday,$yday,$isdst) = localtime($eventlist_etime{$index}); $eventmonth=$months{$eventmonthnum}; $eventday=$eventday+0; $eventyear=$eventyear+1900; if ($eventlist_class{$index} ne "" && $eventlist_class{$index} ne "CONFIDENTIAL" && $eventlist_class{$index} ne "PERSONAL") { if ("$eventmonth-$eventday" ne $lastday) { print "

$days{$wday} $eventmonth $eventday, $eventyear

\n"; $lastday="$eventmonth-$eventday"; } if ($eventlist_stime{$index} eq $eventlist_etime{$index}) { $duration="All Day "; $event=$eventlist_summary{$index}; } else { $duration=format_duration($Starthour,$Startmin,$Endhour, $Endmin, $simple_time); $event=$eventlist_details{$index}; } print "starttime_unix=$startime M=$eventmonth D=$eventday Y=$eventyear event='$event'\n\n" if ($params{debug} ge 2) ; $this_event="$eventlist_stime{$index} $eventlist_etime{$index} $eventlist_summary{$index} $eventlist_details{$index}"; if ($this_event eq $last_event) { print ""; print " WARNING DUPLICATE $this_event
\n" if ($params{debug} ge 2) ;; } else { # if ($eventlist_class{$index} ne "" && $eventlist_class{$index} ne "CONFIDENTIAL" && $eventlist_class{$index} ne "PERSONAL") { print "

$duration — $event

\n"; # } } $last_event=$this_event; } } } sub displayList { my $simple_time = shift(@_); my %months=("0","January","1","February","2","March","3","April","4","May","5","June", "6","July","7","August","8","September","9","October","10","November","11","December"); my %days=("0","Sunday","1","Monday","2","Tuesday","3","Wednesday","4","Thursday","5","Friday", "6","Saturday"); foreach $index (sort { $eventlist_stime{$a} <=> $eventlist_stime{$b} } keys %eventlist_stime) { $startime=$eventlist_stime{$index}; $NoEvents=0; ($sec,$Startmin,$Starthour,$eventday,$eventmonthnum,$eventyear,$wday,$yday,$isdst) = localtime($startime); ($sec,$Endmin,$Endhour,$Endday,$Endmonthnum,$Endyear,$wday,$yday,$isdst) = localtime($eventlist_etime{$index}); $eventmonth=$months{$eventmonthnum}; $eventday=$eventday+0; $eventyear=$eventyear+1900; if ("$eventmonth-$eventday" ne $lastday) { print "

$days{$wday} $eventmonth $eventday, $eventyear

\n"; $lastday="$eventmonth-$eventday"; } if ($eventlist_stime{$index} eq $eventlist_etime{$index}) { $duration="All Day "; $eventsum=$eventlist_summary{$index}; $eventd=""; $eventl=""; } else { $duration=format_duration($Starthour,$Startmin,$Endhour, $Endmin, $simple_time); $eventsum=$eventlist_summary{$index}; $eventd=$eventlist_details{$index}; $eventl=$eventlist_location{$index} } print "starttime_unix=$startime $eventmonth $eventday $eventyear $event\n\n" if ($params{debug} ge 2) ; $this_event="$eventlist_stime{$index} $eventlist_etime{$index} $eventlist_summary{$index} $eventlist_details{$index}"; if ($this_event eq $last_event) { print ""; } else { print "

$duration $eventsum
Location: $eventl
$eventd

\n"; } $last_event=$this_event; } } sub displayShortList { my $simple_time = shift(@_); my %months=("0","January","1","February","2","March","3","April","4","May","5","June", "6","July","7","August","8","September","9","October","10","November","11","December"); my %days=("0","Sunday","1","Monday","2","Tuesday","3","Wednesday","4","Thursday","5","Friday", "6","Saturday"); foreach $index (sort { $eventlist_stime{$a} <=> $eventlist_stime{$b} } keys %eventlist_stime) { $startime=$eventlist_stime{$index}; $NoEvents=0; ($sec,$Startmin,$Starthour,$eventday,$eventmonthnum,$eventyear,$wday,$yday,$isdst) = localtime($startime); ($sec,$Endmin,$Endhour,$Endday,$Endmonthnum,$Endyear,$wday,$yday,$isdst) = localtime($eventlist_etime{$index}); $eventmonth=$months{$eventmonthnum}; $eventday=$eventday+0; $eventyear=$eventyear+1900; if ("$eventmonth-$eventday" ne $lastday) { print "

$days{$wday} $eventmonth $eventday, $eventyear

\n"; $lastday="$eventmonth-$eventday"; } if ($eventlist_stime{$index} eq $eventlist_etime{$index}) { $duration="All Day "; $eventsum=$eventlist_summary{$index}; $eventd=""; $eventl=""; } else { $duration=format_duration($Starthour,$Startmin,$Endhour, $Endmin, $simple_time); $eventsum=$eventlist_summary{$index}; $eventd=$eventlist_details{$index}; $eventl=$eventlist_location{$index} } print "starttime_unix=$startime $eventmonth $eventday $eventyear $event\n\n" if ($params{debug} ge 2) ; $this_event="$eventlist_stime{$index} $eventlist_etime{$index} $eventlist_summary{$index} $eventlist_details{$index}"; if ($this_event eq $last_event) { print ""; } else { if($eventlist_class{$index} ne "" && $eventlist_class{$index} ne "CONFIDENTIAL" && $eventlist_class{$index} ne "PERSONAL"){ # print "

$duration $eventsum
Location: $eventl
$eventd

\n"; print "

$duration $eventsum

\n"; } } $last_event=$this_event; } } sub displayCalendar { my $simple_time = shift(@_); my %months=("0","January","1","February","2","March","3","April","4","May","5","June", "6","July","7","August","8","September","9","October","10","November","11","December"); my %days=("0","Sunday","1","Monday","2","Tuesday","3","Wednesday","4","Thursday","5","Friday", "6","Saturday"); $NoEvents=1; foreach $index (sort { $eventlist_stime{$a} <=> $eventlist_stime{$b} } keys %eventlist_stime) { $startime=$eventlist_stime{$index}; $NoEvents=0; ($sec,$Startmin,$Starthour,$eventday,$eventmonthnum,$eventyear,$wday,$yday,$isdst) = localtime($startime); ($sec,$Endmin,$Endhour,$Endday,$Endmonthnum,$Endyear,$wday,$yday,$isdst) = localtime($eventlist_etime{$index}); $eventmonth=$months{$eventmonthnum}; $eventmonthnum=sprintf("%2s",$eventmonthnum); $eventday=sprintf("%2s",$eventday); $eventyear=$eventyear+1900; if ($eventlist_stime{$index} eq $eventlist_etime{$index}) { $duration="All Day"; } else { $duration=format_duration($Starthour,$Startmin,$Endhour, $Endmin, $simple_time); } $definedMonths{$eventyear."-".$eventmonthnum}=$eventyear; # $calrow=POSIX::floor(($eventday+1)/7); # $calcol=$wday; # $calevents{$eventmonthnum."-".$calrow."-".$calcol} .="

$duration: $eventlist_summary{$index}
$eventlist_location{$index}

\n"; if ($eventlist_class{$index} ne "") { $text=$eventlist_summary{$index}; } else { $text="Private event"; } $calevents{$eventmonthnum."-".$eventday} .="

$duration: $text
$eventlist_location{$index}

\n"; if ($params{debug}) { print "calevent (mm-dd) $eventmonthnum-$eventday is $eventlist_summary{$index}
\n"; print "definedMonths (yyyy-mm) $eventyear-$eventmonthnum is
\n"; print "event class=".$eventlist_class{$index}."
\n"; } } print "\n"; foreach $key (sort keys (%definedMonths)) { ($year,$Month)=split(/-/,$key); $monthnum=$Month+1; $cal = `cal $monthnum $definedMonths{$key}`; # print "cal $monthnum $definedMonths{$Month} (Month=$Month)
\n"; @calfile = split(/\n/,$cal); $moyr=shift(@calfile); @moyr=split(/ /,$moyr); $curyear=pop(@moyr)+0; $curmonth=pop(@moyr); print ""; print "

$curmonth $curyear

\n"; $_=shift(@calfile); @days=split(/ /); print ""; foreach $day (@days) { if ($day ne "") { print ""; } } print "\n"; $row=0; # for ($row=0 ; $row<=4; $row++) { while ($_=shift(@calfile)) { print ""; # $_=shift(@calfile); $col=0; for ($i=0;$i<26;$i+=4) { $date=substr($_,$i,2); if (defined($calevents{$Month.'-'.$date})) { $pevent=$calevents{$Month.'-'.$date}; } else { $pevent=" "; } print ""; $col++; } print "\n"; $row++; } print "
",$day,"
$date 
$pevent
\n"; } print "

Nothing Scheduled for selected time period.

\n" if ($NoEvents); } sub format_duration($$$$$) { #This subroutine formats start and end time as # H {a.m.|p.m} to H {a.m.|p.m} # H:mm {a.m.|p.m} to HH:MM {a.m.|p.m} # Midnight|Noon to midnight|noon # or any combination of the above. my ($Starthour,$Startmin,$Endhour, $Endmin, $simple_time) = @_; my $Start; my $SAMPM; my $End; my $EAMPM; # fix to 00 format. if (length($Startmin) < 2) {$Startmin="0".$Startmin;} if (length($Endmin) < 2) {$Endmin="0".$Endmin;} if ( $Startmin eq "00" ) { #Here on the hour if ($Starthour == 0){ $Start="Midnight"; $SAMPM=" to "; }elsif ( $Starthour < 12){ $Start=$Starthour; $SAMPM=" a.m. to "; }elsif ( $Starthour == 12){ $Start="Noon"; $SAMPM=" to "; }elsif ( $Starthour > 12){ $Start=$Starthour-12; $SAMPM=" p.m. to "; } }else{ #Here have minutes if ( $Starthour == 0){ $Start='12:'.$Startmin; $SAMPM=' a.m. to '; }elsif ( $Starthour < 12){ $Start=$Starthour.":".$Startmin; $SAMPM=' a.m. to '; }elsif ( $Starthour == 12){ $Start=$Starthour.':'.$Startmin; $SAMPM=' p.m. to '; }elsif ( $Starthour > 12){ $Start=($Starthour-12).':'.$Startmin; $SAMPM=' p.m. to '; } } if ( $Endmin eq "00" ) { #Here on the hour if ($Endhour == 0){ $End='midnight'; $EAMPM=' '; }elsif ( $Endhour < 12){ $End=$Endhour; $EAMPM=' a.m. '; }elsif ( $Endhour == 12){ $End='noon'; $EAMPM=' '; }elsif ( $Endhour > 12){ $End=$Endhour-12; $EAMPM=' p.m. '; } }else{ #Here have minutes if ( $Endhour == 0){ $End='12:'.$Endmin; $EAMPM=' a.m. '; }elsif ( $Endhour < 12){ $End=$Endhour.':'.$Endmin; $EAMPM=' a.m. '; }elsif ( $Endhour == 12){ $End=$Endhour.':'.$Endmin; $EAMPM=' p.m. '; }elsif ( $Endhour > 12){ $End=($Endhour-12).":".$Endmin; $EAMPM=' p.m. '; } } my $duration; if ($simple_time){ # simple_time means just start time... # rather than the normal start to end range $SAMPM =~ s/ to //; # get rid of 'to' if present. $duration="".$Start.$SAMPM; } else{ $duration="".$Start.$SAMPM.$End.$EAMPM." "; } return $duration; } 1;

Last modified June 27 2005 04:20 PM

Contact UVM © 2014 The University of Vermont - Burlington, VT 05405 - (802) 656-3131