[CORE] Fixed some small issues with PEAR
This commit is contained in:
parent
d9e7862cea
commit
7d262ad50b
3
Makefile
3
Makefile
|
@ -7,6 +7,9 @@ plugin_mo = $(patsubst %.po,%.mo,$(wildcard plugins/*/locale/*/LC_MESSAGES/*.po)
|
|||
|
||||
translations : $(core_mo) $(plugin_mo)
|
||||
|
||||
upgrade :
|
||||
php scripts/upgrade.php
|
||||
|
||||
clean :
|
||||
rm -f $(core_mo) $(plugin_mo)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"michelf/php-markdown": "^1.8.0",
|
||||
"openid/php-openid": "^2.3",
|
||||
"paragonie/constant_time_encoding": "^1.0.4",
|
||||
"pear/console_getopt": "^1.4",
|
||||
"phpseclib/phpseclib": "dev-master#f815e43077da67d3dd5b4d18a45753f5b79c1ab9",
|
||||
"stomp-php/stomp-php": "^4.5.1"
|
||||
},
|
||||
|
|
49
composer.lock
generated
49
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "443e1729de86d54a2d4e4707b15ad41d",
|
||||
"content-hash": "f84a3a1654cf40103976cea8b2365b8c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "apereo/phpcas",
|
||||
|
@ -682,6 +682,53 @@
|
|||
],
|
||||
"time": "2019-01-03T20:59:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pear/console_getopt",
|
||||
"version": "v1.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pear/Console_Getopt.git",
|
||||
"reference": "6c77aeb625b32bd752e89ee17972d103588b90c0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pear/Console_Getopt/zipball/6c77aeb625b32bd752e89ee17972d103588b90c0",
|
||||
"reference": "6c77aeb625b32bd752e89ee17972d103588b90c0",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Console": "./"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
"./"
|
||||
],
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Beaver",
|
||||
"email": "cellog@php.net",
|
||||
"role": "Helper"
|
||||
},
|
||||
{
|
||||
"name": "Andrei Zmievski",
|
||||
"email": "andrei@php.net",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"name": "Stig Bakken",
|
||||
"email": "stig@php.net",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "More info available on: http://pear.php.net/package/Console_Getopt",
|
||||
"time": "2019-02-06T16:52:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "dev-master",
|
||||
|
|
6672
extlib/Date.php
6672
extlib/Date.php
File diff suppressed because it is too large
Load Diff
4728
extlib/Date/Calc.php
4728
extlib/Date/Calc.php
File diff suppressed because it is too large
Load Diff
|
@ -1,242 +0,0 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
||||
|
||||
// {{{ Header
|
||||
|
||||
/**
|
||||
* Class to convert date strings between Gregorian and Human calendar formats
|
||||
*
|
||||
* The Human Calendar format has been proposed by Scott Flansburg and can be
|
||||
* explained as follows:
|
||||
* The year is made up of 13 months
|
||||
* Each month has 28 days
|
||||
* Counting of months starts from 0 (zero) so the months will run from 0 to 12
|
||||
* New Years day (00) is a monthless day
|
||||
* Note: Leap Years are not yet accounted for in the Human Calendar system
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 1997-2006 Allan Kent
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted under the terms of the BSD License.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Date and Time
|
||||
* @package Date
|
||||
* @author Allan Kent <allan@lodestone.co.za>
|
||||
* @copyright 1997-2006 Allan Kent
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Date
|
||||
* @since File available since Release 1.3
|
||||
*/
|
||||
|
||||
// }}}
|
||||
// {{{ Class: Date_Human
|
||||
|
||||
/**
|
||||
* Class to convert date strings between Gregorian and Human calendar formats
|
||||
*
|
||||
* The Human Calendar format has been proposed by Scott Flansburg and can be
|
||||
* explained as follows:
|
||||
* The year is made up of 13 months
|
||||
* Each month has 28 days
|
||||
* Counting of months starts from 0 (zero) so the months will run from 0 to 12
|
||||
* New Years day (00) is a monthless day
|
||||
* Note: Leap Years are not yet accounted for in the Human Calendar system
|
||||
*
|
||||
* @category Date and Time
|
||||
* @package Date
|
||||
* @author Allan Kent <allan@lodestone.co.za>
|
||||
* @copyright 1997-2005 Allan Kent
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* BSD License
|
||||
* @version Release: 1.5.0a4
|
||||
* @link http://pear.php.net/package/Date
|
||||
* @since Class available since Release 1.3
|
||||
*/
|
||||
class Date_Human
|
||||
{
|
||||
// {{{ gregorianToHuman()
|
||||
|
||||
/**
|
||||
* Returns an associative array containing the converted date information
|
||||
* in 'Human Calendar' format.
|
||||
*
|
||||
* If the day is New Years Day, the function will return
|
||||
* "hdom" => 0
|
||||
* "hdow" => 0
|
||||
* "hwom" => 0
|
||||
* "hwoy" => 0
|
||||
* "hmoy" => -1
|
||||
* Since 0 is a valid month number under the Human Calendar, I have left
|
||||
* the month as -1 for New Years Day.
|
||||
*
|
||||
* @param int $day in DD format, default current local day
|
||||
* @param int $month in MM format, default current local month
|
||||
* @param int $year in CCYY format, default to current local year
|
||||
*
|
||||
* @return associative array(
|
||||
* hdom, // Human Day Of Month, starting at 1
|
||||
* hdow, // Human Day Of Week, starting at 1
|
||||
* hwom, // Human Week of Month, starting at 1
|
||||
* hwoy, // Human Week of Year, starting at 1
|
||||
* hmoy, // Human Month of Year, starting at 0
|
||||
* )
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
public function gregorianToHuman($day = 0, $month = 0, $year = 0)
|
||||
{
|
||||
/*
|
||||
* Check to see if any of the arguments are empty
|
||||
* If they are then populate the $dateinfo array
|
||||
* Then check to see which arguments are empty and fill
|
||||
* those with the current date info
|
||||
*/
|
||||
if ((empty($day) || (empty($month)) || empty($year))) {
|
||||
$dateinfo = getdate(time());
|
||||
}
|
||||
if (empty($day)) {
|
||||
$day = $dateinfo["mday"];
|
||||
}
|
||||
if (empty($month)) {
|
||||
$month = $dateinfo["mon"];
|
||||
}
|
||||
if (empty($year)) {
|
||||
$year = $dateinfo["year"];
|
||||
}
|
||||
/*
|
||||
* We need to know how many days into the year we are
|
||||
*/
|
||||
$dateinfo = getdate(mktime(0, 0, 0, $month, $day, $year));
|
||||
$dayofyear = $dateinfo["yday"];
|
||||
/*
|
||||
* Human Calendar starts at 0 for months and the first day of the year
|
||||
* is designated 00, so we need to start our day of the year at 0 for
|
||||
* these calculations.
|
||||
* Also, the day of the month is calculated with a modulus of 28.
|
||||
* Because a day is 28 days, the last day of the month would have a
|
||||
* remainder of 0 and not 28 as it should be. Decrementing $dayofyear
|
||||
* gets around this.
|
||||
*/
|
||||
$dayofyear--;
|
||||
/*
|
||||
* 28 days in a month...
|
||||
*/
|
||||
$humanMonthOfYear = floor($dayofyear / 28);
|
||||
/*
|
||||
* If we are in the first month then the day of the month is $dayofyear
|
||||
* else we need to find the modulus of 28.
|
||||
*/
|
||||
if ($humanMonthOfYear == 0) {
|
||||
$humanDayOfMonth = $dayofyear;
|
||||
} else {
|
||||
$humanDayOfMonth = ($dayofyear) % 28;
|
||||
}
|
||||
/*
|
||||
* Day of the week is modulus 7
|
||||
*/
|
||||
$humanDayOfWeek = $dayofyear % 7;
|
||||
/*
|
||||
* We can now increment $dayofyear back to it's correct value for
|
||||
* the remainder of the calculations
|
||||
*/
|
||||
$dayofyear++;
|
||||
/*
|
||||
* $humanDayOfMonth needs to be incremented now - recall that we fudged
|
||||
* it a bit by decrementing $dayofyear earlier
|
||||
* Same goes for $humanDayOfWeek
|
||||
*/
|
||||
$humanDayOfMonth++;
|
||||
$humanDayOfWeek++;
|
||||
/*
|
||||
* Week of the month is day of the month divided by 7, rounded up
|
||||
* Same for week of the year, but use $dayofyear instead $humanDayOfMonth
|
||||
*/
|
||||
$humanWeekOfMonth = ceil($humanDayOfMonth / 7);
|
||||
$humanWeekOfYear = ceil($dayofyear / 7);
|
||||
/*
|
||||
* Return an associative array of the values
|
||||
*/
|
||||
return array("hdom" => $humanDayOfMonth,
|
||||
"hdow" => $humanDayOfWeek,
|
||||
"hwom" => $humanWeekOfMonth,
|
||||
"hwoy" => $humanWeekOfYear,
|
||||
"hmoy" => $humanMonthOfYear);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ humanToGregorian()
|
||||
|
||||
/**
|
||||
* Returns unix timestamp for a given Human Calendar date
|
||||
*
|
||||
* @param int $day in DD format
|
||||
* @param int $month in MM format
|
||||
* @param int $year in CCYY format, default to current local year
|
||||
*
|
||||
* @return int unix timestamp of date
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
public function humanToGregorian($day, $month, $year = 0)
|
||||
{
|
||||
/*
|
||||
* Check to see if the year has been passed through.
|
||||
* If not get current year
|
||||
*/
|
||||
if (empty($year)) {
|
||||
$dateinfo = getdate(time());
|
||||
$year = $dateinfo["year"];
|
||||
}
|
||||
/*
|
||||
* We need to get the day of the year that we are currently at so that
|
||||
* we can work out the Gregorian Month and day
|
||||
*/
|
||||
$DayOfYear = $month * 28;
|
||||
$DayOfYear += $day;
|
||||
/*
|
||||
* Human Calendar starts at 0, so we need to increment $DayOfYear
|
||||
* to take into account the day 00
|
||||
*/
|
||||
$DayOfYear++;
|
||||
/*
|
||||
* the mktime() function will correctly calculate the date for out of
|
||||
* range values, so putting $DayOfYear instead of the day of the month
|
||||
* will work fine.
|
||||
*/
|
||||
$GregorianTimeStamp = mktime(0, 0, 0, 1, $DayOfYear, $year);
|
||||
return $GregorianTimeStamp;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: php
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
1181
extlib/Date/Span.php
1181
extlib/Date/Span.php
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +0,0 @@
|
|||
Copyright (c) 1997-2006 Baba Buehler, Pierre-Alain Joye
|
||||
All rights reserved
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of Baba Buehler, Pierre-Alain Joye nor the names of
|
||||
contributors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,12 +0,0 @@
|
|||
$Id$
|
||||
|
||||
TODO
|
||||
|
||||
- Fix once the timezone problem
|
||||
- Once TZ works nicely, update the testunit_date and use
|
||||
the real timezone and dct to check the expected time offset
|
||||
- Clean the test cases and atomic display instead of a global ok or failed
|
||||
- Write the docs....
|
||||
- More strict complaint againts ISO 8601
|
||||
- Complaint againts RFC 822 Date and Time Specification
|
||||
- Complaint againts ISO 3339
|
|
@ -1,137 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Date Example</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style>
|
||||
span.code {
|
||||
font-family: Monospace;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
require_once "Date.php";
|
||||
|
||||
function echo_code($ps_date)
|
||||
{
|
||||
echo '<span class="code">' . $ps_date . "</span><br />\n";
|
||||
}
|
||||
|
||||
|
||||
$date = new Date();
|
||||
|
||||
|
||||
?>
|
||||
<h4>Object is set to currrent time and local time zone by default:</h4>
|
||||
<?php
|
||||
|
||||
echo_code($date->format('%d/%m/%Y %H.%M.%S%O (%Z)'));
|
||||
echo_code($date->format2('DD/MM/YYYY HH.MI.SSTZO (TZC - TZN)'));
|
||||
echo_code($date->getDate(DATE_FORMAT_ISO));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Set date to 1st February, 1991:</h4>
|
||||
<?php
|
||||
|
||||
$date->setDate("1991-02-01 01:02:03");
|
||||
|
||||
echo_code($date->format('%d/%m/%Y %H.%M.%S'));
|
||||
echo_code($date->format2('DD/MM/YYYY HH.MI.SS'));
|
||||
|
||||
// Display day, month spelled out:
|
||||
//
|
||||
echo_code($date->format('%A, %e %B %Y, %H.%M.%S'));
|
||||
echo_code($date->format2('NPDay, NPDDth Month YYYY, HH.MI.SS'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Time without padding (i.e. leading noughts), and with short year:</h4>
|
||||
<?php
|
||||
|
||||
echo_code($date->format('%e/%m/%y %h.%M.%S'));
|
||||
echo_code($date->format2('NPDD/NPMM/YY NPHH.MI.SS'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Conversion to another time zone:</h4>
|
||||
<?php
|
||||
|
||||
$date->convertTZbyID("Asia/Calcutta");
|
||||
|
||||
echo_code($date->format2('"Time zone ID:" TZR'));
|
||||
echo_code($date->format2('"Time zone name:" TZN'));
|
||||
echo_code($date->format2('"Time zone code:" TZC'));
|
||||
echo_code($date->format2('"Time zone offset:" TZO'));
|
||||
echo "<br />\n";
|
||||
echo_code($date->format2('DD/MM/YYYY HH.MI.SSTZO (TZC)'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Addition/Subtraction:</h4>
|
||||
<?php
|
||||
|
||||
$date->addDays(-1);
|
||||
echo_code($date->format2('DD/MM/YYYY HH.MI.SS'));
|
||||
|
||||
$date->addHours(13);
|
||||
echo_code($date->format2('DD/MM/YYYY HH.MI.SS'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>12-hour time:</h4>
|
||||
<?php
|
||||
|
||||
echo_code($date->format('%d/%m/%Y %I.%M.%S %p'));
|
||||
echo_code($date->format2('DD/MM/YYYY HH12.MI.SS am'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Display micro-time:</h4>
|
||||
<?php
|
||||
|
||||
$date->setSecond(3.201282);
|
||||
|
||||
echo_code($date->format('%d/%m/%Y %I.%M.%s'));
|
||||
echo_code($date->format2('DD/MM/YYYY HH12.MI.SS.FFFFFF'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Convert to Unix time:</h4>
|
||||
<?php
|
||||
|
||||
echo_code($hn_unixtime = $date->format2('U'));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Convert Unix time back to Date object:</h4>
|
||||
<?php
|
||||
|
||||
$date2 = new Date($hn_unixtime);
|
||||
|
||||
echo_code($date2->format2("DD/MM/YYYY HH.MI.SSTZO"));
|
||||
|
||||
|
||||
?>
|
||||
<h4>Compare two times for equality:</h4>
|
||||
<?php
|
||||
|
||||
if ($date2->before($date)) {
|
||||
echo "second date is earlier (because Unix time ignores the part-second)<br />\n";
|
||||
}
|
||||
|
||||
$date->trunc(DATE_PRECISION_SECOND);
|
||||
|
||||
if ($date2->equals($date)) {
|
||||
echo "dates are now the same<br />\n";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,225 +0,0 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 Leandro Lucarella |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to the New BSD license, That is bundled |
|
||||
// | with this package in the file LICENSE, and is available through |
|
||||
// | the world-wide-web at |
|
||||
// | http://www.opensource.org/licenses/bsd-license.php |
|
||||
// | If you did not receive a copy of the new BSDlicense and are unable |
|
||||
// | to obtain it through the world-wide-web, please send a note to |
|
||||
// | pear-dev@lists.php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Leandro Lucarella <llucax@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'Date.php';
|
||||
require_once 'Date/Span.php';
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
|
||||
/**
|
||||
* Test case for Date_Span
|
||||
*
|
||||
* @package Date
|
||||
* @author Leandro Lucarella <llucax@php.net>
|
||||
*/
|
||||
class Date_SpanTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public $time;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->time = new Date_Span(97531);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
unset($this->time);
|
||||
}
|
||||
|
||||
public function testSetFromArray()
|
||||
{
|
||||
$this->time->setFromArray(array(5, 48.5, 28.5, 31));
|
||||
$this->assertEquals(
|
||||
'7:0:59:1',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetFromString()
|
||||
{
|
||||
$this->time->setFromString('5:00:59:31');
|
||||
$this->assertEquals(
|
||||
'5:0:59:31',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetFromSeconds()
|
||||
{
|
||||
$this->time->setFromSeconds(434344);
|
||||
$this->assertEquals(
|
||||
'5:0:39:4',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetFromMinutes()
|
||||
{
|
||||
$this->time->setFromMinutes(7860.0166666666);
|
||||
$this->assertEquals(
|
||||
'5:11:0:1',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetFromHours()
|
||||
{
|
||||
$this->time->setFromHours(50.12345);
|
||||
$this->assertEquals(
|
||||
'2:2:7:24',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetFromDays()
|
||||
{
|
||||
$this->time->setFromDays(pi());
|
||||
$this->assertEquals(
|
||||
'3:3:23:54',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetFromDateDiff()
|
||||
{
|
||||
$this->time->setFromDateDiff(
|
||||
new Date('2004-03-10 01:15:59'),
|
||||
new Date('2003-03-10 00:10:50')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'366:1:5:9',
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCopy()
|
||||
{
|
||||
$time = new Date_Span();
|
||||
$time->copy($this->time);
|
||||
$this->assertEquals(
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
),
|
||||
sprintf(
|
||||
'%d:%d:%d:%d',
|
||||
$time->day,
|
||||
$time->hour,
|
||||
$time->minute,
|
||||
$time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormat()
|
||||
{
|
||||
$codes = array(
|
||||
'C' => '1, 03:05:31',
|
||||
'd' => '1.1288310185185',
|
||||
'D' => '1',
|
||||
'e' => '27.091944444444',
|
||||
'f' => '1625.5166666667',
|
||||
'g' => '97531',
|
||||
'h' => '3',
|
||||
'H' => '03',
|
||||
'i' => '3',
|
||||
'I' => '03',
|
||||
'm' => '5',
|
||||
'M' => '05',
|
||||
'n' => "\n",
|
||||
'p' => 'am',
|
||||
'P' => 'AM',
|
||||
'r' => '03:05:31 am',
|
||||
'R' => '03:05',
|
||||
's' => '31',
|
||||
'S' => '31',
|
||||
't' => "\t",
|
||||
'T' => '03:05:31',
|
||||
'%' => '%',
|
||||
);
|
||||
foreach ($codes as $code => $expected) {
|
||||
$this->assertEquals(
|
||||
"$code: $expected",
|
||||
$this->time->format("$code: %$code")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testAdd()
|
||||
{
|
||||
$this->time->add(new Date_Span(6000));
|
||||
$result = $this->time->toSeconds();
|
||||
$expected = 103531;
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testSubtract()
|
||||
{
|
||||
$this->time->subtract(new Date_Span(6000));
|
||||
$result = $this->time->toSeconds();
|
||||
$expected = 91531;
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
|
@ -1,453 +0,0 @@
|
|||
<?php
|
||||
// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 Marshall Roch |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to the New BSD license, That is bundled |
|
||||
// | with this package in the file LICENSE, and is available through |
|
||||
// | the world-wide-web at |
|
||||
// | http://www.opensource.org/licenses/bsd-license.php |
|
||||
// | If you did not receive a copy of the new BSDlicense and are unable |
|
||||
// | to obtain it through the world-wide-web, please send a note to |
|
||||
// | pear-dev@lists.php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Marshall Roch <mroch@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'Date.php';
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
|
||||
class myDate extends Date
|
||||
{
|
||||
public function myDate($date)
|
||||
{
|
||||
$this->Date($date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Date
|
||||
*
|
||||
* @package Date
|
||||
* @author Marshall Roch <mroch@php.net>
|
||||
*/
|
||||
class Date_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public $time;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->time = new Date("2003-10-04 14:03:24Z");
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
unset($this->time);
|
||||
}
|
||||
|
||||
public function testDateNull()
|
||||
{
|
||||
$time = new Date();
|
||||
$this->assertEquals(
|
||||
date('Y-m-d H:i:s'),
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$time->year,
|
||||
$time->month,
|
||||
$time->day,
|
||||
$time->hour,
|
||||
$time->minute,
|
||||
$time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAbstraction()
|
||||
{
|
||||
$d = new Date();
|
||||
$my = new myDate($d);
|
||||
$this->assertEquals($d->getDate(), $my->getDate());
|
||||
}
|
||||
|
||||
public function testDateCopy()
|
||||
{
|
||||
$temp = new Date($this->time);
|
||||
$this->assertEquals($temp, $this->time);
|
||||
}
|
||||
|
||||
public function testDateISO()
|
||||
{
|
||||
$temp = new Date("2003-10-04 14:03:24");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateISOBasic()
|
||||
{
|
||||
$temp = new Date("20031004T140324");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateISOExtended()
|
||||
{
|
||||
$temp = new Date("2003-10-04T14:03:24");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateISOTimestamp()
|
||||
{
|
||||
$temp = new Date("20031004140324");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateUnixtime()
|
||||
{
|
||||
$temp = new Date();
|
||||
$temp->setTZbyID("UTC");
|
||||
$temp->setDate(strtotime("2003-10-04 14:03:24Z"));
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateUnixtime2()
|
||||
{
|
||||
$temp = new Date();
|
||||
$temp->setTZbyID("UTC-05:30");
|
||||
$temp->setDate(strtotime("2003-10-04 14:03:24Z"));
|
||||
$temp->convertTZbyID("UTC");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateUnixtime3()
|
||||
{
|
||||
$temp = new Date();
|
||||
$temp->setTZbyID("America/Chicago");
|
||||
$temp->setDate(strtotime("2003-10-04 14:03:24Z"));
|
||||
$temp->convertTZbyID("UTC");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateUnixtime4()
|
||||
{
|
||||
$temp = new Date();
|
||||
$temp->setTZbyID("Europe/London");
|
||||
$temp->setDate(strtotime("2003-10-04 14:03:24Z")); // Summer time in London
|
||||
$temp->setTZbyID("UTC");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 15:03:24', // Preserves London local time (15.03)
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$temp->year,
|
||||
$temp->month,
|
||||
$temp->day,
|
||||
$temp->hour,
|
||||
$temp->minute,
|
||||
$temp->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateISO()
|
||||
{
|
||||
$this->time->setDate("2003-10-04 14:03:24");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateISOBasic()
|
||||
{
|
||||
$this->time->setDate("20031004T140324");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateISOExtended()
|
||||
{
|
||||
$this->time->setDate("2003-10-04T14:03:24");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateTimestamp()
|
||||
{
|
||||
$this->time->setDate("20031004140324");
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateUnixtime()
|
||||
{
|
||||
$this->time->setDate(strtotime("2003-10-04 14:03:24Z"));
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateUnixtime2()
|
||||
{
|
||||
$hs_oldtz = $this->time->getTZID();
|
||||
$this->time->setTZbyID("UTC-05:30");
|
||||
$this->time->setDate(strtotime("2003-10-04 14:03:24Z"));
|
||||
$this->time->convertTZbyID($hs_oldtz);
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetDateUnixtime3()
|
||||
{
|
||||
$hs_oldtz = $this->time->getTZID();
|
||||
$this->time->setTZbyID("America/Chicago");
|
||||
$this->time->setDate(strtotime("2003-10-04 14:03:24Z"));
|
||||
$this->time->convertTZbyID($hs_oldtz);
|
||||
$this->assertEquals(
|
||||
'2003-10-04 14:03:24',
|
||||
sprintf(
|
||||
'%04d-%02d-%02d %02d:%02d:%02d',
|
||||
$this->time->year,
|
||||
$this->time->month,
|
||||
$this->time->day,
|
||||
$this->time->hour,
|
||||
$this->time->minute,
|
||||
$this->time->second
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetDateISO()
|
||||
{
|
||||
$date = $this->time->getDate(DATE_FORMAT_ISO);
|
||||
$this->assertEquals('2003-10-04 14:03:24', $date);
|
||||
}
|
||||
|
||||
public function testGetDateISOBasic()
|
||||
{
|
||||
$date = $this->time->getDate(DATE_FORMAT_ISO_BASIC);
|
||||
$this->assertEquals('20031004T140324Z', $date);
|
||||
}
|
||||
|
||||
public function testGetDateISOExtended()
|
||||
{
|
||||
$date = $this->time->getDate(DATE_FORMAT_ISO_EXTENDED);
|
||||
$this->assertEquals('2003-10-04T14:03:24Z', $date);
|
||||
}
|
||||
|
||||
public function testGetDateTimestamp()
|
||||
{
|
||||
$date = $this->time->getDate(DATE_FORMAT_TIMESTAMP);
|
||||
$this->assertEquals('20031004140324', $date);
|
||||
}
|
||||
|
||||
public function testGetDateUnixtime()
|
||||
{
|
||||
$date = $this->time->getDate(DATE_FORMAT_UNIXTIME);
|
||||
$this->assertEquals(strtotime('2003-10-04 14:03:24Z'), $date);
|
||||
}
|
||||
|
||||
public function testGetDateUnixtime2()
|
||||
{
|
||||
$hs_oldtz = $this->time->getTZID();
|
||||
$this->time->convertTZbyID("UTC-05:30");
|
||||
$date = $this->time->getDate(DATE_FORMAT_UNIXTIME);
|
||||
$this->assertEquals(strtotime('2003-10-04 14:03:24Z'), $date);
|
||||
$this->time->convertTZbyID($hs_oldtz);
|
||||
}
|
||||
|
||||
public function testGetDateUnixtime3()
|
||||
{
|
||||
$hs_oldtz = $this->time->getTZID();
|
||||
$this->time->convertTZbyID("America/Chicago");
|
||||
$date = $this->time->getDate(DATE_FORMAT_UNIXTIME);
|
||||
$this->assertEquals(strtotime('2003-10-04 14:03:24Z'), $date);
|
||||
$this->time->convertTZbyID($hs_oldtz);
|
||||
}
|
||||
|
||||
public function testFormatLikeStrftime()
|
||||
{
|
||||
$codes = array(
|
||||
'a' => 'Sat',
|
||||
'A' => 'Saturday',
|
||||
'b' => 'Oct',
|
||||
'B' => 'October',
|
||||
'C' => '20',
|
||||
'd' => '04',
|
||||
'D' => '10/04/2003',
|
||||
'e' => '4',
|
||||
'H' => '14',
|
||||
'I' => '02',
|
||||
'j' => '277',
|
||||
'm' => '10',
|
||||
'M' => '03',
|
||||
'n' => "\n",
|
||||
'O' => '+00:00',
|
||||
'o' => '+00:00',
|
||||
'p' => 'pm',
|
||||
'P' => 'PM',
|
||||
'r' => '02:03:24 PM',
|
||||
'R' => '14:03',
|
||||
'S' => '24',
|
||||
't' => "\t",
|
||||
'T' => '14:03:24',
|
||||
'w' => '6',
|
||||
'U' => '39',
|
||||
'y' => '03',
|
||||
'Y' => '2003',
|
||||
'%' => '%'
|
||||
);
|
||||
|
||||
foreach ($codes as $code => $expected) {
|
||||
$this->assertEquals(
|
||||
"$code: $expected",
|
||||
$this->time->formatLikeStrftime("$code: %$code")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testToUTCbyOffset()
|
||||
{
|
||||
$this->time->setTZbyID('EST');
|
||||
$this->time->toUTC();
|
||||
$temp = new Date("2003-10-04 14:03:24");
|
||||
$temp->toUTCbyOffset("-05:00");
|
||||
|
||||
$this->assertEquals($temp, $this->time);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
--TEST--
|
||||
Bug #11313 DST time change not handled correctly
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
date_default_timezone_set('Europe/Moscow');
|
||||
//include_once('debug.php');
|
||||
require_once 'Date.php';
|
||||
|
||||
$date = new Date('2007-03-25 03:00:04');
|
||||
$tmp = new Date($date);
|
||||
|
||||
$PRINT_FORMAT = "%Y-%m-%d %H:%M:%S %Z%O";
|
||||
|
||||
//var_dump($date->tz, 'TimeZone');
|
||||
printf("% 50s: %s\n", "Actual date", $date->format($PRINT_FORMAT));
|
||||
|
||||
$tmp->copy($date);
|
||||
$tmp->subtractSpan(new Date_Span('0:00:00:05'));
|
||||
printf(
|
||||
"% 50s: %s\n",
|
||||
'Subtracting 5 seconds',
|
||||
$tmp->format($PRINT_FORMAT)
|
||||
);
|
||||
|
||||
$tmp->copy($date);
|
||||
$tmp->subtractSpan(new Date_Span('0:00:20:00'));
|
||||
printf(
|
||||
"% 50s: %s\n",
|
||||
"Subtracting 20 minutes",
|
||||
$tmp->format($PRINT_FORMAT)
|
||||
);
|
||||
|
||||
$tmp->copy($date);
|
||||
$tmp->subtractSpan(new Date_Span('0:02:30:00'));
|
||||
printf(
|
||||
"% 50s: %s\n",
|
||||
"Subtracting 2 hours 30 minutes",
|
||||
$tmp->format($PRINT_FORMAT)
|
||||
);
|
||||
|
||||
$tmp->copy($date);
|
||||
$tmp->subtractSpan(new Date_Span('0:10:00:00'));
|
||||
printf(
|
||||
"% 50s: %s\n",
|
||||
"Subtracting 10 hours",
|
||||
$tmp->format($PRINT_FORMAT)
|
||||
);
|
||||
|
||||
$tmp->copy($date);
|
||||
$tmp->subtractSpan(new Date_Span('3:00:00:00'));
|
||||
printf(
|
||||
"% 50s: %s\n",
|
||||
"Subtracting 3 days",
|
||||
$tmp->format($PRINT_FORMAT)
|
||||
);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Actual date: 2007-03-25 03:00:04 MSD+04:00
|
||||
Subtracting 5 seconds: 2007-03-25 01:59:59 MSK+03:00
|
||||
Subtracting 20 minutes: 2007-03-25 01:40:04 MSK+03:00
|
||||
Subtracting 2 hours 30 minutes: 2007-03-24 23:30:04 MSK+03:00
|
||||
Subtracting 10 hours: 2007-03-24 16:00:04 MSK+03:00
|
||||
Subtracting 3 days: 2007-03-22 02:00:04 MSK+03:00
|
|
@ -1,32 +0,0 @@
|
|||
--TEST--
|
||||
Bug #13376 setFromDateDiff change the source of Date objects
|
||||
--FILE--
|
||||
<?php
|
||||
/*
|
||||
* Test for: Date_Span
|
||||
* Part tested: Date_Span::setFromDateDiff()
|
||||
*
|
||||
* This test should be tested on both PHP4 and PHP5 to see the different.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
require_once 'Date.php';
|
||||
|
||||
$startDate = new Date('2008-02-29 00:00:00');
|
||||
$endDate = new Date('2008-03-01 23:30:10');
|
||||
print 'Days: ' . $startDate->format('%Y-%m-%d') . ' to ' . $endDate->format('%Y-%m-%d') . "\n";
|
||||
|
||||
$diff = new Date_Span();
|
||||
$diff->setFromDateDiff($startDate, $endDate);
|
||||
|
||||
// still same instances?
|
||||
print 'Days: ' . $startDate->format('%Y-%m-%d') . ' to ' . $endDate->format('%Y-%m-%d') . "\n";
|
||||
|
||||
// what about diff?
|
||||
print 'Diff: ' . $diff->format('%D day %H hours %M minutes %S seconds') . "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Days: 2008-02-29 to 2008-03-01
|
||||
Days: 2008-02-29 to 2008-03-01
|
||||
Diff: 1 day 23 hours 30 minutes 10 seconds
|
|
@ -1,13 +0,0 @@
|
|||
--TEST--
|
||||
Bug #13545 Date_Span::set() doesn't work when passed an int and format
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once 'Date.php';
|
||||
|
||||
$span = new Date_Span(1, '%D');
|
||||
echo $span->format('%D-%S');
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
1-00
|
|
@ -1,22 +0,0 @@
|
|||
--TEST--
|
||||
Bug #19568 setDate() handles ISO week dates incorrectly
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Date.php';
|
||||
|
||||
$x = new Date('2012-W49-1');
|
||||
print $x->year . "\n";
|
||||
print $x->month . "\n";
|
||||
print $x->day . "\n";
|
||||
|
||||
$y = new Date('2012-W50-1');
|
||||
print $y->year . "\n";
|
||||
print $y->month . "\n";
|
||||
print $y->day . "\n";
|
||||
--EXPECT--
|
||||
2012
|
||||
12
|
||||
3
|
||||
2012
|
||||
12
|
||||
10
|
|
@ -1,17 +0,0 @@
|
|||
--TEST--
|
||||
Bug #2378: Date::getDate(DATE_FORMAT_UNIXTIME) doesn't convert to GMT
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once "Date.php";
|
||||
|
||||
|
||||
$date =& new Date(1095935549);
|
||||
echo $date->getTime()."\n";
|
||||
$date->convertTZbyID('America/Los_Angeles');
|
||||
echo $date->getTime()."\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
1095935549
|
||||
1095935549
|
|
@ -1,104 +0,0 @@
|
|||
--TEST--
|
||||
Bug #2378: Date::getDate(DATE_FORMAT_UNIXTIME) doesn't convert to GMT
|
||||
--FILE--
|
||||
<?php
|
||||
/**
|
||||
* Test for: Date
|
||||
* Parts tested: Date::getTime(), Date::getDate(DATE_FORMAT_UNIXTIME)
|
||||
*/
|
||||
|
||||
require_once 'Date.php';
|
||||
|
||||
$dates = array(
|
||||
'1969-12-31T18:30:00-05:30', // 0
|
||||
'1970-01-01T07:00:00+07:00', // 0
|
||||
'1970-01-01T00:00:00Z', // 0
|
||||
'1998-12-31T23:59:59Z', // 915148799
|
||||
// '1998-12-31T23:59:60Z', // 915148800
|
||||
'1999-01-01T00:00:00Z', // 915148800 (no leap second)
|
||||
'2001-09-09T01:46:40Z', // 1000000000
|
||||
'2004-01-10T13:37:04Z', // 2^30
|
||||
'2005-03-18T01:58:31Z', // 1111111111
|
||||
'2006-12-08T01:00:00Z', // 1165539600
|
||||
'2009-02-13T23:31:30Z', // 1234567890
|
||||
'2033-05-18T03:33:20Z', // 2000000000
|
||||
);
|
||||
|
||||
$date = new Date();
|
||||
foreach ($dates as $hs_date) {
|
||||
$date->setDate($hs_date);
|
||||
|
||||
if (PEAR::isError($res = $date->convertTZbyID('UTC'))) {
|
||||
print_r($res);
|
||||
exit();
|
||||
}
|
||||
$ts = $date->getTime();
|
||||
echo 'Greenwich = ' . str_pad($ts, 10) . ' - ' . $date->formatLikeSQL('YYYY-MM-DD HH:MI:SSSTZH:TZM') . "\n";
|
||||
|
||||
if (PEAR::isError($res = $date->convertTZbyID('Europe/London'))) {
|
||||
print_r($res);
|
||||
exit();
|
||||
}
|
||||
$ts = $date->getTime();
|
||||
echo 'London ' . $date->formatLikeSQL('("UTC"NPSTZH)') . " = " . str_pad($ts, 10) . ' - ' . $date->formatLikeSQL('YYYY-MM-DD HH:MI:SSSTZH:TZM') . "\n";
|
||||
|
||||
if (PEAR::isError($res = $date->convertTZbyID('Europe/Paris'))) {
|
||||
print_r($res);
|
||||
exit();
|
||||
}
|
||||
$ts = $date->getTime();
|
||||
echo 'Paris ' . $date->formatLikeSQL('("UTC"NPSTZH)') . " = " . str_pad($ts, 10) . ' - ' . $date->formatLikeSQL('YYYY-MM-DD HH:MI:SSSTZH:TZM') . "\n";
|
||||
|
||||
if (PEAR::isError($res = $date->convertTZbyID('Asia/Jakarta'))) {
|
||||
print_r($res);
|
||||
exit();
|
||||
}
|
||||
$ts = $date->getTime();
|
||||
echo 'Jakarta ' . $date->formatLikeSQL('("UTC"NPSTZH)') . " = " . str_pad($ts, 10) . ' - ' . $date->formatLikeSQL('YYYY-MM-DD HH:MI:SSSTZH:TZM') . "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Greenwich = 0 - 1970-01-01 00:00:00+00:00
|
||||
London (UTC+0) = 0 - 1970-01-01 00:00:00+00:00
|
||||
Paris (UTC+1) = 0 - 1970-01-01 01:00:00+01:00
|
||||
Jakarta (UTC+7) = 0 - 1970-01-01 07:00:00+07:00
|
||||
Greenwich = 0 - 1970-01-01 00:00:00+00:00
|
||||
London (UTC+0) = 0 - 1970-01-01 00:00:00+00:00
|
||||
Paris (UTC+1) = 0 - 1970-01-01 01:00:00+01:00
|
||||
Jakarta (UTC+7) = 0 - 1970-01-01 07:00:00+07:00
|
||||
Greenwich = 0 - 1970-01-01 00:00:00+00:00
|
||||
London (UTC+0) = 0 - 1970-01-01 00:00:00+00:00
|
||||
Paris (UTC+1) = 0 - 1970-01-01 01:00:00+01:00
|
||||
Jakarta (UTC+7) = 0 - 1970-01-01 07:00:00+07:00
|
||||
Greenwich = 915148799 - 1998-12-31 23:59:59+00:00
|
||||
London (UTC+0) = 915148799 - 1998-12-31 23:59:59+00:00
|
||||
Paris (UTC+1) = 915148799 - 1999-01-01 00:59:59+01:00
|
||||
Jakarta (UTC+7) = 915148799 - 1999-01-01 06:59:59+07:00
|
||||
Greenwich = 915148800 - 1999-01-01 00:00:00+00:00
|
||||
London (UTC+0) = 915148800 - 1999-01-01 00:00:00+00:00
|
||||
Paris (UTC+1) = 915148800 - 1999-01-01 01:00:00+01:00
|
||||
Jakarta (UTC+7) = 915148800 - 1999-01-01 07:00:00+07:00
|
||||
Greenwich = 1000000000 - 2001-09-09 01:46:40+00:00
|
||||
London (UTC+1) = 1000000000 - 2001-09-09 02:46:40+01:00
|
||||
Paris (UTC+2) = 1000000000 - 2001-09-09 03:46:40+02:00
|
||||
Jakarta (UTC+7) = 1000000000 - 2001-09-09 08:46:40+07:00
|
||||
Greenwich = 1073741824 - 2004-01-10 13:37:04+00:00
|
||||
London (UTC+0) = 1073741824 - 2004-01-10 13:37:04+00:00
|
||||
Paris (UTC+1) = 1073741824 - 2004-01-10 14:37:04+01:00
|
||||
Jakarta (UTC+7) = 1073741824 - 2004-01-10 20:37:04+07:00
|
||||
Greenwich = 1111111111 - 2005-03-18 01:58:31+00:00
|
||||
London (UTC+0) = 1111111111 - 2005-03-18 01:58:31+00:00
|
||||
Paris (UTC+1) = 1111111111 - 2005-03-18 02:58:31+01:00
|
||||
Jakarta (UTC+7) = 1111111111 - 2005-03-18 08:58:31+07:00
|
||||
Greenwich = 1165539600 - 2006-12-08 01:00:00+00:00
|
||||
London (UTC+0) = 1165539600 - 2006-12-08 01:00:00+00:00
|
||||
Paris (UTC+1) = 1165539600 - 2006-12-08 02:00:00+01:00
|
||||
Jakarta (UTC+7) = 1165539600 - 2006-12-08 08:00:00+07:00
|
||||
Greenwich = 1234567890 - 2009-02-13 23:31:30+00:00
|
||||
London (UTC+0) = 1234567890 - 2009-02-13 23:31:30+00:00
|
||||
Paris (UTC+1) = 1234567890 - 2009-02-14 00:31:30+01:00
|
||||
Jakarta (UTC+7) = 1234567890 - 2009-02-14 06:31:30+07:00
|
||||
Greenwich = 2000000000 - 2033-05-18 03:33:20+00:00
|
||||
London (UTC+1) = 2000000000 - 2033-05-18 04:33:20+01:00
|
||||
Paris (UTC+2) = 2000000000 - 2033-05-18 05:33:20+02:00
|
||||
Jakarta (UTC+7) = 2000000000 - 2033-05-18 10:33:20+07:00
|
|
@ -1,22 +0,0 @@
|
|||
--TEST--
|
||||
Bug #445: Date does not handle DATE_FORMAT_ISO_EXTENDED correctly
|
||||
--FILE--
|
||||
<?php
|
||||
/**
|
||||
* Test for: Date
|
||||
* Parts tested: DATE_FORMAT_ISO_EXTENDED constant
|
||||
*/
|
||||
|
||||
require_once 'Date.php';
|
||||
|
||||
$input = '2003-12-17T10:27:03Z';
|
||||
$date = new Date('2003-12-17T10:27:03Z');
|
||||
echo 'Date::getMonth() (via Constructor) = ' . $date->getMonth() . "\n";
|
||||
|
||||
$date = new Date();
|
||||
$date->setDate($input, DATE_FORMAT_ISO_EXTENDED);
|
||||
echo 'Date::getMonth() (via Date::setDate()) = ' . $date->getMonth() . "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Date::getMonth() (via Constructor) = 12
|
||||
Date::getMonth() (via Date::setDate()) = 12
|
|
@ -1,104 +0,0 @@
|
|||
--TEST--
|
||||
Bug #6246: Date::inDaylightTime() crashes Apache 2.0.55 with status 3221225477
|
||||
--FILE--
|
||||
<?php
|
||||
/**
|
||||
* Test for: Date::inDaylightTime()
|
||||
* Parts tested: Date_TimeZone::inDaylightTime()
|
||||
*/
|
||||
|
||||
require_once 'Date.php';
|
||||
|
||||
/**
|
||||
* In 2007, daylight saving time (DST) was extended in the United States.
|
||||
* DST started on March 11, 2007, which was three weeks earlier than in
|
||||
* the past, and it ended on November 4, 2007, one week later than in years
|
||||
* past. This results in a new DST period that is four weeks longer than in
|
||||
* previous years.
|
||||
*
|
||||
* N.B. the time at which US Summer time starts is 2.00 'Wall-Clock' Time,
|
||||
* that is, it goes forward at 2.00 in standard time, and goes back at
|
||||
* 2.00 in Summer time. This is unlike Europe which all switches together
|
||||
* at 1.00 GMT in both directions, so that in London, for example, the
|
||||
* clocks go back at 2.00 BST (although at that exact instant, the time
|
||||
* actually becomes 1.00 GMT).
|
||||
*
|
||||
* All countries in Europe except Iceland observe DST and change on the same
|
||||
* date and time, starting on the last Sunday in March and ending on the last
|
||||
* Sunday in October. Before 1996, DST ended on the last Sunday in September
|
||||
* in most European countries; on the British Isles though, DST then ended on
|
||||
* the fourth (which some years isn't the last) Sunday in October. In the
|
||||
* West European (UTC), Central European (CET, UTC+1), and East European
|
||||
* (UTC+2) time zones the change is simultaneous: on both dates the clocks
|
||||
* are changed everywhere at 01:00 UTC, i.e. from local times of
|
||||