1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | /* 日時表示用クラス */ |
---|
25 | class SC_Date { |
---|
26 | var $start_year; |
---|
27 | var $month; |
---|
28 | var $day; |
---|
29 | var $end_year; |
---|
30 | |
---|
31 | // コンストラクタ |
---|
32 | function SC_Date($start_year='', $end_year='') { |
---|
33 | if ( $start_year ) $this->setStartYear($start_year); |
---|
34 | if ( $end_year ) $this->setEndYear($end_year); |
---|
35 | } |
---|
36 | |
---|
37 | function setStartYear($year){ |
---|
38 | $this->start_year = $year; |
---|
39 | } |
---|
40 | |
---|
41 | function getStartYear(){ |
---|
42 | return $this->start_year; |
---|
43 | } |
---|
44 | |
---|
45 | function setEndYear($endYear) { |
---|
46 | $this->end_year = $endYear; |
---|
47 | } |
---|
48 | |
---|
49 | function getEndYear() { |
---|
50 | return $this->end_year; |
---|
51 | } |
---|
52 | |
---|
53 | function setMonth($month){ |
---|
54 | $this->month = $month; |
---|
55 | } |
---|
56 | |
---|
57 | function setDay ($day){ |
---|
58 | $this->day = $day; |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * 年プルダウン用の配列を返す |
---|
63 | * FIXME $default_year に一致いる行が無かった場合、先頭か末尾に付加すべきと思われる。 |
---|
64 | * @param string $year XMLファイル名 |
---|
65 | * @param bool|string $default_year |
---|
66 | * false 「選択なし」は含めない。 |
---|
67 | * true 「選択なし」は含める。 |
---|
68 | * string 「選択なし」は指定された値の下に付加する。 |
---|
69 | * @param string $default_key |
---|
70 | */ |
---|
71 | function getYear($year = '', $default_year = false, $default_key = '----') { |
---|
72 | if ( $year ) $this->setStartYear($year); |
---|
73 | |
---|
74 | $year = $this->start_year; |
---|
75 | if ( ! $year ) $year = DATE('Y'); |
---|
76 | |
---|
77 | $end_year = $this->end_year; |
---|
78 | if ( ! $end_year ) $end_year = (DATE('Y') + 3); |
---|
79 | |
---|
80 | $year_array = array(); |
---|
81 | |
---|
82 | if ($default_year === true) { |
---|
83 | $year_array[$default_key] = '----'; |
---|
84 | } |
---|
85 | |
---|
86 | for ($i = $year; $i <= $end_year; $i++) { |
---|
87 | $year_array[$i] = $i; |
---|
88 | if ($default_year !== true && strlen($default_year) >= 1 && $i == $default_year) { |
---|
89 | $year_array[$default_key] = '----'; |
---|
90 | } |
---|
91 | } |
---|
92 | return $year_array; |
---|
93 | } |
---|
94 | |
---|
95 | function getZeroYear($year = ''){ |
---|
96 | if ( $year ) $this->setStartYear($year); |
---|
97 | |
---|
98 | $year = $this->start_year; |
---|
99 | if ( ! $year ) $year = DATE('Y'); |
---|
100 | |
---|
101 | $end_year = $this->end_year; |
---|
102 | if ( ! $end_year ) $end_year = (DATE('Y') + 3); |
---|
103 | |
---|
104 | $year_array = array(); |
---|
105 | |
---|
106 | for ($i = $year; $i <= $end_year; $i++) { |
---|
107 | $key = substr($i, -2); |
---|
108 | $year_array[$key] = $key; |
---|
109 | } |
---|
110 | return $year_array; |
---|
111 | } |
---|
112 | |
---|
113 | function getZeroMonth(){ |
---|
114 | |
---|
115 | $month_array = array(); |
---|
116 | for ($i=1; $i <= 12; $i++){ |
---|
117 | $val = sprintf("%02d", $i); |
---|
118 | $month_array[$val] = $val; |
---|
119 | } |
---|
120 | return $month_array; |
---|
121 | } |
---|
122 | |
---|
123 | function getMonth($default = false) { |
---|
124 | $month_array = array(); |
---|
125 | |
---|
126 | if ($default) $month_array[''] = '--'; |
---|
127 | |
---|
128 | for ($i=0; $i < 12; $i++){ |
---|
129 | $month_array[$i + 1 ] = $i + 1; |
---|
130 | } |
---|
131 | return $month_array; |
---|
132 | } |
---|
133 | |
---|
134 | function getDay($default = false) { |
---|
135 | $day_array = array(); |
---|
136 | |
---|
137 | if ($default) $day_array[''] = '--'; |
---|
138 | |
---|
139 | for ($i=0; $i < 31; $i++){ |
---|
140 | $day_array[ $i + 1 ] = $i + 1; |
---|
141 | } |
---|
142 | |
---|
143 | return $day_array; |
---|
144 | } |
---|
145 | |
---|
146 | function getHour(){ |
---|
147 | |
---|
148 | $day_array = array(); |
---|
149 | for ($i=0; $i<=23; $i++){ |
---|
150 | $hour_array[$i] = $i; |
---|
151 | } |
---|
152 | |
---|
153 | return $hour_array; |
---|
154 | } |
---|
155 | |
---|
156 | function getMinutes(){ |
---|
157 | |
---|
158 | $minutes_array = array(); |
---|
159 | for ($i=0; $i<=59; $i++){ |
---|
160 | $minutes_array[$i] = $i; |
---|
161 | } |
---|
162 | |
---|
163 | return $minutes_array; |
---|
164 | } |
---|
165 | |
---|
166 | function getMinutesInterval(){ |
---|
167 | |
---|
168 | $minutes_array = array("00"=>"00", "30"=>"30"); |
---|
169 | return $minutes_array; |
---|
170 | } |
---|
171 | } |
---|