source: branches/version-2_5-dev/data/class/SC_Date.php @ 18701

Revision 18701, 4.6 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 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/* 日時表示用クラス */
25class 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   
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    }
146
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    }
156
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    }
172}
173?>
Note: See TracBrowser for help on using the repository browser.