Reversed school and email fields in faculty
[tpope-extra.git] / perl / sctweb
index 06ff3a98056fd22e19e630d5de29b7a081ec6a3c..aa91c493a1a62e5c084eb3b3964c3d71019424db 100755 (executable)
@@ -56,7 +56,7 @@ sub next_class {
     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 = Date::Calc->today;
+    my $today = Date::Calc->new(Date::Calc->localtime(time+3600*6)->date);
     my @days=();
     foreach(split(" ",$class{'days'})) {
        push @days, Decode_Day_of_Week($_);
@@ -67,7 +67,7 @@ sub next_class {
        next if(grep($_ == $today, @off));
        return $today;
     }
-    $today = Date::Calc->today;
+    $today = Date::Calc->new(Date::Calc->gmtime->date);
     for($today = ($today < $lastday ? $today : $lastday); $today > $firstday; $today--) {
        next unless(grep($_ == Day_of_Week($today->date), @days));
        next if(grep($_ == $today, @off));
@@ -220,7 +220,7 @@ sub get_faculty_email {
        while($_ = <INS>) {
            chomp;
            m/"([^"]*)",([^,]*),([^,]*)/;
-           ($name, $school, $email) = ($1, $2, $3);
+           ($name, $email, $school) = ($1, $2, $3);
            $name =~ s/^([^,]*), ([^,]*)(.*)$/$2 $1$3/;
            $name =~ s/ [A-Z]\.//g;
            $name = lc $name;
@@ -289,7 +289,7 @@ sub do_mhc_schedule {
        if(defined($file) && (-d $file)) {
            $row->{'instructor'} =~ s/^([^,]*), ([^,]*)(.*)/$2 $1$3/;
            my $email = get_faculty_email $row->{'instructor'};
-           $row->{'instructor'} = '"' . $row->{'instructor'} . '" <'. ($email || "$1\@from.sctweb" . ">");
+           $row->{'instructor'} = '"' . $row->{'instructor'} . '" <'. ($email || "$1\@from.sctweb") . ">";
            $row->{'duration'} =~ /^(\d\d\d\d)(\d\d)(\d\d)-\d{8}$/;
            $row->{'begin'} =~ /^(\d\d):(\d\d)$/;
            my $next = next_class(%$row);
@@ -414,7 +414,15 @@ sub do_html_schedule {
            $row->{'duration'} =~ s/\d\d(\d\d)(\d\d)(\d\d)/$2-$3-$1/g;
            print '<tr>';
            print "<td>" . $row->{'id'} . "<br />" . $row->{'title'} . "</td>";
-           print "<td>" . $row->{'instructor'} . "</td>";
+           my $instructor = $row->{'instructor'};
+           $instructor =~ s/^([^,]*), ([^,]*)(.*)/$2 $1$3/;
+           my $email = get_faculty_email($instructor);
+           #if($email) {
+               #print '<td><a href="mailto:' . $email . '">'
+               #. $row->{'instructor'} . "</a></td>";
+           # } else {
+               print "<td>" . $row->{'instructor'} . "</td>";
+           #}
            print "<td>" . $row->{'days'} . "</td>";
            print "<td>" . $row->{'time'} . "</td>";
            print "<td>" . $row->{'duration'} . "</td>";
@@ -472,7 +480,7 @@ sub do_faculty {
            map { s/[\r\n]//g; $_} @$row;
            $row->[0] = capitalize($row->[0]);
            $row->[0] =~ s/([A-Z]r?)$/$1./;
-           print '"'.$row->[0].'",',$row->[1].',', $row->[2], "\n";
+           print '"'.$row->[0].'",',$row->[2].',', $row->[1], "\n";
        }
     }
 }