Changeset 18758 for trunk/data/class/SC_Date.php
- Timestamp:
- 2010/07/20 13:25:33 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/class/SC_Date.php
r16741 r18758 3 3 * This file is part of EC-CUBE 4 4 * 5 * Copyright(c) 2000-20 07LOCKON CO.,LTD. All Rights Reserved.5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. 6 6 * 7 7 * http://www.lockon.co.jp/ … … 22 22 */ 23 23 24 /* 24 /* 日時表示用クラス */ 25 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 function getYear($year = '', $default = ''){ 62 if ( $year ) $this->setStartYear($year); 63 64 $year = $this->start_year; 65 if ( ! $year ) $year = DATE("Y"); 66 67 $end_year = $this->end_year; 68 if ( ! $end_year ) $end_year = (DATE("Y") + 3); 69 70 $year_array = array(); 71 72 for ($i=$year; $i<=($end_year); $i++){ 73 $year_array[$year] = $i; 74 if($year == $default) { 75 $year_array['----'] = "----"; 76 } 77 $year++; 78 } 79 return $year_array; 80 } 81 82 function getZeroYear($year = ''){ 83 if ( $year ) $this->setStartYear($year); 84 85 $year = $this->start_year; 86 if ( ! $year ) $year = DATE("Y"); 87 88 $end_year = $this->end_year; 89 if ( ! $end_year ) $end_year = (DATE("Y") + 3); 90 91 $year_array = array(); 92 93 for ($i=$year; $i<=($end_year); $i++){ 94 $key = substr($i, -2); 95 $year_array[$key] = $key; 96 } 97 return $year_array; 98 } 99 100 function getZeroMonth(){ 101 102 $month_array = array(); 103 for ($i=1; $i <= 12; $i++){ 104 $val = sprintf("%02d", $i); 105 $month_array[$val] = $val; 106 } 107 return $month_array; 108 } 109 110 111 function getMonth(){ 112 113 $month_array = array(); 114 for ($i=0; $i < 12; $i++){ 115 $month_array[$i + 1 ] = $i + 1; 116 } 117 return $month_array; 118 } 119 120 function getDay(){ 121 122 $day_array = array(); 123 for ($i=0; $i < 31; $i++){ 124 $day_array[ $i + 1 ] = $i + 1; 125 } 126 127 return $day_array; 128 } 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 124 function getMonth($default = false) { 125 $month_array = array(); 126 127 if ($default) $month_array[''] = '--'; 128 129 for ($i=0; $i < 12; $i++){ 130 $month_array[$i + 1 ] = $i + 1; 131 } 132 return $month_array; 133 } 134 135 function getDay($default = false) { 136 $day_array = array(); 137 138 if ($default) $day_array[''] = '--'; 139 140 for ($i=0; $i < 31; $i++){ 141 $day_array[ $i + 1 ] = $i + 1; 142 } 143 144 return $day_array; 145 } 129 146 130 function getHour(){ 131 132 133 for ($i=0; $i<=23; $i++){ 134 135 136 137 138 147 function getHour(){ 148 149 $day_array = array(); 150 for ($i=0; $i<=23; $i++){ 151 $hour_array[$i] = $i; 152 } 153 154 return $hour_array; 155 } 139 156 140 function getMinutes(){ 141 142 143 for ($i=0; $i<=59; $i++){ 144 145 146 147 148 149 150 function getMinutesInterval(){ 151 152 $minutes_array = array("00"=>"00", "30"=>"30"); 153 154 } 157 function getMinutes(){ 158 159 $minutes_array = array(); 160 for ($i=0; $i<=59; $i++){ 161 $minutes_array[$i] = $i; 162 } 163 164 return $minutes_array; 165 } 166 167 function getMinutesInterval(){ 168 169 $minutes_array = array("00"=>"00", "30"=>"30"); 170 return $minutes_array; 171 } 155 172 } 156 173 ?>
Note: See TracChangeset
for help on using the changeset viewer.