Ignore:
Timestamp:
2013/08/26 12:42:34 (11 years ago)
Author:
kimoto
Message:

#2275 PEAR更新
不要なrequire_onceの削除
レガシーなPEARモジュールは使わない
SearchReplace?.phpのパスが間違っているので修正

File:
1 edited

Legend:

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

    r20119 r23125  
    11<?php 
    22/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
    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 // | license@php.net so we can mail you a copy immediately.               | 
    16 // +----------------------------------------------------------------------+ 
    17 // | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      | 
    18 // +----------------------------------------------------------------------+ 
    19 // 
    20 // $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $ 
    21 // 
     3 
    224/** 
    23  * @package Calendar 
    24  * @version $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $ 
     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 <hfuecks@phppatterns.com> 
     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 
    2537 */ 
     38 
    2639/** 
    2740 * Performs calendar calculations based on the PHP date() function and 
    2841 * Unix timestamps (using PHP's mktime() function). 
    29  * @package Calendar 
    30  * @access protected 
     42 * 
     43 * @category  Date and Time 
     44 * @package   Calendar 
     45 * @author    Harry Fuecks <hfuecks@phppatterns.com> 
     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 
    3150 */ 
    3251class Calendar_Engine_UnixTS /* implements Calendar_Engine_Interface */ 
     
    4968     * Uses a static variable to prevent date() being used twice 
    5069     * for a date which is already known 
    51      * @param int Unix timestamp 
     70     * 
     71     * @param int $stamp Unix timestamp 
     72     * 
    5273     * @return array 
    5374     * @access protected 
     
    5778        static $stamps = array(); 
    5879        if ( !isset($stamps[$stamp]) ) { 
    59             $date = @date('Y n j H i s t W w',$stamp); 
     80            $date = @date('Y n j H i s t W w', $stamp); 
    6081            $stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d"); 
    6182        } 
     
    6586    /** 
    6687     * Returns a numeric year given a timestamp 
    67      * @param int Unix timestamp 
     88     * 
     89     * @param int $stamp Unix timestamp 
     90     * 
    6891     * @return int year (e.g. 2003) 
    6992     * @access protected 
     
    77100    /** 
    78101     * Returns a numeric month given a timestamp 
    79      * @param int Unix timestamp 
     102     * 
     103     * @param int $stamp Unix timestamp 
     104     * 
    80105     * @return int month (e.g. 9) 
    81106     * @access protected 
     
    89114    /** 
    90115     * Returns a numeric day given a timestamp 
    91      * @param int Unix timestamp 
     116     * 
     117     * @param int $stamp Unix timestamp 
     118     * 
    92119     * @return int day (e.g. 15) 
    93120     * @access protected 
     
    101128    /** 
    102129     * Returns a numeric hour given a timestamp 
    103      * @param int Unix timestamp 
     130     * 
     131     * @param int $stamp Unix timestamp 
     132     * 
    104133     * @return int hour (e.g. 13) 
    105134     * @access protected 
     
    113142    /** 
    114143     * Returns a numeric minute given a timestamp 
    115      * @param int Unix timestamp 
     144     * 
     145     * @param int $stamp Unix timestamp 
     146     * 
    116147     * @return int minute (e.g. 34) 
    117148     * @access protected 
     
    125156    /** 
    126157     * Returns a numeric second given a timestamp 
    127      * @param int Unix timestamp 
     158     * 
     159     * @param int $stamp Unix timestamp 
     160     * 
    128161     * @return int second (e.g. 51) 
    129162     * @access protected 
     
    137170    /** 
    138171     * Returns a timestamp 
    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) 
     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     * 
    145180     * @return int Unix timestamp 
    146181     * @access protected 
     
    149184    { 
    150185        static $dates = array(); 
    151         if ( !isset($dates[$y][$m][$d][$h][$i][$s]) ) { 
     186        if (!isset($dates[$y][$m][$d][$h][$i][$s])) { 
    152187            $dates[$y][$m][$d][$h][$i][$s] = @mktime($h, $i, $s, $m, $d, $y); 
    153188        } 
     
    157192    /** 
    158193     * The upper limit on years that the Calendar Engine can work with 
     194     * 
    159195     * @return int (2037) 
    160196     * @access protected 
     
    167203    /** 
    168204     * The lower limit on years that the Calendar Engine can work with 
     205     * 
    169206     * @return int (1970 if it's Windows and 1902 for all other OSs) 
    170207     * @access protected 
     
    177214    /** 
    178215     * Returns the number of months in a year 
     216     * 
     217     * @param int $y year 
     218     * 
    179219     * @return int (12) 
    180     * @access protected 
     220     * @access protected 
    181221     */ 
    182222    function getMonthsInYear($y=null) 
     
    187227    /** 
    188228     * Returns the number of days in a month, given year and month 
    189      * @param int year (2003) 
    190      * @param int month (9) 
     229     * 
     230     * @param int $y year (2003) 
     231     * @param int $m month (9) 
     232     * 
    191233     * @return int days in month 
    192234     * @access protected 
     
    194236    function getDaysInMonth($y, $m) 
    195237    { 
    196         $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1); 
    197         $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
     238        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1); 
     239        $date  = Calendar_Engine_UnixTS::stampCollection($stamp); 
    198240        return $date[6]; 
    199241    } 
     
    202244     * Returns numeric representation of the day of the week in a month, 
    203245     * given year and month 
    204      * @param int year (2003) 
    205      * @param int month (9) 
     246     * 
     247     * @param int $y year (2003) 
     248     * @param int $m month (9) 
     249     * 
    206250     * @return int from 0 to 6 
    207251     * @access protected 
     
    209253    function getFirstDayInMonth($y, $m) 
    210254    { 
    211         $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1); 
    212         $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
     255        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1); 
     256        $date  = Calendar_Engine_UnixTS::stampCollection($stamp); 
    213257        return $date[8]; 
    214258    } 
     
    216260    /** 
    217261     * Returns the number of days in a week 
    218      * @param int year (2003) 
    219      * @param int month (9) 
    220      * @param int day (4) 
     262     * 
     263     * @param int $y year (2003) 
     264     * @param int $m month (9) 
     265     * @param int $d day (4) 
     266     * 
    221267     * @return int (7) 
    222268     * @access protected 
    223269     */ 
    224     function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) 
     270    function getDaysInWeek($y=null, $m=null, $d=null) 
    225271    { 
    226272        return 7; 
     
    229275    /** 
    230276     * Returns the number of the week in the year (ISO-8601), given a date 
    231      * @param int year (2003) 
    232      * @param int month (9) 
    233      * @param int day (4) 
     277     * 
     278     * @param int $y year (2003) 
     279     * @param int $m month (9) 
     280     * @param int $d day (4) 
     281     * 
    234282     * @return int week number 
    235283     * @access protected 
     
    237285    function getWeekNInYear($y, $m, $d) 
    238286    { 
    239         $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d); 
    240         $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
     287        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d); 
     288        $date  = Calendar_Engine_UnixTS::stampCollection($stamp); 
    241289        return $date[7]; 
    242290    } 
     
    244292    /** 
    245293     * Returns the number of the week in the month, given a date 
    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) 
     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     * 
    250300     * @return int week number 
    251301     * @access protected 
     
    253303    function getWeekNInMonth($y, $m, $d, $firstDay=1) 
    254304    { 
    255         $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1; 
     305        $weekEnd = (0 == $firstDay) ? $this->getDaysInWeek()-1 : $firstDay-1; 
    256306        $end_of_week = 1; 
    257307        while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) { 
     
    268318    /** 
    269319     * Returns the number of weeks in the month 
    270      * @param int year (2003) 
    271      * @param int month (9) 
    272      * @param int first day of the week (default: monday) 
     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     * 
    273325     * @return int weeks number 
    274326     * @access protected 
    275327     */ 
    276     function getWeeksInMonth($y, $m, $firstDay=1) 
     328    function getWeeksInMonth($y, $m, $firstDay = 1) 
    277329    { 
    278330        $FDOM = $this->getFirstDayInMonth($y, $m); 
     
    294346    /** 
    295347     * Returns the number of the day of the week (0=sunday, 1=monday...) 
    296      * @param int year (2003) 
    297      * @param int month (9) 
    298      * @param int day (4) 
     348     * 
     349     * @param int $y year (2003) 
     350     * @param int $m month (9) 
     351     * @param int $d day (4) 
     352     * 
    299353     * @return int weekday number 
    300354     * @access protected 
     
    302356    function getDayOfWeek($y, $m, $d) 
    303357    { 
    304         $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d); 
     358        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d); 
    305359        $date = Calendar_Engine_UnixTS::stampCollection($stamp); 
    306360        return $date[8]; 
     
    309363    /** 
    310364     * Returns a list of integer days of the week beginning 0 
    311      * @param int year (2003) 
    312      * @param int month (9) 
    313      * @param int day (4) 
     365     * 
     366     * @param int $y year (2003) 
     367     * @param int $m month (9) 
     368     * @param int $d day (4) 
     369     * 
    314370     * @return array (0,1,2,3,4,5,6) 1 = Monday 
    315371     * @access protected 
    316372     */ 
    317     function getWeekDays($y=NULL, $m=NULL, $d=NULL) 
     373    function getWeekDays($y=null, $m=null, $d=null) 
    318374    { 
    319375        return array(0, 1, 2, 3, 4, 5, 6); 
     
    322378    /** 
    323379     * Returns the default first day of the week 
    324      * @param int year (2003) 
    325      * @param int month (9) 
    326      * @param int day (4) 
     380     * 
     381     * @param int $y year (2003) 
     382     * @param int $m month (9) 
     383     * @param int $d day (4) 
     384     * 
    327385     * @return int (default 1 = Monday) 
    328386     * @access protected 
    329387     */ 
    330     function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) 
     388    function getFirstDayOfWeek($y=null, $m=null, $d=null) 
    331389    { 
    332390        return 1; 
     
    335393    /** 
    336394     * 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     * 
    337400     * @return int (24) 
    338401     * @access protected 
    339402     */ 
    340     function getHoursInDay($y=null,$m=null,$d=null) 
     403    function getHoursInDay($y=null, $m=null, $d=null) 
    341404    { 
    342405        return 24; 
     
    345408    /** 
    346409     * 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     * 
    347416     * @return int (60) 
    348417     * @access protected 
    349418     */ 
    350     function getMinutesInHour($y=null,$m=null,$d=null,$h=null) 
     419    function getMinutesInHour($y=null, $m=null, $d=null, $h=null) 
    351420    { 
    352421        return 60; 
     
    355424    /** 
    356425     * 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     * 
    357433     * @return int (60) 
    358434     * @access protected 
    359435     */ 
    360     function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) 
     436    function getSecondsInMinute($y=null, $m=null, $d=null, $h=null, $i=null) 
    361437    { 
    362438        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        ); 
    363461    } 
    364462} 
Note: See TracChangeset for help on using the changeset viewer.