<?php
/*
Titken Lipinski, 2007
Koden er ment som inspiration, og opdateres ikke i forold til nye funktioner på siden (som feks pdf osv)
*/
?>
<?php
$maaneder = array("","Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December");
$dage = array("S","M","T","O","T","F","L");
?>
<?php
if ( !function_exists('easter_date') ) {
function easter_date($Year) {
$G = $Year % 19;
$C = (int)($Year / 100);
$H = (int)($C - ($C / 4) - ((8*$C+13) / 25) + 19*$G + 15) % 30;
$I = (int)$H - (int)($H / 28)*(1 - (int)($H / 28)*(int)(29 / ($H + 1))*((int)(21 - $G) / 11));
$J = ($Year + (int)($Year/4) + $I + 2 - $C + (int)($C/4)) % 7;
$L = $I - $J;
$m = 3 + (int)(($L + 40) / 44);
$d = $L + 28 - 31 * ((int)($m / 4));
$y = $Year;
$E = mktime(0,0,0, $m, $d, $y);
return $E;
}
}
?>
<?php
function day_exists($aar, $mnd, $dg) {
return ( checkdate($mnd, $dg, $aar) ) ? true : false;
}
?>
<?php
function hent_faste_helligdage($aar) {
define("A_DAY", 86400);
$skudaar = date("L",mktime(0,0,0, 1, 1,$aar));
$fastelavn = ($skudaar==1) ? 49 : 48;
$paskedag = (int)easter_date($aar);
$hlg[date("Y-n-j", mktime(0,0,0, 1, 1,$aar))] = 'Nytårsdag';
$hlg[date("Y-n-j", ($paskedag - 3*A_DAY))] = 'Skærtorsdag';
$hlg[date("Y-n-j", ($paskedag - 2*A_DAY))] = 'Langfredag';
$hlg[date("Y-n-j", ($paskedag + 0*A_DAY))] = 'Påskedag';
$hlg[date("Y-n-j", ($paskedag + 1*A_DAY))] = '2. påskedag';
$hlg[date("Y-n-j", ($paskedag + 26*A_DAY))] = 'Store bededag';
$hlg[date("Y-n-j", ($paskedag + 39*A_DAY))] = 'Kr. himmelfartsdag';
$hlg[date("Y-n-j", ($paskedag + 49*A_DAY))] = 'Pinsedag';
$hlg[date("Y-n-j", ($paskedag + 50*A_DAY))] = '2. pinsedag';
$hlg[date("Y-n-j", mktime(0,0,0, 6, 5,$aar))] = 'Grundlovsdag';
$hlg[date("Y-n-j", mktime(0,0,0,12,24,$aar))] = 'Juleaften';
$hlg[date("Y-n-j", mktime(0,0,0,12,25,$aar))] = '1. juledag';
$hlg[date("Y-n-j", mktime(0,0,0,12,26,$aar))] = '2. juledag';
$hlg[date("Y-n-j", mktime(0,0,0,12,31,$aar))] = 'Nytårsaften';
$hlg[date("Y-n-j", $paskedag - $fastelavn*A_DAY)] = 'Fastelavn';
$hlg[date("Y-n-j", mktime(0,0,0, 1, 6,$aar))] = 'Hellig 3 konger';
return $hlg;
}
?>
<?php
function skriv_maaneder($start,$slut,$aar) {
global $helligdage, $maaneder, $dage;
echo "<table class=\"cal\">\n";
echo " <tr>\n";
for ($i=$start; $i<=$slut; $i++) {
echo " <th>".$maaneder[$i]."</th>\n";
}
echo " </tr>\n";
for ($dag=1; $dag<=31; $dag++) {
echo " <tr>\n";
for ($mnd=$start; $mnd<=$slut; $mnd++) {
if ( day_exists($aar,$mnd,$dag) ) {
$fmt = $aar."-".$mnd."-".$dag;
$ugedag = date("w", mktime(0,0,0,$mnd,$dag,$aar));
$skriv_dag = $dage[$ugedag];
$style = ( $ugedag == 0 ) ? " class=\"son\"" : "";
$weekno = ( $ugedag == 1 ) ? "<span class=\"rw\">".(int)date("W", mktime(0,0,0,$mnd,$dag,$aar))."</span>" : "";
if ( array_key_exists($fmt,$helligdage) ) {
$style = " class=\"hlg\"";
$right2 = "<span class=\"r2\">".$helligdage[$fmt]."</span>";
} else {
$right2 = "";
}
echo " <td{$style}><span class=\"l\">$dag</span><span class=\"r\">$skriv_dag</span>".$right2.$weekno."</td>\n";
} else {
echo " <td> </td>\n";
}
}
echo " </tr>\n";
}
echo "</table>\n";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Kalender med danske helligdage</title>
<style type="text/css">
@media print {
#form {
display : none;
}
body {
background-color: #FFFFFF;
color: #000000;
}
}
body {
background-color: #E8E8E8;
color: #000000;
font-family: verdana, arial, sans-serif;
font-size: 10px;
margin-top: 40px;
margin-left: 40px;
}
h1 {
font-size: 15px;
font-weight: bold;
}
h3 {
font-size: 10px;
font-weight: bold;
margin-top: 3px;
margin-bottom: 3px;
}
th {
background-color: #8F8F8F;
color: #000000;
width: 180px;
}
p {
margin-top: 0px;
margin-bottom: 5px;
}
.l {
width: 15px;
float: left;
text-align: right;
}
.r {
width: 24px;
margin-left: 4px;
float: left;
}
.r2 {
margin-left: 4px;
float: left;
}
.rw {
font-family: arial,vardana, sans-serif;
font-size: 9px;
vartical-align: top;
margin-left: 4px;
float: right;
}
.cal {
border: solid black 2px;
border-collapse: collapse;
}
.cal td {
border: solid black 1px;
border-collapse: collapse;
padding: 2px;
}
.cal th {
border: solid black 1px;
border-collapse: collapse;
padding: 2px;
}
.son {
background-color:#C1C1C1;
color: #000000;
}
.hlg {
background-color:#D0AFAF;
color: #000000;
}
</style>
</head>
<body>
<?php
if ( !isset($_REQUEST['aar']) ) {
$aar = date("Y",time());
} else {
$aar = (int)$_REQUEST['aar'];
}
$helligdage = hent_faste_helligdage($aar);
echo "<div id=\"form\">\n";
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
echo "<b>Vælg årstal:</b> <select name=\"aar\">\n";
for ($i=2006; $i<=2017; $i++) {
$selected = ($i==$aar) ? " selected=\"selected\"":"";
echo " <option value=\"".$i."\"{$selected}>".$i."</option>\n";
}
echo "</select>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Vis kalender\" />\n";
echo "</form>\n";
echo "</div>\n";
echo "<h1>".$aar." - 1. halvår</h1>\n";
skriv_maaneder(1,6,$aar);
echo "<div style=\"page-break-after:always;\"></div>\n";
echo "<h1>".$aar." - 2. halvår</h1>\n";
skriv_maaneder(7,12,$aar);
?>
</body>
</html>