Aktivitetskalender

Line

#!/usr/bin/perl -w use strict; use CGI qw(param); #use POSIX qw[ _exit ]; use Time::Local; my $side = param("side"); my ($rrn, $d1, $d2, $when, $what, $text1, $text2) = 0; my $today=0; my ($second, $minute, $hour, $dayOfMonth, $monthOffset, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $year1 = 1901 + $yearOffset; my $month = 1 + $monthOffset; if ($dayOfMonth < 10) { $today=$month."0".$dayOfMonth; } else { $today=$month.$dayOfMonth; } $today=int $today; #Denne linie skal med! print "Content-Type: text/html\n\n"; if ($side) { if ($month <=6 || $month == 12 ) { if ($month == 12) { print "

Program for foråret $year1

\n"; } else { print "

Program for foråret $year

\n"; } } else { print "

Program for efteråret $year

\n"; } } my $daynbr = ""; my $strDay = ""; my $strMonth = ""; my $Test = ""; my $month1 = ""; my $day = ""; my $strd2 = ""; open (FILE, 'aktuel.txt'); while () { chomp; ($rrn, $d1, $strd2, $when, $what, $text1, $text2) = split("%"); $month1 = substr($strd2, 0, 2); #Get month number (1-12) $day = substr($strd2, 2,2); #Get date (1-31) $day = sprintf("%0d", $day); # print "$rrn - $strd2 - $month1$day\n"; $d1 = int $d1; $d2 = int $strd2; my $gmtime = timegm(0,0,0,$day,$month1-1,$year-1900); my @gmtime = gmtime($gmtime); # convert back $daynbr = $gmtime[6]; # Get day from nunber ($daynbr) if ($daynbr == 0) { $strDay = "Søndag";} elsif ($daynbr == 1) { $strDay = "Mandag";} elsif ($daynbr == 2) { $strDay = "Tirsdag";} elsif ($daynbr == 3) { $strDay = "Onsdag";} elsif ($daynbr == 4) { $strDay = "Torsdag";} elsif ($daynbr == 5) { $strDay = "Fredag";} elsif ($daynbr == 6) { $strDay = "Lørdag"; } # Get month from nunber ($month) if ($month1 == 1) { $strMonth = "Januar";} elsif ($month1 == 2) { $strMonth = "Februar";} elsif ($month1 == 3) { $strMonth = "Marts";} elsif ($month1 == 4) { $strMonth = "April";} elsif ($month1 == 5) { $strMonth = "Maj";} elsif ($month1 == 6) { $strMonth = "Juni";} elsif ($month1 == 7) { $strMonth = "Juli";} elsif ($month1 == 8) { $strMonth = "August";} elsif ($month1 == 9) { $strMonth = "September";} elsif ($month1 == 10) { $strMonth = "Oktober";} elsif ($month1 == 11) { $strMonth = "November";} elsif ($month1 == 12) { $strMonth = "December"; } # print "$day\n"; if (($side) && ($rrn != 0)) { # print "$day\n"; # print "$strDay d. $day. $strMonth kl.\n"; # print "Test 1 $rrn
"; # Last item om list should be 9, problems if more than 8 activites if ($rrn == 9) { print "

$what\n

"; goto break_out; } else { print "\n"; print "

$strDay d. $day. $strMonth kl. $when

\n"; print "

$what
\n"; if ($text1) { print "$text1
\n"; } if ($text2) { print "$text2
\n"; } print "

\n"; } } else { if ( (($today >= $d1) && ($today -1 < $d2)) || ($rrn eq 0) ) { print "$strDay d. $day. $strMonth kl. $when
\n"; print "$what\n"; } } break_out: } close (FILE); print "."; #POSIX::_exit(0); exit;

Line

Top

Valid XHTML 1.0! Valid CSS!