date.php.svn-base

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· SVN-BASE 代码 · 共 1,690 行 · 第 1/5 页

SVN-BASE
1,690
字号
                }                // Weekday not found                throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", $date);                break;            case Zend_Date::WEEKDAY_8601 :                $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale);                if ((intval($date) > 0) and (intval($date) < 8)) {                    return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),                                                 $this->mktime(0, 0, 0, 1, 1 + $weekday,      1970, true));                }                // Weekday not found                throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", $date);                break;            case Zend_Date::DAY_SUFFIX :                throw new Zend_Date_Exception('day suffix not supported', $date);                break;            case Zend_Date::WEEKDAY_DIGIT :                $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale);                if ((intval($date) > 0) and (intval($date) < 8)) {                    return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 2 + $date,    1970, true),                                                 $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true));                }                // Weekday not found                throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", $date);                break;            case Zend_Date::DAY_OF_YEAR :                if (is_numeric($date)) {                    return $this->_assign($calc, $this->mktime(0, 0, 0, 1,      1 + $date, 1970, true),                                                 $this->mktime(0, 0, 0, $month, 1 + $day,  1970, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, day expected", $date);                break;            case Zend_Date::WEEKDAY_NARROW :                $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'format', 'abbreviated'));                $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale);                $cnt = 0;                foreach ($daylist as $key => $value) {                    if (strtoupper(substr($value, 0, 1)) == strtoupper($date)) {                        $found = $cnt;                        break;                    }                    ++$cnt;                }                // Weekday found                if ($cnt < 7) {                    return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found,   1970, true),                                                 $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true));                }                // Weekday not found                throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", $date);                break;            case Zend_Date::WEEKDAY_NAME :                $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'format', 'abbreviated'));                $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale);                $cnt = 0;                foreach ($daylist as $key => $value) {                    if (strtoupper($value) == strtoupper($date)) {                        $found = $cnt;                        break;                    }                    ++$cnt;                }                // Weekday found                if ($cnt < 7) {                    return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found,   1970, true),                                                 $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true));                }                // Weekday not found                throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", $date);                break;            // week formats            case Zend_Date::WEEK :                if (is_numeric($date)) {                    $week = (int) $this->get(Zend_Date::WEEK, $locale);                    return $this->_assign($calc, parent::mktime(0, 0, 0, 1, 1 + ($date * 7), 1970, true),                                                 parent::mktime(0, 0, 0, 1, 1 + ($week * 7), 1970, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, week expected", $date);                break;            // month formats            case Zend_Date::MONTH_NAME :                $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'format', 'wide'));                $cnt = 0;                foreach ($monthlist as $key => $value) {                    if (strtoupper($value) == strtoupper($date)) {                        $found = $key;                        break;                    }                    ++$cnt;                }                $date = array_search($date, $monthlist);                // Monthname found                if ($cnt < 12) {                    if ($calc == 'add') {                        $date += $found;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $month - $found;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $date,  $day, $year, true),                                                 $this->mktime(0, 0, 0, $month, $day, $year, true));                }                // Monthname not found                throw new Zend_Date_Exception("invalid date ($date) operand, month expected", $date);                break;            case Zend_Date::MONTH :                if (is_numeric($date)) {                    if ($calc == 'add') {                        $date += $month;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $month - $date;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day, $year, true),                                                 $this->mktime(0, 0, 0, $month,        $day, $year, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, month expected", $date);                break;            case Zend_Date::MONTH_NAME_SHORT :                $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'format', 'abbreviated'));                $cnt = 0;                foreach ($monthlist as $key => $value) {                    if (strtoupper($value) == strtoupper($date)) {                        $found = $key;                        break;                    }                    ++$cnt;                }                $date = array_search($date, $monthlist);                // Monthname found                if ($cnt < 12) {                    if ($calc == 'add') {                        $date += $found;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $month - $found;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $date,  $day, $year, true),                                                 $this->mktime(0, 0, 0, $month, $day, $year, true));                }                // Monthname not found                throw new Zend_Date_Exception("invalid date ($date) operand, month expected", $date);                break;            case Zend_Date::MONTH_SHORT :                if (is_numeric($date)) {                    if ($calc == 'add') {                        $date += $month;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $month - $date;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $date,  $day, $year, true),                                                 $this->mktime(0, 0, 0, $month, $day, $year, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, month expected", $date);                break;            case Zend_Date::MONTH_DAYS :                throw new Zend_Date_Exception('month days not supported', $date);                break;            case Zend_Date::MONTH_NAME_NARROW :                $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'stand-alone', 'narrow'));                $cnt = 0;                foreach ($monthlist as $key => $value) {                    if (strtoupper($value) == strtoupper($date)) {                        $found = $key;                        break;                    }                    ++$cnt;                }                $date = array_search($date, $monthlist);                                // Monthname found                if ($cnt < 12) {                    if ($calc == 'add') {                        $date += $found;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $month - $found;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $date,  $day, $year, true),                                                 $this->mktime(0, 0, 0, $month, $day, $year, true));                }                // Monthname not found                throw new Zend_Date_Exception("invalid date ($date) operand, month expected", $date);                break;            // year formats            case Zend_Date::LEAPYEAR :                throw new Zend_Date_Exception('leap year not supported', $date);                break;            case Zend_Date::YEAR_8601 :                if (is_numeric($date)) {                    if ($calc == 'add') {                        $date += $year;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $year - $date;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),                                                 $this->mktime(0, 0, 0, $month, $day, $year,         true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, year expected", $date);                break;            case Zend_Date::YEAR :                if (is_numeric($date)) {                    if ($calc == 'add') {                        $date += $year;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $year - $date;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),                                                 $this->mktime(0, 0, 0, $month, $day, $year,         true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, year expected", $date);                break;            case Zend_Date::YEAR_SHORT :                if (is_numeric($date)) {                    $date = intval($date);                    if (($date >= 0) and ($date <= 100) and ($calc == 'set')) {                        $date += 1900;                        if ($date < 1970) {                            $date += 100;                        }                    }                    if ($calc == 'add') {                        $date += $year;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $year - $date;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true),                                                 $this->mktime(0, 0, 0, $month, $day, $year, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, year expected", $date);                break;            case Zend_Date::YEAR_SHORT_8601 :                if (is_numeric($date)) {                    $date = intval($date);                    if (($date >= 0) and ($date <= 100) and ($calc == 'set')) {                        $date += 1900;                        if ($date < 1970) {                            $date += 100;                        }                    }                    if ($calc == 'add') {                        $date += $year;                        $calc = 'set';                    } else if ($calc == 'sub') {                        $date = $year - $date;                        $calc = 'set';                    }                    return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true),                                                 $this->mktime(0, 0, 0, $month, $day, $year, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, year expected", $date);                break;            // time formats            case Zend_Date::MERIDIEM :                throw new Zend_Date_Exception('meridiem not supported', $date);                break;            case Zend_Date::SWATCH :                if (is_numeric($date)) {                    $rest = intval($date);                    $hours = floor($rest * 24 / 1000);                    $rest = $rest - ($hours * 1000 / 24);                    $minutes = floor($rest * 1440 / 1000);                    $rest = $rest - ($minutes * 1000 / 1440);                    $seconds = floor($rest * 86400 / 1000);                    return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1, 1, 1970, true),                                                 $this->mktime($hour,  $minute,  $second,  1, 1, 1970, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, swatchstamp expected", $date);                break;            case Zend_Date::HOUR_SHORT_AM :                if (is_numeric($date)) {                    return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),                                                 $this->mktime($hour,         0, 0, 1, 1, 1970, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", $date);                break;            case Zend_Date::HOUR_SHORT :                if (is_numeric($date)) {                    return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),                                                 $this->mktime($hour,         0, 0, 1, 1, 1970, true));                }                throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", $date);                break;            case Zend_Date::HOUR_AM :                if (is_numeric($date)) 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?