calendar Dec 2024 |
KW |
Mo |
Di |
Mi |
Do |
Fr |
Sa |
So |
48 |
|
|
|
|
|
|
1 |
48 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
49 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
50 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
51 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
52 |
30 |
31 |
|
|
|
|
|
class calendar
{
var $curday;
var $curmonth;
var $curyear;
var $curwday;
var $curyday;
var $wday = array("Mo", "Di", "Mi", "Do", "Fr", "Sa", "So");
var $month = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var $dayspermonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
function calendar($d, $m, $y, $w, $yd)
{
$this->curday = $d;
$this->curmonth = $m;
$this->curyear = $y;
$this->curwday = $w;
$this->curyday = $yd;
}
var $title = "calendar";
function settitle($t)
{
$this->title = $t;
}
function gettitle()
{
return $this->title;
}
function draw()
{
// Titel
$caltxt = "<table class=\"cal\">\n";
$caltxt .= "<tr><td colspan=\"8\" class=\"caltit0\">".$this->title." ".$this->month[$this->curmonth-1]." ".$this->curyear."</td></tr>\n";
$caltxt .= "<tr>\n";
// Überschriften Wochentage
$caltxt .= " <td class=\"caltit1\">KW</td>\n";
for ($i=0; $i<7; $i++)
{
$caltxt .= " <td class=\"caltit1\"> ".$this->wday[$i]." </td>\n";
}
$caltxt .= "</tr>\n";
// Wochentage
$d = 0; // Tag des Monats
$swd = $this->curwday - ($this->curday % 7) + 1; // Start-Wochentag
if ($swd < 0) {$swd = $swd + 7;}
$kw = ceil($this->curyday / 7); // KW ermitteln
for ($i=1; $d < $this->dayspermonth[$this->curmonth-1]; $i++)
{
$caltxt .= "<tr>\n";
$caltxt .= " <td class=\"caltit1\">";
if ($d < $this->curday - 6)
{
$caltxt .= round($kw - ($this->curday - $d) / 7);
}
else
{
if ($d > $this->curday)
{
$caltxt .= $kw + round(($d - $this->curday) / 7);
}
else
{
$caltxt .= $kw;
}
}
$caltxt .= "</td>\n";
for ($ii=1; $ii<=7; $ii++)
{
$caltxt .= " <td class=\"calday\"> ";
if ($d == 0) // 1.Tag im Monat finden, anhand Wochentagszahl
{
if ($ii == $swd || $ii == 7)
{
$d++;
$caltxt .= $d;
}
}
else // restliche Monatstage bis Tage/Monat eintragen
{
if ($d < $this->dayspermonth[$this->curmonth-1])
{
$d++;
$caltxt .= $d;
}
}
$caltxt .= " </td>\n";
}
$caltxt .= "</tr>\n";
}
$caltxt .= "</table>\n";
return $caltxt;
}
}
$d = getdate(); // Aktuellen Tag holen
// $mycal = new calendar(25, 10, 2005, 2);
$mycal = new calendar($d["mday"], $d["mon"], $d["year"], $d["wday"], $d["yday"]); // Kalender-Objekt initialisieren
$out .= $mycal->draw(); // Kalender zeichnen
echo $out;