| version 1.1, 2005/06/05 12:13:52 |
version 1.2, 2005/11/07 20:37:10 |
|
|
| <?php |
<?php |
| /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
|
| // +----------------------------------------------------------------------+ |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
| // | PHP Version 4 | |
|
| // +----------------------------------------------------------------------+ |
/** |
| // | Copyright (c) 1997-2003 The PHP Group | |
* Generic date handling class for PEAR |
| // +----------------------------------------------------------------------+ |
* |
| // | This source file is subject to version 2.02 of the PHP license, | |
* Generic date handling class for PEAR. Attempts to be time zone aware |
| // | that is bundled with this package in the file LICENSE, and is | |
* through the Date::TimeZone class. Supports several operations from |
| // | available at through the world-wide-web at | |
* Date::Calc on Date objects. |
| // | http://www.php.net/license/2_02.txt. | |
* |
| // | If you did not receive a copy of the PHP license and are unable to | |
* PHP versions 4 and 5 |
| // | obtain it through the world-wide-web, please send a note to | |
* |
| // | license@php.net so we can mail you a copy immediately. | |
* LICENSE: This source file is subject to version 2.02 of the PHP license |
| // +----------------------------------------------------------------------+ |
* that is available through the world-wide-web at the following URI: |
| // | Authors: Baba Buehler <baba@babaz.com> | |
* http://www.php.net/license/2_02.txt. If you did not receive a copy of |
| // | Pierre-Alain Joye <pajoye@php.net> | |
* the PHP License and are unable to obtain it through the web, please |
| // +----------------------------------------------------------------------+ |
* send a note to license@php.net so we can mail you a copy immediately. |
| // |
* |
| // $Id$ |
* @category Date and Time |
| |
* @package Date |
| |
* @author Baba Buehler <baba@babaz.com> |
| |
* @author Pierre-Alain Joye <pajoye@php.net> |
| |
* @copyright 1997-2005 The PHP Group |
| |
* @license http://www.php.net/license/2_02.txt PHP License |
| |
* @version CVS: $Id$ |
| |
* @link http://pear.php.net/package/Date |
| |
*/ |
| |
|
| /**@#+ |
/**@#+ |
| * Include supporting classes |
* Include supporting classes |
| Line 57 define('DATE_FORMAT_UNIXTIME', 5); |
|
| Line 65 define('DATE_FORMAT_UNIXTIME', 5); |
|
| /**@#-*/ |
/**@#-*/ |
| |
|
| /** |
/** |
| * Generic date handling class for PEAR. |
* Generic date handling class for PEAR |
| * |
* |
| * Generic date handling class for PEAR. Attempts to be time zone aware |
* Generic date handling class for PEAR. Attempts to be time zone aware |
| * through the Date::TimeZone class. Supports several operations from |
* through the Date::TimeZone class. Supports several operations from |
| * Date::Calc on Date objects. |
* Date::Calc on Date objects. |
| * |
* |
| * @author Baba Buehler <baba@babaz.com> |
* @author Baba Buehler <baba@babaz.com> |
| * @package Date |
* @author Pierre-Alain Joye <pajoye@php.net> |
| * @access public |
* @copyright 1997-2005 The PHP Group |
| |
* @license http://www.php.net/license/2_02.txt PHP License |
| |
* @version Release: 1.4.5 |
| |
* @link http://pear.php.net/package/Date |
| */ |
*/ |
| class Date |
class Date |
| { |
{ |
|
|
| * @var float |
* @var float |
| */ |
*/ |
| var $partsecond; |
var $partsecond; |
| |
|
| /** |
/** |
| * timezone for this date |
* timezone for this date |
| * @var object Date_TimeZone |
* @var object Date_TimeZone |
| */ |
*/ |
| var $tz; |
var $tz; |
| |
|
| |
/** |
| |
* define the default weekday abbreviation length |
| |
* used by ::format() |
| |
* @var int |
| |
*/ |
| |
var $getWeekdayAbbrnameLength = 3; |
| |
|
| |
|
| /** |
/** |
| * Constructor |
* Constructor |
|
|
| $nextchar = substr($format,$strpos + 1,1); |
$nextchar = substr($format,$strpos + 1,1); |
| switch ($nextchar) { |
switch ($nextchar) { |
| case "a": |
case "a": |
| $output .= Date_Calc::getWeekdayAbbrname($this->day,$this->month,$this->year); |
$output .= Date_Calc::getWeekdayAbbrname($this->day,$this->month,$this->year, $this->getWeekdayAbbrnameLength); |
| break; |
break; |
| case "A": |
case "A": |
| $output .= Date_Calc::getWeekdayFullname($this->day,$this->month,$this->year); |
$output .= Date_Calc::getWeekdayFullname($this->day,$this->month,$this->year); |
|
|
| case "H": |
case "H": |
| $output .= sprintf("%02d", $this->hour); |
$output .= sprintf("%02d", $this->hour); |
| break; |
break; |
| |
case 'h': |
| |
$output .= sprintf("%d", $this->hour); |
| |
break; |
| case "I": |
case "I": |
| $hour = ($this->hour + 1) > 12 ? $this->hour - 12 : $this->hour; |
$hour = ($this->hour + 1) > 12 ? $this->hour - 12 : $this->hour; |
| $output .= sprintf("%02d", $hour==0 ? 12 : $hour); |
$output .= sprintf("%02d", $hour==0 ? 12 : $hour); |
| break; |
break; |
| |
case "i": |
| |
$hour = ($this->hour + 1) > 12 ? $this->hour - 12 : $this->hour; |
| |
$output .= sprintf("%d", $hour==0 ? 12 : $hour); |
| |
break; |
| case "j": |
case "j": |
| $output .= Date_Calc::julianDate($this->day,$this->month,$this->year); |
$output .= Date_Calc::julianDate($this->day,$this->month,$this->year); |
| break; |
break; |
|
|
| $output .= sprintf("%02d:%02d", $this->hour, $this->minute); |
$output .= sprintf("%02d:%02d", $this->hour, $this->minute); |
| break; |
break; |
| case "s": |
case "s": |
| $output .= sprintf("%02f", (float)((float)$this->second + $this->partsecond)); |
$output .= str_replace(',', '.', sprintf("%09f", (float)((float)$this->second + $this->partsecond))); |
| break; |
break; |
| case "S": |
case "S": |
| $output .= sprintf("%02d", $this->second); |
$output .= sprintf("%02d", $this->second); |
|
|
| */ |
*/ |
| function getYear() |
function getYear() |
| { |
{ |
| return $this->year; |
return (int)$this->year; |
| } |
} |
| |
|
| /** |
/** |
|
|
| */ |
*/ |
| function getMonth() |
function getMonth() |
| { |
{ |
| return $this->month; |
return (int)$this->month; |
| } |
} |
| |
|
| /** |
/** |
|
|
| $this->second = $s; |
$this->second = $s; |
| } |
} |
| } |
} |
| |
} |
| |
|
| } // Date |
|
| |
|
| |
|
| // |
|
| // END |
|
| ?> |
?> |