Ignore:
Timestamp:
2013/08/28 13:26:44 (13 years ago)
Author:
m_uehara
Message:

#2275
影響が大きいため、2.13.0では対応を行わない r23125 r23128 r23133 を差し戻します。

Location:
branches/version-2_13-dev/data/module/Calendar/Engine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/Calendar/Engine/Interface.php

    r23125 r23141  
    11<?php 
    22/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
    3  
     3// 
     4// +----------------------------------------------------------------------+ 
     5// | PHP Version 4                                                        | 
     6// +----------------------------------------------------------------------+ 
     7// | Copyright (c) 1997-2002 The PHP Group                                | 
     8// +----------------------------------------------------------------------+ 
     9// | This source file is subject to version 2.02 of the PHP license,      | 
     10// | that is bundled with this package in the file LICENSE, and is        | 
     11// | available at through the world-wide-web at                           | 
     12// | http://www.php.net/license/3_0.txt.                                  | 
     13// | If you did not receive a copy of the PHP license and are unable to   | 
     14// | obtain it through the world-wide-web, please send a note to          | 
     15// | [email protected] so we can mail you a copy immediately.               | 
     16// +----------------------------------------------------------------------+ 
     17// | Authors: Harry Fuecks <[email protected]>                      | 
     18// +----------------------------------------------------------------------+ 
     19// 
     20// $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $ 
     21// 
    422/** 
    5  * Contains the Calendar_Engine_Interface class (interface) 
    6  * 
    7  * PHP versions 4 and 5 
    8  * 
    9  * LICENSE: Redistribution and use in source and binary forms, with or without 
    10  * modification, are permitted provided that the following conditions are met: 
    11  * 1. Redistributions of source code must retain the above copyright 
    12  *    notice, this list of conditions and the following disclaimer. 
    13  * 2. Redistributions in binary form must reproduce the above copyright 
    14  *    notice, this list of conditions and the following disclaimer in the 
    15  *    documentation and/or other materials provided with the distribution. 
    16  * 3. The name of the author may not be used to endorse or promote products 
    17  *    derived from this software without specific prior written permission. 
    18  * 
    19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 
    20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
    21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    22  * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY 
    23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    29  * 
    30  * @category  Date and Time 
    31  * @package   Calendar 
    32  * @author    Harry Fuecks <[email protected]> 
    33  * @author    Lorenzo Alberton <[email protected]> 
    34  * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton 
    35  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    36  * @version   CVS: $Id: Interface.php 269074 2008-11-15 21:21:42Z quipo $ 
    37  * @link      http://pear.php.net/package/Calendar 
     23 * @package Calendar 
     24 * @version $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $ 
    3825 */ 
    39  
    4026/** 
    4127 * The methods the classes implementing the Calendar_Engine must implement. 
    4228 * Note this class is not used but simply to help development 
    43  * 
    44  * @category  Date and Time 
    45  * @package   Calendar 
    46  * @author    Harry Fuecks <[email protected]> 
    47  * @author    Lorenzo Alberton <[email protected]> 
    48  * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton 
    49  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    50  * @link      http://pear.php.net/package/Calendar 
     29 * @package Calendar 
    5130 * @access protected 
    5231 */ 
     
    5837     * Typically called "internally" by methods like stampToYear. 
    5938     * Return value can vary, depending on the specific implementation 
    60      * 
    61      * @param int $stamp timestamp (depending on implementation) 
    62      * 
     39     * @param int timestamp (depending on implementation) 
    6340     * @return mixed 
    6441     * @access protected 
     
    7047    /** 
    7148     * Returns a numeric year given a timestamp 
    72      * 
    73      * @param int $stamp timestamp (depending on implementation) 
    74      * 
     49     * @param int timestamp (depending on implementation) 
    7550     * @return int year (e.g. 2003) 
    7651     * @access protected 
     
    8257    /** 
    8358     * Returns a numeric month given a timestamp 
    84      * 
    85      * @param int $stamp timestamp (depending on implementation) 
    86      * 
     59     * @param int timestamp (depending on implementation) 
    8760     * @return int month (e.g. 9) 
    8861     * @access protected 
     
    9467    /** 
    9568     * Returns a numeric day given a timestamp 
    96      * 
    97      * @param int $stamp timestamp (depending on implementation) 
    98      * 
     69     * @param int timestamp (depending on implementation) 
    9970     * @return int day (e.g. 15) 
    10071     * @access protected 
     
    10677    /** 
    10778     * Returns a numeric hour given a timestamp 
    108      * 
    109      * @param int $stamp timestamp (depending on implementation) 
    110      * 
     79     * @param int timestamp (depending on implementation) 
    11180     * @return int hour (e.g. 13) 
    11281     * @access protected 
     
    11887    /** 
    11988     * Returns a numeric minute given a timestamp 
    120      * 
    121      * @param int $stamp timestamp (depending on implementation) 
    122      * 
     89     * @param int timestamp (depending on implementation) 
    12390     * @return int minute (e.g. 34) 
    12491     * @access protected 
     
    13097    /** 
    13198     * Returns a numeric second given a timestamp 
    132      * 
    133      * @param int $stamp timestamp (depending on implementation) 
    134      * 
     99     * @param int timestamp (depending on implementation) 
    135100     * @return int second (e.g. 51) 
    136101     * @access protected 
     
    141106 
    142107    /** 
    143      * Returns a timestamp. Can be worth "caching" generated timestamps in a 
    144      * static variable, identified by the params this method accepts, 
    145      * to timestamp will only be calculated once. 
    146      * 
    147      * @param int $y year (e.g. 2003) 
    148      * @param int $m month (e.g. 9) 
    149      * @param int $d day (e.g. 13) 
    150      * @param int $h hour (e.g. 13) 
    151      * @param int $i minute (e.g. 34) 
    152      * @param int $s second (e.g. 53) 
    153      * 
     108     * Returns a timestamp. Can be worth "caching" generated 
     109     * timestamps in a static variable, identified by the 
     110     * params this method accepts, to timestamp will only 
     111     * be calculated once. 
     112     * @param int year (e.g. 2003) 
     113     * @param int month (e.g. 9) 
     114     * @param int day (e.g. 13) 
     115     * @param int hour (e.g. 13) 
     116     * @param int minute (e.g. 34) 
     117     * @param int second (e.g. 53) 
    154118     * @return int (depends on implementation) 
    155119     * @access protected 
    156120     */ 
    157     function dateToStamp($y, $m, $d, $h, $i, $s) 
     121    function dateToStamp($y,$m,$d,$h,$i,$s) 
    158122    { 
    159123    } 
     
    161125    /** 
    162126     * The upper limit on years that the Calendar Engine can work with 
    163      * 
    164127     * @return int (e.g. 2037) 
    165128     * @access protected 
     
    171134    /** 
    172135     * The lower limit on years that the Calendar Engine can work with 
    173      * 
    174136     * @return int (e.g 1902) 
    175137     * @access protected 
     
    181143    /** 
    182144     * Returns the number of months in a year 
    183      * 
    184      * @param int $y (optional) year to get months for 
    185      * 
     145     * @param int (optional) year to get months for 
    186146     * @return int (e.g. 12) 
    187147     * @access protected 
     
    193153    /** 
    194154     * Returns the number of days in a month, given year and month 
    195      * 
    196      * @param int $y year (e.g. 2003) 
    197      * @param int $m month (e.g. 9) 
    198      * 
     155     * @param int year (e.g. 2003) 
     156     * @param int month (e.g. 9) 
    199157     * @return int days in month 
    200158     * @access protected 
     
    207165     * Returns numeric representation of the day of the week in a month, 
    208166     * given year and month 
    209      * 
    210      * @param int $y year (e.g. 2003) 
    211      * @param int $m month (e.g. 9) 
    212      * 
     167     * @param int year (e.g. 2003) 
     168     * @param int month (e.g. 9) 
    213169     * @return int 
    214170     * @access protected 
     
    220176    /** 
    221177     * Returns the number of days in a week 
    222      * 
    223      * @param int $y year (2003) 
    224      * @param int $m month (9) 
    225      * @param int $d day (4) 
    226      * 
     178     * @param int year (2003) 
     179     * @param int month (9) 
     180     * @param int day (4) 
    227181     * @return int (e.g. 7) 
    228182     * @access protected 
    229183     */ 
    230     function getDaysInWeek($y=null, $m=null, $d=null) 
     184    function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) 
    231185    { 
    232186    } 
     
    234188    /** 
    235189     * Returns the number of the week in the year (ISO-8601), given a date 
    236      * 
    237      * @param int $y year (2003) 
    238      * @param int $m month (9) 
    239      * @param int $d day (4) 
    240      * 
     190     * @param int year (2003) 
     191     * @param int month (9) 
     192     * @param int day (4) 
    241193     * @return int week number 
    242194     * @access protected 
     
    248200    /** 
    249201     * Returns the number of the week in the month, given a date 
    250      * 
    251      * @param int $y        year (2003) 
    252      * @param int $m        month (9) 
    253      * @param int $d        day (4) 
    254      * @param int $firstDay first day of the week (default: 1 - monday) 
    255      * 
     202     * @param int year (2003) 
     203     * @param int month (9) 
     204     * @param int day (4) 
     205     * @param int first day of the week (default: 1 - monday) 
    256206     * @return int week number 
    257207     * @access protected 
     
    263213    /** 
    264214     * Returns the number of weeks in the month 
    265      * 
    266      * @param int $y year (2003) 
    267      * @param int $m month (9) 
    268      * 
     215     * @param int year (2003) 
     216     * @param int month (9) 
     217     * @param int first day of the week (default: 1 - monday) 
    269218     * @return int weeks number 
    270219     * @access protected 
     
    276225    /** 
    277226     * Returns the number of the day of the week (0=sunday, 1=monday...) 
    278      * 
    279      * @param int $y year (2003) 
    280      * @param int $m month (9) 
    281      * @param int $d day (4) 
    282      * 
     227     * @param int year (2003) 
     228     * @param int month (9) 
     229     * @param int day (4) 
    283230     * @return int weekday number 
    284231     * @access protected 
     
    290237    /** 
    291238     * Returns the numeric values of the days of the week. 
    292      * 
    293      * @param int $y year (2003) 
    294      * @param int $m month (9) 
    295      * @param int $d day (4) 
    296      * 
     239     * @param int year (2003) 
     240     * @param int month (9) 
     241     * @param int day (4) 
    297242     * @return array list of numeric values of days in week, beginning 0 
    298243     * @access protected 
    299244     */ 
    300     function getWeekDays($y=null, $m=null, $d=null) 
     245    function getWeekDays($y=NULL, $m=NULL, $d=NULL) 
    301246    { 
    302247    } 
     
    305250     * Returns the default first day of the week as an integer. Must be a 
    306251     * member of the array returned from getWeekDays 
    307      * 
    308      * @param int $y year (2003) 
    309      * @param int $m month (9) 
    310      * @param int $d day (4) 
    311      * 
     252     * @param int year (2003) 
     253     * @param int month (9) 
     254     * @param int day (4) 
    312255     * @return int (e.g. 1 for Monday) 
    313256     * @see getWeekDays 
    314257     * @access protected 
    315258     */ 
    316     function getFirstDayOfWeek($y=null, $m=null, $d=null) 
    317     { 
    318     } 
    319  
    320     /** 
    321      * Returns the number of hours in a day 
    322      * 
    323      * @param int $y year (2003) 
    324      * @param int $m month (9) 
    325      * @param int $d day (4) 
    326      * 
     259    function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) 
     260    { 
     261    } 
     262 
     263    /** 
     264     * Returns the number of hours in a day<br> 
     265     * @param int (optional) day to get hours for 
    327266     * @return int (e.g. 24) 
    328267     * @access protected 
     
    334273    /** 
    335274     * Returns the number of minutes in an hour 
    336      * 
    337      * @param int $y year (2003) 
    338      * @param int $m month (9) 
    339      * @param int $d day (4) 
    340      * @param int $h hour 
    341      * 
     275     * @param int (optional) hour to get minutes for 
    342276     * @return int 
    343277     * @access protected 
     
    349283    /** 
    350284     * Returns the number of seconds in a minutes 
    351      * 
    352      * @param int $y year (2003) 
    353      * @param int $m month (9) 
    354      * @param int $d day (4) 
    355      * @param int $h hour 
    356      * @param int $i minute 
    357      * 
     285     * @param int (optional) minute to get seconds for 
    358286     * @return int 
    359287     * @access protected 
    360288     */ 
    361289    function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) 
    362     { 
    363     } 
    364  
    365     /** 
    366      * Checks if the given day is the current day 
    367      * 
    368      * @param int timestamp (depending on implementation) 
    369      * 
    370      * @return boolean 
    371      * @access protected 
    372      */ 
    373     function isToday($stamp) 
    374290    { 
    375291    } 
  • branches/version-2_13-dev/data/module/Calendar/Engine/PearDate.php

    r23125 r23141  
    11<?php 
    22/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
    3  
     3// 
     4// +----------------------------------------------------------------------+ 
     5// | PHP Version 4                                                        | 
     6// +----------------------------------------------------------------------+ 
     7// | Copyright (c) 1997-2002 The PHP Group                                | 
     8// +----------------------------------------------------------------------+ 
     9// | This source file is subject to version 2.02 of the PHP license,      | 
     10// | that is bundled with this package in the file LICENSE, and is        | 
     11// | available at through the world-wide-web at                           | 
     12// | http://www.php.net/license/3_0.txt.                                  | 
     13// | If you did not receive a copy of the PHP license and are unable to   | 
     14// | obtain it through the world-wide-web, please send a note to          | 
     15// | [email protected] so we can mail you a copy immediately.               | 
     16// +----------------------------------------------------------------------+ 
     17// | Authors: Lorenzo Alberton <l dot alberton at quipo dot it>           | 
     18// +----------------------------------------------------------------------+ 
     19// 
     20// $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $ 
     21// 
    422/** 
    5  * Contains the Calendar_Engine_PearDate class 
    6  * 
    7  * PHP versions 4 and 5 
    8  * 
    9  * LICENSE: Redistribution and use in source and binary forms, with or without 
    10  * modification, are permitted provided that the following conditions are met: 
    11  * 1. Redistributions of source code must retain the above copyright 
    12  *    notice, this list of conditions and the following disclaimer. 
    13  * 2. Redistributions in binary form must reproduce the above copyright 
    14  *    notice, this list of conditions and the following disclaimer in the 
    15  *    documentation and/or other materials provided with the distribution. 
    16  * 3. The name of the author may not be used to endorse or promote products 
    17  *    derived from this software without specific prior written permission. 
    18  * 
    19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 
    20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
    21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    22  * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY 
    23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    29  * 
    30  * @category  Date and Time 
    31  * @package   Calendar 
    32  * @author    Lorenzo Alberton <[email protected]> 
    33  * @copyright 2003-2007 Lorenzo Alberton 
    34  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    35  * @version   CVS: $Id: PearDate.php 269076 2008-11-15 21:41:38Z quipo $ 
    36  * @link      http://pear.php.net/package/Calendar 
     23 * @package Calendar 
     24 * @version $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $ 
    3725 */ 
    38  
    3926/** 
    4027 * Load PEAR::Date class 
     
    4532 * Performs calendar calculations based on the PEAR::Date class 
    4633 * Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS) 
    47  * 
    48  * @category  Date and Time 
    49  * @package   Calendar 
    50  * @author    Lorenzo Alberton <[email protected]> 
    51  * @copyright 2003-2007 Lorenzo Alberton 
    52  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    53  * @link      http://pear.php.net/package/Calendar 
     34 * @package Calendar 
    5435 * @access protected 
    5536 */ 
     
    6041     * Uses a static variable to prevent date() being used twice 
    6142     * for a date which is already known 
    62      * 
    63      * @param mixed $stamp Any timestamp format recognized by Pear::Date 
    64      * 
     43     * @param mixed Any timestamp format recognized by Pear::Date 
    6544     * @return object Pear::Date object 
    6645     * @access protected 
     
    7756    /** 
    7857     * Returns a numeric year given a iso-8601 datetime 
    79      * 
    80      * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    81      * 
     58     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    8259     * @return int year (e.g. 2003) 
    8360     * @access protected 
     
    9168    /** 
    9269     * Returns a numeric month given a iso-8601 datetime 
    93      * 
    94      * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    95      * 
     70     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    9671     * @return int month (e.g. 9) 
    9772     * @access protected 
     
    10580    /** 
    10681     * Returns a numeric day given a iso-8601 datetime 
    107      * 
    108      * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    109      * 
     82     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    11083     * @return int day (e.g. 15) 
    11184     * @access protected 
     
    11992    /** 
    12093     * Returns a numeric hour given a iso-8601 datetime 
    121      * 
    122      * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    123      * 
     94     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    12495     * @return int hour (e.g. 13) 
    12596     * @access protected 
     
    133104    /** 
    134105     * Returns a numeric minute given a iso-8601 datetime 
    135      * 
    136      * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    137      * 
     106     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    138107     * @return int minute (e.g. 34) 
    139108     * @access protected 
     
    147116    /** 
    148117     * Returns a numeric second given a iso-8601 datetime 
    149      * 
    150      * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    151      * 
     118     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) 
    152119     * @return int second (e.g. 51) 
    153120     * @access protected 
     
    161128    /** 
    162129     * Returns a iso-8601 datetime 
    163      * 
    164      * @param int $y year (2003) 
    165      * @param int $m month (9) 
    166      * @param int $d day (13) 
    167      * @param int $h hour (13) 
    168      * @param int $i minute (34) 
    169      * @param int $s second (53) 
    170      * 
     130     * @param int year (2003) 
     131     * @param int month (9) 
     132     * @param int day (13) 
     133     * @param int hour (13) 
     134     * @param int minute (34) 
     135     * @param int second (53) 
    171136     * @return string iso-8601 datetime 
    172137     * @access protected 
     
    186151    /** 
    187152     * Set the correct date values (useful for math operations on dates) 
    188      * 
    189      * @param int &$y year   (2003) 
    190      * @param int &$m month  (9) 
    191      * @param int &$d day    (13) 
    192      * @param int &$h hour   (13) 
    193      * @param int &$i minute (34) 
    194      * @param int &$s second (53) 
    195      * 
    196      * @return void 
     153     * @param int year   (2003) 
     154     * @param int month  (9) 
     155     * @param int day    (13) 
     156     * @param int hour   (13) 
     157     * @param int minute (34) 
     158     * @param int second (53) 
    197159     * @access protected 
    198160     */ 
     
    248210    /** 
    249211     * The upper limit on years that the Calendar Engine can work with 
    250      * 
    251212     * @return int 9999 
    252213     * @access protected 
     
    259220    /** 
    260221     * The lower limit on years that the Calendar Engine can work with 
    261      * 
    262222     * @return int 0 
    263223     * @access protected 
     
    270230    /** 
    271231     * Returns the number of months in a year 
    272      * 
    273      * @param int $y year 
    274      * 
    275232     * @return int (12) 
    276233     * @access protected 
     
    283240    /** 
    284241     * Returns the number of days in a month, given year and month 
    285      * 
    286      * @param int $y year (2003) 
    287      * @param int $m month (9) 
    288      * 
     242     * @param int year (2003) 
     243     * @param int month (9) 
    289244     * @return int days in month 
    290245     * @access protected 
     
    298253     * Returns numeric representation of the day of the week in a month, 
    299254     * given year and month 
    300      * 
    301      * @param int $y year (2003) 
    302      * @param int $m month (9) 
    303      * 
     255     * @param int year (2003) 
     256     * @param int month (9) 
    304257     * @return int from 0 to 7 
    305258     * @access protected 
     
    312265    /** 
    313266     * Returns the number of days in a week 
    314      * 
    315      * @param int $y year (2003) 
    316      * @param int $m month (9) 
    317      * @param int $d day (4) 
    318      * 
     267     * @param int year (2003) 
     268     * @param int month (9) 
     269     * @param int day (4) 
    319270     * @return int (7) 
    320271     * @access protected 
    321272     */ 
    322     function getDaysInWeek($y=null, $m=null, $d=null) 
     273    function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) 
    323274    { 
    324275        return 7; 
     
    327278    /** 
    328279     * Returns the number of the week in the year (ISO-8601), given a date 
    329      * 
    330      * @param int $y year (2003) 
    331      * @param int $m month (9) 
    332      * @param int $d day (4) 
    333      * 
     280     * @param int year (2003) 
     281     * @param int month (9) 
     282     * @param int day (4) 
    334283     * @return int week number 
    335284     * @access protected 
     
    337286    function getWeekNInYear($y, $m, $d) 
    338287    { 
    339         //return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard! 
    340         list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y); 
    341         return $nWeek; 
     288        return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard! 
    342289    } 
    343290 
    344291    /** 
    345292     * Returns the number of the week in the month, given a date 
    346      * 
    347      * @param int $y        year (2003) 
    348      * @param int $m        month (9) 
    349      * @param int $d        day (4) 
    350      * @param int $firstDay first day of the week (default: monday) 
    351      * 
     293     * @param int year (2003) 
     294     * @param int month (9) 
     295     * @param int day (4) 
     296     * @param int first day of the week (default: monday) 
    352297     * @return int week number 
    353298     * @access protected 
     
    367312    /** 
    368313     * Returns the number of weeks in the month 
    369      * 
    370      * @param int $y        year (2003) 
    371      * @param int $m        month (9) 
    372      * @param int $firstDay first day of the week (default: monday) 
    373      * 
     314     * @param int year (2003) 
     315     * @param int month (9) 
     316     * @param int first day of the week (default: monday) 
    374317     * @return int weeks number 
    375318     * @access protected 
     
    395338    /** 
    396339     * Returns the number of the day of the week (0=sunday, 1=monday...) 
    397      * 
    398      * @param int $y year (2003) 
    399      * @param int $m month (9) 
    400      * @param int $d day (4) 
    401      * 
     340     * @param int year (2003) 
     341     * @param int month (9) 
     342     * @param int day (4) 
    402343     * @return int weekday number 
    403344     * @access protected 
     
    410351    /** 
    411352     * Returns a list of integer days of the week beginning 0 
    412      * 
    413      * @param int $y year (2003) 
    414      * @param int $m month (9) 
    415      * @param int $d day (4) 
    416      * 
     353     * @param int year (2003) 
     354     * @param int month (9) 
     355     * @param int day (4) 
    417356     * @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday 
    418357     * @access protected 
    419358     */ 
    420     function getWeekDays($y=null, $m=null, $d=null) 
     359    function getWeekDays($y=NULL, $m=NULL, $d=NULL) 
    421360    { 
    422361        return array(0, 1, 2, 3, 4, 5, 6); 
     
    425364    /** 
    426365     * Returns the default first day of the week 
    427      * 
    428      * @param int $y year (2003) 
    429      * @param int $m month (9) 
    430      * @param int $d day (4) 
    431      * 
     366     * @param int year (2003) 
     367     * @param int month (9) 
     368     * @param int day (4) 
    432369     * @return int (default 1 = Monday) 
    433370     * @access protected 
    434371     */ 
    435     function getFirstDayOfWeek($y=null, $m=null, $d=null) 
     372    function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) 
    436373    { 
    437374        return 1; 
     
    440377    /** 
    441378     * Returns the number of hours in a day 
    442      * 
    443      * @param int $y year (2003) 
    444      * @param int $m month (9) 
    445      * @param int $d day (4) 
    446      * 
    447379     * @return int (24) 
    448380     * @access protected 
     
    455387    /** 
    456388     * Returns the number of minutes in an hour 
    457      * 
    458      * @param int $y year (2003) 
    459      * @param int $m month (9) 
    460      * @param int $d day (4) 
    461      * @param int $h hour 
    462      * 
    463389     * @return int (60) 
    464390     * @access protected 
     
    471397    /** 
    472398     * Returns the number of seconds in a minutes 
    473      * 
    474      * @param int $y year (2003) 
    475      * @param int $m month (9) 
    476      * @param int $d day (4) 
    477      * @param int $h hour 
    478      * @param int $i minute 
    479      * 
    480399     * @return int (60) 
    481400     * @access protected 
     
    484403    { 
    485404        return 60; 
    486     } 
    487  
    488     /** 
    489      * Checks if the given day is the current day 
    490      * 
    491      * @param mixed $stamp Any timestamp format recognized by Pear::Date 
    492      * 
    493      * @return boolean 
    494      * @access protected 
    495      */ 
    496     function isToday($stamp) 
    497     { 
    498         static $today = null; 
    499         if (is_null($today)) { 
    500             $today = new Date(); 
    501         } 
    502         $date = Calendar_Engine_PearDate::stampCollection($stamp); 
    503         return (   $date->day == $today->getDay() 
    504                 && $date->month == $today->getMonth() 
    505                 && $date->year == $today->getYear() 
    506         ); 
    507405    } 
    508406} 
  • branches/version-2_13-dev/data/module/Calendar/Engine/UnixTS.php

    r23125 r23141  
    11<?php 
    22/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
    3  
     3// 
     4// +----------------------------------------------------------------------+ 
     5// | PHP Version 4                                                        | 
     6// +----------------------------------------------------------------------+ 
     7// | Copyright (c) 1997-2002 The PHP Group                                | 
     8// +----------------------------------------------------------------------+ 
     9// | This source file is subject to version 2.02 of the PHP license,      | 
     10// | that is bundled with this package in the file LICENSE, and is        | 
     11// | available at through the world-wide-web at                           | 
     12// | http://www.php.net/license/3_0.txt.                                  | 
     13// | If you did not receive a copy of the PHP license and are unable to   | 
     14// | obtain it through the world-wide-web, please send a note to          | 
     15// | [email protected] so we can mail you a copy immediately.               | 
     16// +----------------------------------------------------------------------+ 
     17// | Authors: Harry Fuecks <[email protected]>                      | 
     18// +----------------------------------------------------------------------+ 
     19// 
     20// $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $ 
     21// 
    422/** 
    5  * Contains the Calendar_Engine_UnixTS class 
    6  * 
    7  * PHP versions 4 and 5 
    8  * 
    9  * LICENSE: Redistribution and use in source and binary forms, with or without 
    10  * modification, are permitted provided that the following conditions are met: 
    11  * 1. Redistributions of source code must retain the above copyright 
    12  *    notice, this list of conditions and the following disclaimer. 
    13  * 2. Redistributions in binary form must reproduce the above copyright 
    14  *    notice, this list of conditions and the following disclaimer in the 
    15  *    documentation and/or other materials provided with the distribution. 
    16  * 3. The name of the author may not be used to endorse or promote products 
    17  *    derived from this software without specific prior written permission. 
    18  * 
    19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 
    20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
    21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    22  * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY 
    23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    29  * 
    30  * @category  Date and Time 
    31  * @package   Calendar 
    32  * @author    Harry Fuecks <[email protected]> 
    33  * @copyright 2003-2007 Harry Fuecks 
    34  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    35  * @version   CVS: $Id: UnixTS.php 269074 2008-11-15 21:21:42Z quipo $ 
    36  * @link      http://pear.php.net/package/Calendar 
     23 * @package Calendar 
     24 * @version $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $ 
    3725 */ 
    38  
    3926/** 
    4027 * Performs calendar calculations based on the PHP date() function and 
    4128 * Unix timestamps (using PHP's mktime() function). 
    42  * 
    43  * @category  Date and Time 
    44  * @package   Calendar 
    45  * @author    Harry Fuecks <[email protected]> 
    46  * @copyright 2003-2007 Harry Fuecks 
    47  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    48  * @link      http://pear.php.net/package/Calendar 
    49  * @access    protected 
     29 * @package Calendar 
     30 * @access protected 
    5031 */ 
    5132class Calendar_Engine_UnixTS /* implements Calendar_Engine_Interface */ 
     
    6849     * Uses a static variable to prevent date() being used twice 
    6950     * for a date which is already known 
    70      * 
    71      * @param int $stamp Unix timestamp 
    72      * 
     51     * @param int Unix timestamp 
    7352     * @return array 
    7453     * @access protected 
     
    7857        static $stamps = array(); 
    7958        if ( !isset($stamps[$stamp]) ) { 
    80             $date = @date('Y n j H i s t W w', $stamp); 
     59            $date = @date('Y n j H i s t W w',$stamp); 
    8160            $stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d"); 
    8261        } 
     
    8665    /** 
    8766     * Returns a numeric year given a timestamp 
    88      * 
    89      * @param int $stamp Unix timestamp 
    90      * 
     67     * @param int Unix timestamp 
    9168     * @return int year (e.g. 2003) 
    9269     * @access protected 
     
    10077    /** 
    10178     * Returns a numeric month given a timestamp 
    102      * 
    103      * @param int $stamp Unix timestamp 
    104      * 
     79     * @param int Unix timestamp 
    10580     * @return int month (e.g. 9) 
    10681     * @access protected 
     
    11489    /** 
    11590     * Returns a numeric day given a timestamp 
    116      * 
    117      * @param int $stamp Unix timestamp 
    118      * 
     91     * @param int Unix timestamp 
    11992     * @return int day (e.g. 15) 
    12093     * @access protected 
     
    128101    /** 
    129102     * Returns a numeric hour given a timestamp 
    130      * 
    131      * @param int $stamp Unix timestamp 
    132      * 
     103     * @param int Unix timestamp 
    133104     * @return int hour (e.g. 13) 
    134105     * @access protected 
     
    142113    /** 
    143114     * Returns a numeric minute given a timestamp 
    144      * 
    145      * @param int $stamp Unix timestamp 
    146      * 
     115     * @param int Unix timestamp 
    147116     * @return int minute (e.g. 34) 
    148117     * @access protected 
     
    156125    /** 
    157126     * Returns a numeric second given a timestamp 
    158      * 
    159      * @param int $stamp Unix timestamp 
    160      * 
     127     * @param int Unix timestamp 
    161128     * @return int second (e.g. 51) 
    162129     * @access protected 
     
    170137    /** 
    171138     * Returns a timestamp 
    172      * 
    173      * @param int $y year (2003) 
    174      * @param int $m month (9) 
    175      * @param int $d day (13) 
    176      * @param int $h hour (13) 
    177      * @param int $i minute (34) 
    178      * @param int $s second (53) 
    179      * 
     139     * @param int year (2003) 
     140     * @param int month (9) 
     141     * @param int day (13) 
     142     * @param int hour (13) 
     143     * @param int minute (34) 
     144     * @param int second (53) 
    180145     * @return int Unix timestamp 
    181146     * @access protected 
     
    184149    { 
    185150        static $dates = array(); 
    186         if (!isset($dates[$y][$m][$d][$h][$i][$s])) { 
     151        if ( !isset($dates[$y][$m][$d][$h][$i][$s]) ) { 
    187152            $dates[$y][$m][$d][$h][$i][$s] = @mktime($h, $i, $s, $m, $d, $y); 
    188153        } 
     
    192157    /** 
    193158     * The upper limit on years that the Calendar Engine can work with 
    194      * 
    195159     * @return int (2037) 
    196160     * @access protected 
     
    203167    /** 
    204168     * The lower limit on years that the Calendar Engine can work with 
    205      * 
    206169     * @return int (1970 if it's Windows and 1902 for all other OSs) 
    207170     * @access protected 
     
    214177    /** 
    215178     * Returns the number of months in a year 
    216      * 
    217      * @param int $y year 
    218      * 
    219179     * @return int (12) 
    220      * @access protected 
     180    * @access protected 
    221181     */ 
    222182    function getMonthsInYear($y=null) 
     
    227187    /** 
    228188     * Returns the number of days in a month, given year and month 
    229      * 
    230      * @param int $y year (2003) 
    231      * @param int $m month (9) 
    232      * 
     189     * @param int year (2003) 
     190     * @param int month (9) 
    233191     * @return int days in month 
    234192     * @access protected 
     
    236194    function getDaysInMonth($y, $m) 
    237195    { 
    238         $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1); 
    239         $date  = Calendar_Engine_UnixTS::stampCollection($stamp); 
     196        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1); 
     197        $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
    240198        return $date[6]; 
    241199    } 
     
    244202     * Returns numeric representation of the day of the week in a month, 
    245203     * given year and month 
    246      * 
    247      * @param int $y year (2003) 
    248      * @param int $m month (9) 
    249      * 
     204     * @param int year (2003) 
     205     * @param int month (9) 
    250206     * @return int from 0 to 6 
    251207     * @access protected 
     
    253209    function getFirstDayInMonth($y, $m) 
    254210    { 
    255         $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1); 
    256         $date  = Calendar_Engine_UnixTS::stampCollection($stamp); 
     211        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1); 
     212        $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
    257213        return $date[8]; 
    258214    } 
     
    260216    /** 
    261217     * Returns the number of days in a week 
    262      * 
    263      * @param int $y year (2003) 
    264      * @param int $m month (9) 
    265      * @param int $d day (4) 
    266      * 
     218     * @param int year (2003) 
     219     * @param int month (9) 
     220     * @param int day (4) 
    267221     * @return int (7) 
    268222     * @access protected 
    269223     */ 
    270     function getDaysInWeek($y=null, $m=null, $d=null) 
     224    function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) 
    271225    { 
    272226        return 7; 
     
    275229    /** 
    276230     * Returns the number of the week in the year (ISO-8601), given a date 
    277      * 
    278      * @param int $y year (2003) 
    279      * @param int $m month (9) 
    280      * @param int $d day (4) 
    281      * 
     231     * @param int year (2003) 
     232     * @param int month (9) 
     233     * @param int day (4) 
    282234     * @return int week number 
    283235     * @access protected 
     
    285237    function getWeekNInYear($y, $m, $d) 
    286238    { 
    287         $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d); 
    288         $date  = Calendar_Engine_UnixTS::stampCollection($stamp); 
     239        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d); 
     240        $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
    289241        return $date[7]; 
    290242    } 
     
    292244    /** 
    293245     * Returns the number of the week in the month, given a date 
    294      * 
    295      * @param int $y        year (2003) 
    296      * @param int $m        month (9) 
    297      * @param int $d        day (4) 
    298      * @param int $firstDay first day of the week (default: monday) 
    299      * 
     246     * @param int year (2003) 
     247     * @param int month (9) 
     248     * @param int day (4) 
     249     * @param int first day of the week (default: monday) 
    300250     * @return int week number 
    301251     * @access protected 
     
    303253    function getWeekNInMonth($y, $m, $d, $firstDay=1) 
    304254    { 
    305         $weekEnd = (0 == $firstDay) ? $this->getDaysInWeek()-1 : $firstDay-1; 
     255        $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1; 
    306256        $end_of_week = 1; 
    307257        while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) { 
     
    318268    /** 
    319269     * Returns the number of weeks in the month 
    320      * 
    321      * @param int $y        year (2003) 
    322      * @param int $m        month (9) 
    323      * @param int $firstDay first day of the week (default: monday) 
    324      * 
     270     * @param int year (2003) 
     271     * @param int month (9) 
     272     * @param int first day of the week (default: monday) 
    325273     * @return int weeks number 
    326274     * @access protected 
    327275     */ 
    328     function getWeeksInMonth($y, $m, $firstDay = 1) 
     276    function getWeeksInMonth($y, $m, $firstDay=1) 
    329277    { 
    330278        $FDOM = $this->getFirstDayInMonth($y, $m); 
     
    346294    /** 
    347295     * Returns the number of the day of the week (0=sunday, 1=monday...) 
    348      * 
    349      * @param int $y year (2003) 
    350      * @param int $m month (9) 
    351      * @param int $d day (4) 
    352      * 
     296     * @param int year (2003) 
     297     * @param int month (9) 
     298     * @param int day (4) 
    353299     * @return int weekday number 
    354300     * @access protected 
     
    356302    function getDayOfWeek($y, $m, $d) 
    357303    { 
    358         $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d); 
     304        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d); 
    359305        $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
    360306        return $date[8]; 
     
    363309    /** 
    364310     * Returns a list of integer days of the week beginning 0 
    365      * 
    366      * @param int $y year (2003) 
    367      * @param int $m month (9) 
    368      * @param int $d day (4) 
    369      * 
     311     * @param int year (2003) 
     312     * @param int month (9) 
     313     * @param int day (4) 
    370314     * @return array (0,1,2,3,4,5,6) 1 = Monday 
    371315     * @access protected 
    372316     */ 
    373     function getWeekDays($y=null, $m=null, $d=null) 
     317    function getWeekDays($y=NULL, $m=NULL, $d=NULL) 
    374318    { 
    375319        return array(0, 1, 2, 3, 4, 5, 6); 
     
    378322    /** 
    379323     * Returns the default first day of the week 
    380      * 
    381      * @param int $y year (2003) 
    382      * @param int $m month (9) 
    383      * @param int $d day (4) 
    384      * 
     324     * @param int year (2003) 
     325     * @param int month (9) 
     326     * @param int day (4) 
    385327     * @return int (default 1 = Monday) 
    386328     * @access protected 
    387329     */ 
    388     function getFirstDayOfWeek($y=null, $m=null, $d=null) 
     330    function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) 
    389331    { 
    390332        return 1; 
     
    393335    /** 
    394336     * Returns the number of hours in a day 
    395      * 
    396      * @param int $y year (2003) 
    397      * @param int $m month (9) 
    398      * @param int $d day (4) 
    399      * 
    400337     * @return int (24) 
    401338     * @access protected 
    402339     */ 
    403     function getHoursInDay($y=null, $m=null, $d=null) 
     340    function getHoursInDay($y=null,$m=null,$d=null) 
    404341    { 
    405342        return 24; 
     
    408345    /** 
    409346     * Returns the number of minutes in an hour 
    410      * 
    411      * @param int $y year (2003) 
    412      * @param int $m month (9) 
    413      * @param int $d day (4) 
    414      * @param int $h hour 
    415      * 
    416347     * @return int (60) 
    417348     * @access protected 
    418349     */ 
    419     function getMinutesInHour($y=null, $m=null, $d=null, $h=null) 
     350    function getMinutesInHour($y=null,$m=null,$d=null,$h=null) 
    420351    { 
    421352        return 60; 
     
    424355    /** 
    425356     * Returns the number of seconds in a minutes 
    426      * 
    427      * @param int $y year (2003) 
    428      * @param int $m month (9) 
    429      * @param int $d day (4) 
    430      * @param int $h hour 
    431      * @param int $i minute 
    432      * 
    433357     * @return int (60) 
    434358     * @access protected 
    435359     */ 
    436     function getSecondsInMinute($y=null, $m=null, $d=null, $h=null, $i=null) 
     360    function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) 
    437361    { 
    438362        return 60; 
    439     } 
    440  
    441     /** 
    442      * Checks if the given day is the current day 
    443      * 
    444      * @param mixed $stamp Any timestamp format recognized by Pear::Date 
    445      * 
    446      * @return boolean 
    447      * @access protected 
    448      */ 
    449     function isToday($stamp) 
    450     { 
    451         static $today = null; 
    452         if (is_null($today)) { 
    453             $today_date = @date('Y n j'); 
    454             $today = sscanf($today_date, '%d %d %d'); 
    455         } 
    456         $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
    457         return (   $date[2] == $today[2] 
    458                 && $date[1] == $today[1] 
    459                 && $date[0] == $today[0] 
    460         ); 
    461363    } 
    462364} 
Note: See TracChangeset for help on using the changeset viewer.