/tests/Zend/Date/DateTest.php
PHP | 5695 lines | 5408 code | 119 blank | 168 comment | 9 complexity | aa9b829ef97778bfc3ddec0837e5d3b1 MD5 | raw file
Possible License(s): BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Date
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- namespace ZendTest\Date;
- use Zend\Cache\StorageFactory as CacheFactory,
- Zend\Cache\Storage\Adapter\AdapterInterface as CacheAdapter,
- Zend\Date\Date,
- Zend\Date\Cities,
- Zend\Locale\Locale,
- Zend\Locale\Exception\ExceptionInterface as LocaleException,
- Zend\TimeSync\TimeSync,
- Zend\Registry;
- /**
- * These const values control some testing behavior.
- * They may be defined here or in TestConfiguration.php.
- */
- if (!defined('TESTS_ZEND_LOCALE_BCMATH_ENABLED')) {
- // Set to false to disable usage of bcmath extension by Zend_Date
- define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', true);
- }
- if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE')) {
- // Set to true to run full Zend_Date unit tests.
- // Set to false to run a good subset of Zend_Date unit tests.
- define('TESTS_ZEND_I18N_EXTENDED_COVERAGE', true);
- }
- /**
- * @category Zend
- * @package Zend_Date
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Date
- */
- class DateTest extends \PHPUnit_Framework_TestCase
- {
- private $_cache = null;
- private $_orig = array();
- /**
- * Stores the original set timezone
- * @var string
- */
- private $_originaltimezone;
- public function setUp()
- {
- $this->_originaltimezone = date_default_timezone_get();
- date_default_timezone_set('Indian/Maldives');
- $this->_orig = Date::setOptions();
- $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0));
- Date::setOptions(array('cache' => $this->_cache));
- Date::setOptions(array('fix_dst' => true));
- Date::setOptions(array('extend_month' => false));
- Date::setOptions(array('format_type' => 'iso'));
- }
- public function tearDown()
- {
- Date::setOptions($this->_orig);
- $this->_cache->clear(CacheAdapter::MATCH_ALL);
- date_default_timezone_set($this->_originaltimezone);
- }
- /**
- * Test for date object creation
- */
- public function testCreation()
- {
- // look if locale is detectable
- try {
- $locale = new Locale();
- } catch (LocaleException $e) {
- $this->markTestSkipped('Autodetection of locale failed');
- return;
- }
- $date = new Date(0);
- $this->assertTrue($date instanceof Date);
- }
- /**
- * Test for date object creation using default format for a locale
- */
- public function testCreationDefaultFormat()
- {
- // look if locale is detectable
- try {
- $locale = new Locale();
- } catch (LocaleException $e) {
- $this->markTestSkipped('Autodetection of locale failed');
- return;
- }
- $date = new Date('2006-01-01');
- $this->assertTrue($date instanceof Date);
- $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Date::ISO_8601));
- $date = new Date('2006-01-01', 'en_US');
- $this->assertTrue($date instanceof Date);
- $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Date::ISO_8601));
- }
- /**
- * Test for date object creation using default format for a locale
- */
- public function testCreationDefaultFormatConsistency()
- {
- // look if locale is detectable
- try {
- $locale = new Locale();
- } catch (LocaleException $e) {
- $this->markTestSkipped('Autodetection of locale failed');
- return;
- }
- date_default_timezone_set('America/New_York');
- $locale = 'en_US';
- //2006-01-01T00:00:00+05:00
- $date1 = new Date('2006-01-01 01:00:00', Date::ISO_8601, $locale);
- $date1string = $date1->get(Date::ISO_8601);
- // en_US defines AM/PM, hour 0 does not exist
- // ISO defines dates without AM, 0 exists instead of 12 PM
- // therefor hour is set to 1 to verify
- $date2 = new Date('2006-01-01', Date::DATES, $locale);
- $date2->setTime('01:00:00');
- $this->assertSame($date1string, $date2->get(Date::ISO_8601));
- $date2 = new Date('01-01-2006', Date::DATES, $locale);
- $date2->setTime('01:00:00');
- $this->assertSame($date1string, $date2->get(Date::ISO_8601));
- $date2 = new Date('2006-01-01', null, $locale);
- $date2->setTime('01:00:00');
- $this->assertSame($date1string, $date2->get(Date::ISO_8601));
- $date2 = new Date('2006-01-01');
- $date2->setTime('01:00:00');
- $this->assertSame($date1string, $date2->get(Date::ISO_8601));
- $date2 = new Date('2006-01-01 01:00:00');
- $this->assertSame($date1string, $date2->get(Date::ISO_8601));
- }
- /**
- * Test for creation with timestamp
- */
- public function testCreationTimestamp()
- {
- // look if locale is detectable
- try {
- $locale = new Locale();
- } catch (LocaleException $e) {
- $this->markTestSkipped('Autodetection of locale failed');
- return;
- }
- $date = new Date('12345678');
- $this->assertTrue($date instanceof Date);
- }
- /**
- * Test for creation but only part of date
- */
- public function testCreationDatePart()
- {
- // look if locale is detectable
- try {
- $locale = new Locale();
- } catch (LocaleException $e) {
- $this->markTestSkipped('Autodetection of locale failed');
- return;
- }
- $date = new Date('13',Date::HOUR);
- $this->assertTrue($date instanceof Date);
- $date = new Date('20070802', 'YYYYMMdd');
- $this->assertSame("2007-08-02T00:00:00+05:00", $date->getIso());
- }
- /**
- * Test for creation but only a defined locale
- */
- public function testCreationLocale()
- {
- $locale = new Locale('de_AT');
- $date = new Date('13',null,$locale);
- $this->assertTrue($date instanceof Date);
- }
- /**
- * Test for creation but only part of date with locale
- */
- public function testCreationLocalePart()
- {
- $locale = new Locale('de_AT');
- $date = new Date('13',Date::HOUR,$locale);
- $this->assertTrue($date instanceof Date);
- }
- /**
- * Test for date object creation using default format for a locale
- */
- public function testCreationDefaultLoose()
- {
- // look if locale is detectable
- try {
- $locale = new Locale();
- } catch (LocaleException $e) {
- $this->markTestSkipped('Autodetection of locale failed');
- return;
- }
- $locale = 'de_AT';
- $date = new Date();
- $date = $date->getTimestamp();
- $this->assertTrue(abs($date - time()) < 2);
- date_default_timezone_set('GMT');
- $date = new Date(Date::YEAR);
- $date = $date->getTimestamp();
- $reference = gmmktime(0,0,0,1,1,date('Y'));
- $this->assertTrue($reference == $date);
- $date = new Date('ar_EG');
- $this->assertSame('ar_EG', $date->getLocale());
- $date = $date->getTimestamp();
- $this->assertTrue(abs($date - time()) < 2);
- }
- /**
- * Test for getTimestamp
- */
- public function testGetTimestamp()
- {
- $locale = new Locale('de_AT');
- $date = new Date(10000000);
- $this->assertSame(10000000, $date->getTimestamp());
- }
- /**
- * Test for getUnixTimestamp
- */
- public function testgetUnixTimestamp2()
- {
- $locale = new Locale('de_AT');
- $date = new Date(-100000000);
- $this->assertSame(-100000000, $date->getTimestamp());
- }
- /**
- * Test for setTimestamp
- */
- public function testSetTimestamp()
- {
- $locale = new Locale('de_AT');
- $date = new Date(0,Date::TIMESTAMP,$locale);
- $result = $date->setTimestamp(10000000);
- $this->assertSame('10000000', (string)$result->getTimestamp());
- }
- /**
- * Test for setTimestamp
- */
- public function testSetTimestamp2()
- {
- try {
- $locale = new Locale('de_AT');
- $date = new Date(0,null,$locale);
- $result = $date->setTimestamp('notimestamp');
- $this->Fail("exception expected");
- } catch (\Zend\Date\Exception\ExceptionInterface $e) {
- // success
- }
- }
- /**
- * Test for addTimestamp
- */
- public function testAddTimestamp()
- {
- $locale = new Locale('de_AT');
- $date = new Date(0,null,$locale);
- $result = $date->addTimestamp(10000000);
- $this->assertSame('10000000', (string)$result->getTimestamp());
- $result = $date->addTimestamp(array('timestamp' => 1000));
- $this->assertSame('10001000', (string)$result->getTimestamp());
- try {
- $result = $date->addTimestamp(array('notimestamp' => 1000));
- $this->fail("exception expected");
- } catch (\Zend\Date\Exception\ExceptionInterface $e) {
- // success
- }
- }
- /**
- * Test for addTimestamp
- */
- public function testAddTimestamp2()
- {
- try {
- $locale = new Locale('de_AT');
- $date = new Date(0,null,$locale);
- $result = $date->addTimestamp('notimestamp');
- $this->fail("exception expected");
- } catch (\Zend\Date\Exception\ExceptionInterface $e) {
- // success
- }
- }
- /**
- * Test for subTimestamp
- */
- public function testSubTimestamp()
- {
- $locale = new Locale('de_AT');
- $date = new Date(0,null,$locale);
- $result = $date->subTimestamp(10000000);
- $this->assertSame('-10000000', (string)$result->getTimestamp());
- }
- /**
- * Test for subTimestamp
- */
- public function testSubTimestamp2()
- {
- try {
- $locale = new Locale('de_AT');
- $date = new Date(0,null,$locale);
- $result = $date->subTimestamp('notimestamp');
- $this->fail("exception expected");
- } catch (\Zend\Date\Exception\ExceptionInterface $e) {
- // success
- }
- }
- /**
- * Test for compareTimestamp
- */
- public function testCompareTimestamp()
- {
- $locale = new Locale('de_AT');
- $date1 = new Date(0,null,$locale);
- $date2 = new Date(0,null,$locale);
- $this->assertSame(0, $date1->compareTimestamp($date2));
- $date2 = new Date(100,null,$locale);
- $this->assertSame(-1, $date1->compareTimestamp($date2));
- $date2 = new Date(-100,null,$locale);
- $this->assertSame(1, $date1->compareTimestamp($date2));
- }
- /**
- * Test for __toString
- */
- public function test_ToString()
- {
- $locale = new Locale('de_AT');
- $date = new Date(0,null,$locale);
- $date->setTimezone(date_default_timezone_get());
- $this->assertSame('01.01.1970 05:00:00', $date->__toString());
- }
- /**
- * Test for toString
- */
- public function testToString()
- {
- $locale = new Locale('de_AT');
- $date = new Date(1234567890,null,$locale);
- $date->setTimezone(date_default_timezone_get());
- $this->assertSame('14.02.2009 04:31:30', $date->toString( ));
- $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString('en_US' ));
- $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString(null, 'en_US'));
- $this->assertSame('2009', $date->toString('yyy', null ));
- $this->assertSame('14.02.2009 04:31:30', $date->toString(null, null ));
- $date->setTimeZone('UTC');
- $this->assertSame('Feb 13, 2009 11:31:30 PM', $date->toString(null, 'en_US'));
- $date->setTimeZone('Indian/Maldives');
- $this->assertSame( "xxyy'yyxx", $date->toString("xx'yy''yy'xx"));
- $this->assertSame( 'n.', $date->toString("GGGGG"));
- $this->assertSame( 'n. Chr.', $date->toString( "GGGG"));
- $this->assertSame( 'n. Chr.', $date->toString( "GGG"));
- $this->assertSame( 'n. Chr.', $date->toString( "GG"));
- $this->assertSame( 'n. Chr.', $date->toString( "G"));
- $this->assertSame( '02009', $date->toString("yyyyy"));
- $this->assertSame( '2009', $date->toString( "yyyy"));
- $this->assertSame( '2009', $date->toString( "yyy"));
- $this->assertSame( '09', $date->toString( "yy"));
- $this->assertSame( '2009', $date->toString( "y"));
- $this->assertSame( '02009', $date->toString("YYYYY"));
- $this->assertSame( '2009', $date->toString( "YYYY"));
- $this->assertSame( '2009', $date->toString( "YYY"));
- $this->assertSame( '09', $date->toString( "YY"));
- $this->assertSame( '2009', $date->toString( "Y"));
- $this->assertSame( 'F', $date->toString("MMMMM"));
- $this->assertSame( 'Februar', $date->toString( "MMMM"));
- $this->assertSame( 'Feb', $date->toString( "MMM"));
- $this->assertSame( '02', $date->toString( "MM"));
- $this->assertSame( '2', $date->toString( "M"));
- $this->assertSame( '07', $date->toString( "ww"));
- $this->assertSame( '7', $date->toString( "w"));
- $this->assertSame( '14', $date->toString( "dd"));
- $this->assertSame( '14', $date->toString( "d"));
- $this->assertSame( '044', $date->toString( "DDD"));
- $this->assertSame( '44', $date->toString( "DD"));
- $this->assertSame( '44', $date->toString( "D"));
- $this->assertSame( 'S', $date->toString("EEEEE"));
- $this->assertSame( 'Samstag', $date->toString( "EEEE"));
- $this->assertSame( 'Sam', $date->toString( "EEE"));
- $this->assertSame( 'Sa.', $date->toString( "EE"));
- $this->assertSame( 'S', $date->toString( "E"));
- $this->assertSame( '06', $date->toString( "ee"));
- $this->assertSame( '6', $date->toString( "e"));
- $this->assertSame( 'vorm.', $date->toString( "a"));
- $this->assertSame( '04', $date->toString( "hh"));
- $this->assertSame( '4', $date->toString( "h"));
- $this->assertSame( '04', $date->toString( "HH"));
- $this->assertSame( '4', $date->toString( "H"));
- $this->assertSame( '31', $date->toString( "mm"));
- $this->assertSame( '31', $date->toString( "m"));
- $this->assertSame( '30', $date->toString( "ss"));
- $this->assertSame( '30', $date->toString( "s"));
- $this->assertSame( '0', $date->toString( "S"));
- $this->assertSame('Indian/Maldives', $date->toString( "zzzz"));
- $this->assertSame( 'MVT', $date->toString( "zzz"));
- $this->assertSame( 'MVT', $date->toString( "zz"));
- $this->assertSame( 'MVT', $date->toString( "z"));
- $this->assertSame( '+05:00', $date->toString( "ZZZZ"));
- $this->assertSame( '+0500', $date->toString( "ZZZ"));
- $this->assertSame( '+0500', $date->toString( "ZZ"));
- $this->assertSame( '+0500', $date->toString( "Z"));
- $this->assertSame( '16290000', $date->toString("AAAAA"));
- $this->assertSame( '16290000', $date->toString( "AAAA"));
- $this->assertSame( '16290000', $date->toString( "AAA"));
- $this->assertSame( '16290000', $date->toString( "AA"));
- $this->assertSame( '16290000', $date->toString( "A"));
- $date = new Date("1-1-01",null,$locale);
- $date->setTimezone(date_default_timezone_get());
- $this->assertSame('01', $date->toString("yy"));
- }
- /**
- * Test for toValue
- */
- public function testToValue()
- {
- $locale = new Locale('de_AT');
- $date = new Date(1234567890,null,$locale);
- $date->setTimezone(date_default_timezone_get());
- $this->assertSame(1234567890, $date->toValue() );
- $this->assertSame( 14, $date->toValue(Date::DAY));
- $date->setTimezone('UTC');
- $this->assertSame( 13, $date->toValue(Date::DAY ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY_SHORT ));
- $this->assertSame( 13, $date->toValue(Date::DAY_SHORT ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY ));
- $this->assertSame( 5, $date->toValue(Date::WEEKDAY_8601 ));
- $this->assertFalse( $date->toValue(Date::DAY_SUFFIX ));
- $this->assertSame( 5, $date->toValue(Date::WEEKDAY_DIGIT ));
- $this->assertSame( 43, $date->toValue(Date::DAY_OF_YEAR ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY_NARROW ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY_NAME ));
- $this->assertSame( 7, $date->toValue(Date::WEEK ));
- $this->assertFalse( $date->toValue(Date::MONTH_NAME ));
- $this->assertSame( 2, $date->toValue(Date::MONTH ));
- $this->assertFalse( $date->toValue(Date::MONTH_NAME_SHORT ));
- $this->assertSame( 2, $date->toValue(Date::MONTH_SHORT ));
- $this->assertSame( 28, $date->toValue(Date::MONTH_DAYS ));
- $this->assertFalse( $date->toValue(Date::MONTH_NAME_NARROW));
- $this->assertSame( 0, $date->toValue(Date::LEAPYEAR ));
- $this->assertSame( 2009, $date->toValue(Date::YEAR_8601 ));
- $this->assertSame( 2009, $date->toValue(Date::YEAR ));
- $this->assertSame( 9, $date->toValue(Date::YEAR_SHORT ));
- $this->assertSame( 9, $date->toValue(Date::YEAR_SHORT_8601 ));
- $this->assertFalse( $date->toValue(Date::MERIDIEM ));
- $this->assertSame( 21, $date->toValue(Date::SWATCH ));
- $this->assertSame( 11, $date->toValue(Date::HOUR_SHORT_AM ));
- $this->assertSame( 23, $date->toValue(Date::HOUR_SHORT ));
- $this->assertSame( 11, $date->toValue(Date::HOUR_AM ));
- $this->assertSame( 23, $date->toValue(Date::HOUR ));
- $this->assertSame( 31, $date->toValue(Date::MINUTE ));
- $this->assertSame( 30, $date->toValue(Date::SECOND ));
- $this->assertSame( 0, $date->toValue(Date::MILLISECOND ));
- $this->assertSame( 31, $date->toValue(Date::MINUTE_SHORT ));
- $this->assertSame( 30, $date->toValue(Date::SECOND_SHORT ));
- $this->assertFalse( $date->toValue(Date::TIMEZONE_NAME ));
- $this->assertSame( 0, $date->toValue(Date::DAYLIGHT ));
- $this->assertSame( 0, $date->toValue(Date::GMT_DIFF ));
- $this->assertFalse( $date->toValue(Date::GMT_DIFF_SEP ));
- $this->assertFalse( $date->toValue(Date::TIMEZONE ));
- $this->assertSame( 0, $date->toValue(Date::TIMEZONE_SECS ));
- $this->assertFalse( $date->toValue(Date::ISO_8601 ));
- $this->assertFalse( $date->toValue(Date::RFC_2822 ));
- $this->assertSame(1234567890, $date->toValue(Date::TIMESTAMP ));
- $this->assertFalse( $date->toValue(Date::ERA ));
- $this->assertFalse( $date->toValue(Date::ERA_NAME ));
- $this->assertFalse( $date->toValue(Date::DATES ));
- $this->assertFalse( $date->toValue(Date::DATE_FULL ));
- $this->assertFalse( $date->toValue(Date::DATE_LONG ));
- $this->assertFalse( $date->toValue(Date::DATE_MEDIUM ));
- $this->assertFalse( $date->toValue(Date::DATE_SHORT ));
- $this->assertFalse( $date->toValue(Date::TIMES ));
- $this->assertFalse( $date->toValue(Date::TIME_FULL ));
- $this->assertFalse( $date->toValue(Date::TIME_LONG ));
- $this->assertFalse( $date->toValue(Date::TIME_MEDIUM ));
- $this->assertFalse( $date->toValue(Date::TIME_SHORT ));
- $this->assertFalse( $date->toValue(Date::DATETIME ));
- $this->assertFalse( $date->toValue(Date::DATETIME_FULL ));
- $this->assertFalse( $date->toValue(Date::DATETIME_LONG ));
- $this->assertFalse( $date->toValue(Date::DATETIME_MEDIUM ));
- $this->assertFalse( $date->toValue(Date::DATETIME_SHORT ));
- $this->assertFalse( $date->toValue(Date::ATOM ));
- $this->assertFalse( $date->toValue(Date::COOKIE ));
- $this->assertFalse( $date->toValue(Date::RFC_822 ));
- $this->assertFalse( $date->toValue(Date::RFC_850 ));
- $this->assertFalse( $date->toValue(Date::RFC_1036 ));
- $this->assertFalse( $date->toValue(Date::RFC_1123 ));
- $this->assertFalse( $date->toValue(Date::RFC_3339 ));
- $this->assertFalse( $date->toValue(Date::RSS ));
- $this->assertFalse( $date->toValue(Date::W3C ));
- $date->setTimezone('Indian/Maldives');
- $this->assertFalse( $date->toValue(Date::WEEKDAY_SHORT ));
- $this->assertSame( 14, $date->toValue(Date::DAY_SHORT ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY ));
- $this->assertSame( 6, $date->toValue(Date::WEEKDAY_8601 ));
- $this->assertFalse( $date->toValue(Date::DAY_SUFFIX ));
- $this->assertSame( 6, $date->toValue(Date::WEEKDAY_DIGIT ));
- $this->assertSame( 44, $date->toValue(Date::DAY_OF_YEAR ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY_NARROW ));
- $this->assertFalse( $date->toValue(Date::WEEKDAY_NAME ));
- $this->assertSame( 7, $date->toValue(Date::WEEK ));
- $this->assertFalse( $date->toValue(Date::MONTH_NAME ));
- $this->assertSame( 2, $date->toValue(Date::MONTH ));
- $this->assertFalse( $date->toValue(Date::MONTH_NAME_SHORT ));
- $this->assertSame( 2, $date->toValue(Date::MONTH_SHORT ));
- $this->assertSame( 28, $date->toValue(Date::MONTH_DAYS ));
- $this->assertFalse( $date->toValue(Date::MONTH_NAME_NARROW));
- $this->assertSame( 0, $date->toValue(Date::LEAPYEAR ));
- $this->assertSame( 2009, $date->toValue(Date::YEAR_8601 ));
- $this->assertSame( 2009, $date->toValue(Date::YEAR ));
- $this->assertSame( 9, $date->toValue(Date::YEAR_SHORT ));
- $this->assertSame( 9, $date->toValue(Date::YEAR_SHORT_8601 ));
- $this->assertFalse( $date->toValue(Date::MERIDIEM ));
- $this->assertSame( 21, $date->toValue(Date::SWATCH ));
- $this->assertSame( 4, $date->toValue(Date::HOUR_SHORT_AM ));
- $this->assertSame( 4, $date->toValue(Date::HOUR_SHORT ));
- $this->assertSame( 4, $date->toValue(Date::HOUR_AM ));
- $this->assertSame( 4, $date->toValue(Date::HOUR ));
- $this->assertSame( 31, $date->toValue(Date::MINUTE ));
- $this->assertSame( 30, $date->toValue(Date::SECOND ));
- $this->assertSame( 0, $date->toValue(Date::MILLISECOND ));
- $this->assertSame( 31, $date->toValue(Date::MINUTE_SHORT ));
- $this->assertSame( 30, $date->toValue(Date::SECOND_SHORT ));
- $this->assertFalse( $date->toValue(Date::TIMEZONE_NAME ));
- $this->assertSame( 0, $date->toValue(Date::DAYLIGHT ));
- $this->assertSame( 500, $date->toValue(Date::GMT_DIFF ));
- $this->assertFalse( $date->toValue(Date::GMT_DIFF_SEP ));
- $this->assertFalse( $date->toValue(Date::TIMEZONE ));
- $this->assertSame( 18000, $date->toValue(Date::TIMEZONE_SECS ));
- $this->assertFalse( $date->toValue(Date::ISO_8601 ));
- $this->assertFalse( $date->toValue(Date::RFC_2822 ));
- $this->assertSame(1234567890, $date->toValue(Date::TIMESTAMP ));
- $this->assertFalse( $date->toValue(Date::ERA ));
- $this->assertFalse( $date->toValue(Date::ERA_NAME ));
- $this->assertFalse( $date->toValue(Date::DATES ));
- $this->assertFalse( $date->toValue(Date::DATE_FULL ));
- $this->assertFalse( $date->toValue(Date::DATE_LONG ));
- $this->assertFalse( $date->toValue(Date::DATE_MEDIUM ));
- $this->assertFalse( $date->toValue(Date::DATE_SHORT ));
- $this->assertFalse( $date->toValue(Date::TIMES ));
- $this->assertFalse( $date->toValue(Date::TIME_FULL ));
- $this->assertFalse( $date->toValue(Date::TIME_LONG ));
- $this->assertFalse( $date->toValue(Date::TIME_MEDIUM ));
- $this->assertFalse( $date->toValue(Date::TIME_SHORT ));
- $this->assertFalse( $date->toValue(Date::DATETIME ));
- $this->assertFalse( $date->toValue(Date::DATETIME_FULL ));
- $this->assertFalse( $date->toValue(Date::DATETIME_LONG ));
- $this->assertFalse( $date->toValue(Date::DATETIME_MEDIUM ));
- $this->assertFalse( $date->toValue(Date::DATETIME_SHORT ));
- $this->assertFalse( $date->toValue(Date::ATOM ));
- $this->assertFalse( $date->toValue(Date::COOKIE ));
- $this->assertFalse( $date->toValue(Date::RFC_822 ));
- $this->assertFalse( $date->toValue(Date::RFC_850 ));
- $this->assertFalse( $date->toValue(Date::RFC_1036 ));
- $this->assertFalse( $date->toValue(Date::RFC_1123 ));
- $this->assertFalse( $date->toValue(Date::RFC_3339 ));
- $this->assertFalse( $date->toValue(Date::RSS ));
- $this->assertFalse( $date->toValue(Date::W3C ));
- }
- /**
- * Test for toValue
- */
- public function testGet()
- {
- $locale = new Locale('de_AT');
- $date = new Date(1234567890,null,$locale);
- $date->setTimezone('UTC');
- $this->assertSame( '13', $date->get(Date::DAY ));
- $this->assertSame( 'Fre', $date->get(Date::WEEKDAY_SHORT ));
- $this->assertSame( '13', $date->get(Date::DAY_SHORT ));
- $this->assertSame( 'Freitag', $date->get(Date::WEEKDAY ));
- $this->assertSame( '5', $date->get(Date::WEEKDAY_8601 ));
- $this->assertSame( 'th', $date->get(Date::DAY_SUFFIX ));
- $this->assertSame( '5', $date->get(Date::WEEKDAY_DIGIT ));
- $this->assertSame( '43', $date->get(Date::DAY_OF_YEAR ));
- $this->assertSame( 'F', $date->get(Date::WEEKDAY_NARROW ));
- $this->assertSame( 'Fr.', $date->get(Date::WEEKDAY_NAME ));
- $this->assertSame( '07', $date->get(Date::WEEK ));
- $this->assertSame( 'Februar', $date->get(Date::MONTH_NAME ));
- $this->assertSame( '02', $date->get(Date::MONTH ));
- $this->assertSame( 'Feb', $date->get(Date::MONTH_NAME_SHORT ));
- $this->assertSame( '2', $date->get(Date::MONTH_SHORT ));
- $this->assertSame( '28', $date->get(Date::MONTH_DAYS ));
- $this->assertSame( 'F', $date->get(Date::MONTH_NAME_NARROW));
- $this->assertSame( '0', $date->get(Date::LEAPYEAR ));
- $this->assertSame( '2009', $date->get(Date::YEAR_8601 ));
- $this->assertSame( '2009', $date->get(Date::YEAR ));
- $this->assertSame( '09', $date->get(Date::YEAR_SHORT ));
- $this->assertSame( '09', $date->get(Date::YEAR_SHORT_8601 ));
- $this->assertSame( 'nachm.', $date->get(Date::MERIDIEM ));
- $this->assertSame( '021', $date->get(Date::SWATCH ));
- $this->assertSame( '11', $date->get(Date::HOUR_SHORT_AM ));
- $this->assertSame( '23', $date->get(Date::HOUR_SHORT ));
- $this->assertSame( '11', $date->get(Date::HOUR_AM ));
- $this->assertSame( '23', $date->get(Date::HOUR ));
- $this->assertSame( '31', $date->get(Date::MINUTE ));
- $this->assertSame( '30', $date->get(Date::SECOND ));
- $this->assertSame( '0', $date->get(Date::MILLISECOND ));
- $this->assertSame( '31', $date->get(Date::MINUTE_SHORT ));
- $this->assertSame( '30', $date->get(Date::SECOND_SHORT ));
- $this->assertSame( 'UTC', $date->get(Date::TIMEZONE_NAME ));
- $this->assertSame( '0', $date->get(Date::DAYLIGHT ));
- $this->assertSame( '+0000', $date->get(Date::GMT_DIFF ));
- $this->assertSame( '+00:00', $date->get(Date::GMT_DIFF_SEP ));
- $this->assertSame( 'UTC', $date->get(Date::TIMEZONE ));
- $this->assertSame( '0', $date->get(Date::TIMEZONE_SECS ));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::ISO_8601 ));
- $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Date::RFC_2822 ));
- $this->assertSame( '1234567890', $date->get(Date::TIMESTAMP ));
- $this->assertSame( 'n. Chr.', $date->get(Date::ERA ));
- $this->assertSame( 'n. Chr.', $date->get(Date::ERA_NAME ));
- $this->assertSame( '13.02.2009', $date->get(Date::DATES ));
- $this->assertSame( 'Freitag, 13. Februar 2009', $date->get(Date::DATE_FULL ));
- $this->assertSame( '13. Februar 2009', $date->get(Date::DATE_LONG ));
- $this->assertSame( '13.02.2009', $date->get(Date::DATE_MEDIUM ));
- $this->assertSame( '13.02.09', $date->get(Date::DATE_SHORT ));
- $this->assertSame( '23:31:30', $date->get(Date::TIMES ));
- $this->assertSame( '23:31:30 UTC', $date->get(Date::TIME_FULL ));
- $this->assertSame( '23:31:30 UTC', $date->get(Date::TIME_LONG ));
- $this->assertSame( '23:31:30', $date->get(Date::TIME_MEDIUM ));
- $this->assertSame( '23:31', $date->get(Date::TIME_SHORT ));
- $this->assertSame( '13.02.2009 23:31:30', $date->get(Date::DATETIME ));
- $this->assertSame('Freitag, 13. Februar 2009 23:31:30 UTC', $date->get(Date::DATETIME_FULL ));
- $this->assertSame( '13. Februar 2009 23:31:30 UTC', $date->get(Date::DATETIME_LONG ));
- $this->assertSame( '13.02.2009 23:31:30', $date->get(Date::DATETIME_MEDIUM ));
- $this->assertSame( '13.02.09 23:31', $date->get(Date::DATETIME_SHORT ));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::ATOM ));
- $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Date::COOKIE ));
- $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Date::RFC_822 ));
- $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Date::RFC_850 ));
- $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Date::RFC_1036 ));
- $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Date::RFC_1123 ));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::RFC_3339 ));
- $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Date::RSS ));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::W3C ));
- $this->assertSame( '13', $date->get(Date::DAY, 'es'));
- $this->assertSame( 'vie', $date->get(Date::WEEKDAY_SHORT, 'es'));
- $this->assertSame( '13', $date->get(Date::DAY_SHORT, 'es'));
- $this->assertSame( 'viernes', $date->get(Date::WEEKDAY, 'es'));
- $this->assertSame( '5', $date->get(Date::WEEKDAY_8601, 'es'));
- $this->assertSame( 'th', $date->get(Date::DAY_SUFFIX, 'es'));
- $this->assertSame( '5', $date->get(Date::WEEKDAY_DIGIT, 'es'));
- $this->assertSame( '43', $date->get(Date::DAY_OF_YEAR, 'es'));
- $this->assertSame( 'v', $date->get(Date::WEEKDAY_NARROW, 'es'));
- $this->assertSame( 'vie', $date->get(Date::WEEKDAY_NAME, 'es'));
- $this->assertSame( '07', $date->get(Date::WEEK, 'es'));
- $this->assertSame( 'febrero', $date->get(Date::MONTH_NAME, 'es'));
- $this->assertSame( '02', $date->get(Date::MONTH, 'es'));
- $this->assertSame( 'feb', $date->get(Date::MONTH_NAME_SHORT, 'es'));
- $this->assertSame( '2', $date->get(Date::MONTH_SHORT, 'es'));
- $this->assertSame( '28', $date->get(Date::MONTH_DAYS, 'es'));
- $this->assertSame( 'f', $date->get(Date::MONTH_NAME_NARROW, 'es'));
- $this->assertSame( '0', $date->get(Date::LEAPYEAR, 'es'));
- $this->assertSame( '2009', $date->get(Date::YEAR_8601, 'es'));
- $this->assertSame( '2009', $date->get(Date::YEAR, 'es'));
- $this->assertSame( '09', $date->get(Date::YEAR_SHORT, 'es'));
- $this->assertSame( '09', $date->get(Date::YEAR_SHORT_8601, 'es'));
- $this->assertSame( 'p.m.', $date->get(Date::MERIDIEM, 'es'));
- $this->assertSame( '021', $date->get(Date::SWATCH, 'es'));
- $this->assertSame( '11', $date->get(Date::HOUR_SHORT_AM, 'es'));
- $this->assertSame( '23', $date->get(Date::HOUR_SHORT, 'es'));
- $this->assertSame( '11', $date->get(Date::HOUR_AM, 'es'));
- $this->assertSame( '23', $date->get(Date::HOUR, 'es'));
- $this->assertSame( '31', $date->get(Date::MINUTE, 'es'));
- $this->assertSame( '30', $date->get(Date::SECOND, 'es'));
- $this->assertSame( '0', $date->get(Date::MILLISECOND, 'es'));
- $this->assertSame( '31', $date->get(Date::MINUTE_SHORT, 'es'));
- $this->assertSame( '30', $date->get(Date::SECOND_SHORT, 'es'));
- $this->assertSame( 'UTC', $date->get(Date::TIMEZONE_NAME, 'es'));
- $this->assertSame( '0', $date->get(Date::DAYLIGHT, 'es'));
- $this->assertSame( '+0000', $date->get(Date::GMT_DIFF, 'es'));
- $this->assertSame( '+00:00', $date->get(Date::GMT_DIFF_SEP, 'es'));
- $this->assertSame( 'UTC', $date->get(Date::TIMEZONE, 'es'));
- $this->assertSame( '0', $date->get(Date::TIMEZONE_SECS, 'es'));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::ISO_8601, 'es'));
- $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Date::RFC_2822, 'es'));
- $this->assertSame( '1234567890', $date->get(Date::TIMESTAMP, 'es'));
- $this->assertSame( 'd.C.', $date->get(Date::ERA, 'es'));
- $this->assertSame( 'anno Dómini', $date->get(Date::ERA_NAME, 'es'));
- $this->assertSame( '13/02/2009', $date->get(Date::DATES, 'es'));
- $this->assertSame( 'viernes 13 de febrero de 2009', $date->get(Date::DATE_FULL, 'es'));
- $this->assertSame( '13 de febrero de 2009', $date->get(Date::DATE_LONG, 'es'));
- $this->assertSame( '13/02/2009', $date->get(Date::DATE_MEDIUM, 'es'));
- $this->assertSame( '13/02/09', $date->get(Date::DATE_SHORT, 'es'));
- $this->assertSame( '23:31:30', $date->get(Date::TIMES, 'es'));
- $this->assertSame( '23:31:30 UTC', $date->get(Date::TIME_FULL, 'es'));
- $this->assertSame( '23:31:30 UTC', $date->get(Date::TIME_LONG, 'es'));
- $this->assertSame( '23:31:30', $date->get(Date::TIME_MEDIUM, 'es'));
- $this->assertSame( '23:31', $date->get(Date::TIME_SHORT, 'es'));
- $this->assertSame( '13/02/2009 23:31:30', $date->get(Date::DATETIME, 'es'));
- $this->assertSame('viernes 13 de febrero de 2009 23:31:30 UTC', $date->get(Date::DATETIME_FULL, 'es'));
- $this->assertSame('13 de febrero de 2009 23:31:30 UTC', $date->get(Date::DATETIME_LONG, 'es'));
- $this->assertSame( '13/02/2009 23:31:30', $date->get(Date::DATETIME_MEDIUM, 'es'));
- $this->assertSame( '13/02/09 23:31', $date->get(Date::DATETIME_SHORT, 'es'));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::ATOM, 'es'));
- $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Date::COOKIE, 'es'));
- $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Date::RFC_822, 'es'));
- $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Date::RFC_850, 'es'));
- $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Date::RFC_1036, 'es'));
- $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Date::RFC_1123, 'es'));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::RFC_3339, 'es'));
- $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Date::RSS, 'es'));
- $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Date::W3C, 'es'));
- $date->setTimezone('Indian/Maldives');
- $this->assertSame( '1234567890', $date->get( ));
- $this->assertSame( '14', $date->get(Date::DAY ));
- $this->assertSame( 'Sam', $date->get(Date::WEEKDAY_SHORT ));
- $this->assertSame( '14', $date->get(Date::DAY_SHORT ));
- $this->assertSame( 'Samstag', $date->get(Date::WEEKDAY ));
- $this->assertSame( '6', $date->get(Date::WEEKDAY_8601 ));
- $this->assertSame( 'th', $date->get(Date::DAY_SUFFIX ));
- $this->assertSame( '6', $date->get(Date::WEEKDAY_DIGIT ));
- $this->assertSame( '44', $date->get(Date::DAY_OF_YEAR ));
- $this->assertSame( 'S', $date->get(Date::WEEKDAY_NARROW ));
- $this->assertSame( 'Sa.', $date->get(Date::WEEKDAY_NAME ));
- $this->assertSame( '07', $date->get(Date::WEEK ));
- $this->assertSame( 'Februar', $date->get(Date::MONTH_NAME ));
- $this->assertSame( '02', $date->get(Date::MONTH ));
- $this->assertSame( 'Feb', $date->get(Date::MONTH_NAME_SHORT ));
- $this->assertSame( '2', $date->get(Date::MONTH_SHORT ));
- $this->assertSame( '28', $date->get(Date::MONTH_DAYS ));
- $this->assertSame( 'F', $date->get(Date::MONTH_NAME_NARROW));
- $this->assertSame( '0', $date->get(Date::LEAPYEAR ));
- $this->assertSame( '2009', $date->get(Date::YEAR_8601 ));
- $this->assertSame( '2009', $date->get(Date::YEAR ));
- $this->assertSame( '09', $date->get(Date::YEAR_SHORT ));
- $this->assertSame( '09', $date->get(Date::YEAR_SHORT_8601 ));
- $this->assertSame( 'vorm.', $date->get(Date::MERIDIEM ));
- $this->assertSame( '021', $date->get(Date::SWATCH ));
- $this->assertSame( '4', $date->get(Date::HOUR_SHORT_AM ));
- $this->assertSame( '4', $date->get(Date::HOUR_SHORT ));
- $this->assertSame( '04', $date->get(Date::HOUR_AM ));
- $this->assertSame( '04', $date->get(Date::HOUR ));
- $this->assertSame( '31', $date->get(Date::MINUTE ));
- $this->assertSame( '30', $date->get(Date::SECOND ));
- $this->assertSame( '0', $date->get(Date::MILLISECOND ));
- $this->assertSame( '31', $date->get(Date::MINUTE_SHORT ));
- $this->assertSame( '30', $date->get(Date::SECOND_SHORT ));
- $this->assertSame( 'Indian/Maldives', $date->get(Date::TIMEZONE_NAME ));
- $this->assertSame( '0', $date->get(Date::DAYLIGHT ));
- $this->assertSame( '+0500', $date->get(Date::GMT_DIFF ));
- $this->assertSame( '+05:00', $date->get(Date::GMT_DIFF_SEP ));
- $this->assertSame( 'MVT', $date->get(Date::TIMEZONE ));
- $this->assertSame( '18000', $date->get(Date::TIMEZONE_SECS ));
- $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Date::ISO_8601 ));
- $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Date::RFC_2822 ));
- $this->assertSame( '1234567890', $date->get(Date::TIMESTAMP ));
- $this->assertSame( 'n. Chr.', $date->get(Date::ERA ));
- $this->assertSame( 'n. Chr.', $date->get(Date::ERA_NAME ));
- $this->assertSame( '14.02.2009', $date->get(Date::DATES ));
- $this->assertSame( 'Samstag, 14. Februar 2009', $date->get(Date::DATE_FULL ));
- $this->assertSame( '14. Februar 2009', $date->get(Date::DATE_LONG ));
- $this->assertSame( '14.02.2009', $date->get(Date::DATE_MEDIUM ));
- $this->assertSame( '14.02.09', $date->get(Date::DATE_SHORT ));
- $this->assertSame( '04:31:30', $date->get(Date::TIMES ));
- $this->assertSame( '04:31:30 Indian/Maldives', $date->get(Date::TIME_FULL ));
- $this->assertSame( '04:31:30 MVT', $date->get(Date::TIME_LONG ));
- $this->assertSame( '04:31:30', $date->get(Date::TIME_MEDIUM ));
- $this->assertSame( '04:31', $date->get(Date::TIME_SHORT ));
- $this->assertSame( '14.02.2009 04:31:30', $date->get(Date::DATETIME ));
- $this->assertSame('Samstag, 14. Februar 2009 04:31:30 Indian/Maldives', $date->get(Date::DATETIME_FULL ));
- $this->assertSame( '14. Februar 2009 04:31:30 MVT', $date->get(Date::DATETIME_LONG ));
- $this->assertSame( '14.02.2009 04:31:30', $date->get(Date::DATETIME_MEDIUM ));
- $this->assertSame( '14.02.09 04:31', $date->get(Date::DATETIME_SHORT ));
- $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Date::ATOM ));
- $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Date::COOKIE ));
- $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Date::RFC_822 ));
- $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Date::RFC_850 ));
- $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Date::RFC_1036 ));
- $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Date::RFC_1123 ));
- $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Date::RFC_3339 ));
- $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Date::RSS ));
- $this->assertSame( '2009-02-14T04:31:30+05:00'…
Large files files are truncated, but you can click here to view the full file