| 1 |
<?php |
| 2 |
class calendarData { |
| 3 |
|
| 4 |
var $_year; |
| 5 |
var $_month; |
| 6 |
var $_day; |
| 7 |
var $_row; |
| 8 |
|
| 9 |
var $_date; |
| 10 |
var $_datetext; |
| 11 |
|
| 12 |
function calendarData() { |
| 13 |
$this->_row = 0; |
| 14 |
} |
| 15 |
|
| 16 |
function setToday($year, $month, $day) { |
| 17 |
$this->_year = $year; |
| 18 |
$this->_month = $month; |
| 19 |
$this->_day = $day; |
| 20 |
} |
| 21 |
|
| 22 |
function getDate($row, $d) {return $this->_date[$row][$d];} |
| 23 |
function getDateText($row, $d) {return $this->_datetext[$row][$d];} |
| 24 |
function getRow() {return $this->_row;} |
| 25 |
|
| 26 |
function setCalendarData() { |
| 27 |
|
| 28 |
$day = 1; // 当月開始日に設定 |
| 29 |
$firstw = getWeek($this->_year, $this->_month, $day); // 当月開始日の曜日 |
| 30 |
$lastday = getLastDay($this->_year, $this->_month); // 当月最終日 |
| 31 |
$lastw = getWeek($this->_year, $this->_month, $lastday); // 当月最終日の曜日 |
| 32 |
|
| 33 |
// 1週目 |
| 34 |
for ($d = 0; $d <= 6; $d++) { |
| 35 |
if ($firstw == $d) { |
| 36 |
$this->_date[0][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 37 |
$this->_datetext[0][$d] = $day; |
| 38 |
} elseif ($firstw < $d) { |
| 39 |
list($this->_year, $this->_month, $day) = getNextDay($this->_year, $this->_month, $day); |
| 40 |
$this->_date[0][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 41 |
$this->_datetext[0][$d] = $day; |
| 42 |
} else { |
| 43 |
$this->_date[0][$d] = ""; |
| 44 |
$this->_datetext[0][$d] = ""; |
| 45 |
} |
| 46 |
} |
| 47 |
// 2~4週目 |
| 48 |
for ($d = 0; $d <= 6; $d++) { |
| 49 |
list($this->_year, $this->_month, $day) = getNextDay($this->_year, $this->_month, $day); |
| 50 |
$this->_date[1][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 51 |
$this->_datetext[1][$d] = $day; |
| 52 |
} |
| 53 |
for ($d = 0; $d <= 6; $d++) { |
| 54 |
list($this->_year, $this->_month, $day) = getNextDay($this->_year, $this->_month, $day); |
| 55 |
$this->_date[2][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 56 |
$this->_datetext[2][$d] = $day; |
| 57 |
} |
| 58 |
for ($d = 0; $d <= 6; $d++) { |
| 59 |
list($this->_year, $this->_month, $day) = getNextDay($this->_year, $this->_month, $day); |
| 60 |
$this->_date[3][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 61 |
$this->_datetext[3][$d] = $day; |
| 62 |
} |
| 63 |
// 5週目 |
| 64 |
for ($d = 0; $d <= 6; $d++) { |
| 65 |
if ($lastday == $day) { |
| 66 |
break; |
| 67 |
} else { |
| 68 |
list($this->_year, $this->_month, $day) = getNextDay($this->_year, $this->_month, $day); |
| 69 |
$this->_date[4][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 70 |
$this->_datetext[4][$d] = $day; |
| 71 |
} |
| 72 |
} |
| 73 |
if ($d <= 6) { |
| 74 |
while ($d <= 6) { |
| 75 |
$this->_date[4][$d] = ""; |
| 76 |
$this->_datetext[4][$d] = ""; |
| 77 |
$d++; |
| 78 |
} |
| 79 |
} else { |
| 80 |
// 6週目 |
| 81 |
for ($d = 0; $d <= 6; $d++) { |
| 82 |
if ($lastday == $day) { |
| 83 |
break; |
| 84 |
} else { |
| 85 |
list($this->_year, $this->_month, $day) = getNextDay($this->_year, $this->_month, $day); |
| 86 |
$this->_date[5][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); |
| 87 |
$this->_datetext[5][$d] = $day; |
| 88 |
} |
| 89 |
} |
| 90 |
if ($d > 0) { |
| 91 |
while ($d <= 6) { |
| 92 |
$this->_date[5][$d] = ""; |
| 93 |
$this->_datetext[5][$d] = ""; |
| 94 |
$d++; |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
$this->_row = count($this->_date); |
| 100 |
} |
| 101 |
} |
| 102 |
?> |
| 103 |
|