[GENERIC] Zend_Date:
[zend/radio.git] / tests / Zend / DateTest.php
blob179bf1e722bf96746db15c2ad319a4e0c33620f4
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Date
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id $
23 /**
24 * Test helper
26 require_once dirname(__FILE__) . '/../TestHelper.php';
28 /**
29 * These const values control some testing behavior.
30 * They may be defined here or in TestConfiguration.php.
32 if (!defined('TESTS_ZEND_LOCALE_BCMATH_ENABLED')) {
33 // Set to false to disable usage of bcmath extension by Zend_Date
34 define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', true);
36 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE')) {
37 // Set to true to run full Zend_Date unit tests.
38 // Set to false to run a good subset of Zend_Date unit tests.
39 define('TESTS_ZEND_I18N_EXTENDED_COVERAGE', true);
42 /**
43 * Zend_Date
45 require_once 'Zend/Loader.php';
46 require_once 'Zend/Date.php';
47 require_once 'Zend/Locale.php';
48 require_once 'Zend/Date/Cities.php';
49 require_once 'Zend/TimeSync.php';
51 // echo "BCMATH is ", Zend_Locale_Math::isBcmathDisabled() ? 'disabled':'not disabled', "\n";
53 /**
54 * @category Zend
55 * @package Zend_Date
56 * @subpackage UnitTests
57 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
58 * @license http://framework.zend.com/license/new-bsd New BSD License
59 * @group Zend_Date
61 class Zend_DateTest extends PHPUnit_Framework_TestCase
64 private $_cache = null;
66 public function setUp()
68 $this->originalTimezone = date_default_timezone_get();
69 date_default_timezone_set('Indian/Maldives');
70 require_once 'Zend/Cache.php';
71 $this->_cache = Zend_Cache::factory('Core', 'File',
72 array('lifetime' => 120, 'automatic_serialization' => true),
73 array('cache_dir' => dirname(__FILE__) . '/_files/'));
74 Zend_Date::setOptions(array('cache' => $this->_cache));
75 Zend_Date::setOptions(array('fix_dst' => true));
76 Zend_Date::setOptions(array('extend_month' => false));
77 Zend_Date::setOptions(array('format_type' => 'iso'));
80 public function tearDown()
82 $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
83 date_default_timezone_set($this->originalTimezone);
86 /**
87 * Test for date object creation
89 public function testCreation()
91 // look if locale is detectable
92 try {
93 $locale = new Zend_Locale();
94 } catch (Zend_Locale_Exception $e) {
95 $this->markTestSkipped('Autodetection of locale failed');
96 return;
99 $date = new Zend_Date(0);
100 $this->assertTrue($date instanceof Zend_Date);
104 * Test for date object creation using default format for a locale
106 public function testCreationDefaultFormat()
108 // look if locale is detectable
109 try {
110 $locale = new Zend_Locale();
111 } catch (Zend_Locale_Exception $e) {
112 $this->markTestSkipped('Autodetection of locale failed');
113 return;
116 $date = new Zend_Date('2006-01-01');
117 $this->assertTrue($date instanceof Zend_Date);
118 $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Zend_Date::ISO_8601));
120 $date = new Zend_Date('2006-01-01', 'en_US');
121 $this->assertTrue($date instanceof Zend_Date);
122 $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Zend_Date::ISO_8601));
126 * Test for date object creation using default format for a locale
128 public function testCreationDefaultFormatConsistency()
130 // look if locale is detectable
131 try {
132 $locale = new Zend_Locale();
133 } catch (Zend_Locale_Exception $e) {
134 $this->markTestSkipped('Autodetection of locale failed');
135 return;
138 date_default_timezone_set('America/New_York');
139 $locale = 'en_US';
140 //2006-01-01T00:00:00+05:00
141 $date1 = new Zend_Date('2006-01-01 01:00:00', Zend_Date::ISO_8601, $locale);
142 $date1string = $date1->get(Zend_Date::ISO_8601);
144 // en_US defines AM/PM, hour 0 does not exist
145 // ISO defines dates without AM, 0 exists instead of 12 PM
146 // therefor hour is set to 1 to verify
147 $date2 = new Zend_Date('2006-01-01', Zend_Date::DATES, $locale);
148 $date2->setTime('01:00:00');
149 $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601));
150 $date2 = new Zend_Date('01-01-2006', Zend_Date::DATES, $locale);
151 $date2->setTime('01:00:00');
152 $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601));
153 $date2 = new Zend_Date('2006-01-01', null, $locale);
154 $date2->setTime('01:00:00');
155 $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601));
156 $date2 = new Zend_Date('2006-01-01');
157 $date2->setTime('01:00:00');
158 $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601));
159 $date2 = new Zend_Date('2006-01-01 01:00:00');
160 $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601));
164 * Test for creation with timestamp
166 public function testCreationTimestamp()
168 // look if locale is detectable
169 try {
170 $locale = new Zend_Locale();
171 } catch (Zend_Locale_Exception $e) {
172 $this->markTestSkipped('Autodetection of locale failed');
173 return;
176 $date = new Zend_Date('12345678');
177 $this->assertTrue($date instanceof Zend_Date);
181 * Test for creation but only part of date
183 public function testCreationDatePart()
185 // look if locale is detectable
186 try {
187 $locale = new Zend_Locale();
188 } catch (Zend_Locale_Exception $e) {
189 $this->markTestSkipped('Autodetection of locale failed');
190 return;
193 $date = new Zend_Date('13',Zend_Date::HOUR);
194 $this->assertTrue($date instanceof Zend_Date);
196 $date = new Zend_Date('20070802', 'YYYYMMdd');
197 $this->assertSame("2007-08-02T00:00:00+05:00", $date->getIso());
201 * Test for creation but only a defined locale
203 public function testCreationLocale()
205 $locale = new Zend_Locale('de_AT');
206 $date = new Zend_Date('13',null,$locale);
207 $this->assertTrue($date instanceof Zend_Date);
211 * Test for creation but only part of date with locale
213 public function testCreationLocalePart()
215 $locale = new Zend_Locale('de_AT');
216 $date = new Zend_Date('13',Zend_Date::HOUR,$locale);
217 $this->assertTrue($date instanceof Zend_Date);
221 * Test for date object creation using default format for a locale
223 public function testCreationDefaultLoose()
225 // look if locale is detectable
226 try {
227 $locale = new Zend_Locale();
228 } catch (Zend_Locale_Exception $e) {
229 $this->markTestSkipped('Autodetection of locale failed');
230 return;
233 $locale = 'de_AT';
234 $date = new Zend_Date();
236 $date = $date->getTimestamp();
237 $this->assertTrue(abs($date - time()) < 2);
239 date_default_timezone_set('GMT');
240 $date = new Zend_Date(Zend_Date::YEAR);
242 $date = $date->getTimestamp();
243 $reference = gmmktime(0,0,0,1,1,date('Y'));
244 $this->assertTrue($reference == $date);
246 $date = new Zend_Date('ar_EG');
247 $this->assertSame('ar_EG', $date->getLocale());
248 $date = $date->getTimestamp();
249 $this->assertTrue(abs($date - time()) < 2);
253 * Test for getTimestamp
255 public function testGetTimestamp()
257 $locale = new Zend_Locale('de_AT');
258 $date = new Zend_Date(10000000);
259 $this->assertSame(10000000, $date->getTimestamp());
263 * Test for getUnixTimestamp
265 public function testgetUnixTimestamp2()
267 $locale = new Zend_Locale('de_AT');
268 $date = new Zend_Date(-100000000);
269 $this->assertSame(-100000000, $date->getTimestamp());
273 * Test for setTimestamp
275 public function testSetTimestamp()
277 $locale = new Zend_Locale('de_AT');
278 $date = new Zend_Date(0,Zend_Date::TIMESTAMP,$locale);
279 $result = $date->setTimestamp(10000000);
280 $this->assertSame('10000000', (string)$result->getTimestamp());
284 * Test for setTimestamp
286 public function testSetTimestamp2()
288 try {
289 $locale = new Zend_Locale('de_AT');
290 $date = new Zend_Date(0,null,$locale);
291 $result = $date->setTimestamp('notimestamp');
292 $this->Fail("exception expected");
293 } catch (Zend_Date_Exception $e) {
294 // success
299 * Test for addTimestamp
301 public function testAddTimestamp()
303 $locale = new Zend_Locale('de_AT');
304 $date = new Zend_Date(0,null,$locale);
305 $result = $date->addTimestamp(10000000);
306 $this->assertSame('10000000', (string)$result->getTimestamp());
308 $result = $date->addTimestamp(array('timestamp' => 1000));
309 $this->assertSame('10001000', (string)$result->getTimestamp());
311 try {
312 $result = $date->addTimestamp(array('notimestamp' => 1000));
313 $this->fail("exception expected");
314 } catch (Zend_Date_Exception $e) {
315 // success
320 * Test for addTimestamp
322 public function testAddTimestamp2()
324 try {
325 $locale = new Zend_Locale('de_AT');
326 $date = new Zend_Date(0,null,$locale);
327 $result = $date->addTimestamp('notimestamp');
328 $this->fail("exception expected");
329 } catch (Zend_Date_Exception $e) {
330 // success
335 * Test for subTimestamp
337 public function testSubTimestamp()
339 $locale = new Zend_Locale('de_AT');
340 $date = new Zend_Date(0,null,$locale);
341 $result = $date->subTimestamp(10000000);
342 $this->assertSame('-10000000', (string)$result->getTimestamp());
346 * Test for subTimestamp
348 public function testSubTimestamp2()
350 try {
351 $locale = new Zend_Locale('de_AT');
352 $date = new Zend_Date(0,null,$locale);
353 $result = $date->subTimestamp('notimestamp');
354 $this->fail("exception expected");
355 } catch (Zend_Date_Exception $e) {
356 // success
361 * Test for compareTimestamp
363 public function testCompareTimestamp()
365 $locale = new Zend_Locale('de_AT');
366 $date1 = new Zend_Date(0,null,$locale);
367 $date2 = new Zend_Date(0,null,$locale);
368 $this->assertSame(0, $date1->compareTimestamp($date2));
370 $date2 = new Zend_Date(100,null,$locale);
371 $this->assertSame(-1, $date1->compareTimestamp($date2));
373 $date2 = new Zend_Date(-100,null,$locale);
374 $this->assertSame(1, $date1->compareTimestamp($date2));
378 * Test for __toString
380 public function test_ToString()
382 $locale = new Zend_Locale('de_AT');
383 $date = new Zend_Date(0,null,$locale);
384 $date->setTimezone(date_default_timezone_get());
385 $this->assertSame('01.01.1970 05:00:00', $date->__toString());
389 * Test for toString
391 public function testToString()
393 $locale = new Zend_Locale('de_AT');
394 $date = new Zend_Date(1234567890,null,$locale);
395 $date->setTimezone(date_default_timezone_get());
396 $this->assertSame('14.02.2009 04:31:30', $date->toString( ));
397 $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString('en_US' ));
398 $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString(null, 'en_US'));
399 $this->assertSame('2009', $date->toString('yyy', null ));
400 $this->assertSame('14.02.2009 04:31:30', $date->toString(null, null ));
402 $date->setTimeZone('UTC');
403 $this->assertSame('Feb 13, 2009 11:31:30 PM', $date->toString(null, 'en_US'));
405 $date->setTimeZone('Indian/Maldives');
406 $this->assertSame( "xxyy'yyxx", $date->toString("xx'yy''yy'xx"));
407 $this->assertSame( 'n.', $date->toString("GGGGG"));
408 $this->assertSame( 'n. Chr.', $date->toString( "GGGG"));
409 $this->assertSame( 'n. Chr.', $date->toString( "GGG"));
410 $this->assertSame( 'n. Chr.', $date->toString( "GG"));
411 $this->assertSame( 'n. Chr.', $date->toString( "G"));
412 $this->assertSame( '02009', $date->toString("yyyyy"));
413 $this->assertSame( '2009', $date->toString( "yyyy"));
414 $this->assertSame( '2009', $date->toString( "yyy"));
415 $this->assertSame( '09', $date->toString( "yy"));
416 $this->assertSame( '2009', $date->toString( "y"));
417 $this->assertSame( '02009', $date->toString("YYYYY"));
418 $this->assertSame( '2009', $date->toString( "YYYY"));
419 $this->assertSame( '2009', $date->toString( "YYY"));
420 $this->assertSame( '09', $date->toString( "YY"));
421 $this->assertSame( '2009', $date->toString( "Y"));
422 $this->assertSame( 'F', $date->toString("MMMMM"));
423 $this->assertSame( 'Februar', $date->toString( "MMMM"));
424 $this->assertSame( 'Feb', $date->toString( "MMM"));
425 $this->assertSame( '02', $date->toString( "MM"));
426 $this->assertSame( '2', $date->toString( "M"));
427 $this->assertSame( '07', $date->toString( "ww"));
428 $this->assertSame( '7', $date->toString( "w"));
429 $this->assertSame( '14', $date->toString( "dd"));
430 $this->assertSame( '14', $date->toString( "d"));
431 $this->assertSame( '044', $date->toString( "DDD"));
432 $this->assertSame( '44', $date->toString( "DD"));
433 $this->assertSame( '44', $date->toString( "D"));
434 $this->assertSame( 'S', $date->toString("EEEEE"));
435 $this->assertSame( 'Samstag', $date->toString( "EEEE"));
436 $this->assertSame( 'Sam', $date->toString( "EEE"));
437 $this->assertSame( 'Sa.', $date->toString( "EE"));
438 $this->assertSame( 'S', $date->toString( "E"));
439 $this->assertSame( '06', $date->toString( "ee"));
440 $this->assertSame( '6', $date->toString( "e"));
441 $this->assertSame( 'vorm.', $date->toString( "a"));
442 $this->assertSame( '04', $date->toString( "hh"));
443 $this->assertSame( '4', $date->toString( "h"));
444 $this->assertSame( '04', $date->toString( "HH"));
445 $this->assertSame( '4', $date->toString( "H"));
446 $this->assertSame( '31', $date->toString( "mm"));
447 $this->assertSame( '31', $date->toString( "m"));
448 $this->assertSame( '30', $date->toString( "ss"));
449 $this->assertSame( '30', $date->toString( "s"));
450 $this->assertSame( '0', $date->toString( "S"));
451 $this->assertSame('Indian/Maldives', $date->toString( "zzzz"));
452 $this->assertSame( 'MVT', $date->toString( "zzz"));
453 $this->assertSame( 'MVT', $date->toString( "zz"));
454 $this->assertSame( 'MVT', $date->toString( "z"));
455 $this->assertSame( '+05:00', $date->toString( "ZZZZ"));
456 $this->assertSame( '+0500', $date->toString( "ZZZ"));
457 $this->assertSame( '+0500', $date->toString( "ZZ"));
458 $this->assertSame( '+0500', $date->toString( "Z"));
459 $this->assertSame( '16290000', $date->toString("AAAAA"));
460 $this->assertSame( '16290000', $date->toString( "AAAA"));
461 $this->assertSame( '16290000', $date->toString( "AAA"));
462 $this->assertSame( '16290000', $date->toString( "AA"));
463 $this->assertSame( '16290000', $date->toString( "A"));
465 $date = new Zend_Date("1-1-01",null,$locale);
466 $date->setTimezone(date_default_timezone_get());
467 $this->assertSame('01', $date->toString("yy"));
471 * Test for toValue
473 public function testToValue()
475 $locale = new Zend_Locale('de_AT');
476 $date = new Zend_Date(1234567890,null,$locale);
477 $date->setTimezone(date_default_timezone_get());
478 $this->assertSame(1234567890, $date->toValue() );
479 $this->assertSame( 14, $date->toValue(Zend_Date::DAY));
481 $date->setTimezone('UTC');
482 $this->assertSame( 13, $date->toValue(Zend_Date::DAY ));
483 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_SHORT ));
484 $this->assertSame( 13, $date->toValue(Zend_Date::DAY_SHORT ));
485 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY ));
486 $this->assertSame( 5, $date->toValue(Zend_Date::WEEKDAY_8601 ));
487 $this->assertFalse( $date->toValue(Zend_Date::DAY_SUFFIX ));
488 $this->assertSame( 5, $date->toValue(Zend_Date::WEEKDAY_DIGIT ));
489 $this->assertSame( 43, $date->toValue(Zend_Date::DAY_OF_YEAR ));
490 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NARROW ));
491 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NAME ));
492 $this->assertSame( 7, $date->toValue(Zend_Date::WEEK ));
493 $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME ));
494 $this->assertSame( 2, $date->toValue(Zend_Date::MONTH ));
495 $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_SHORT ));
496 $this->assertSame( 2, $date->toValue(Zend_Date::MONTH_SHORT ));
497 $this->assertSame( 28, $date->toValue(Zend_Date::MONTH_DAYS ));
498 $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_NARROW));
499 $this->assertSame( 0, $date->toValue(Zend_Date::LEAPYEAR ));
500 $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR_8601 ));
501 $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR ));
502 $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT ));
503 $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT_8601 ));
504 $this->assertFalse( $date->toValue(Zend_Date::MERIDIEM ));
505 $this->assertSame( 21, $date->toValue(Zend_Date::SWATCH ));
506 $this->assertSame( 11, $date->toValue(Zend_Date::HOUR_SHORT_AM ));
507 $this->assertSame( 23, $date->toValue(Zend_Date::HOUR_SHORT ));
508 $this->assertSame( 11, $date->toValue(Zend_Date::HOUR_AM ));
509 $this->assertSame( 23, $date->toValue(Zend_Date::HOUR ));
510 $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE ));
511 $this->assertSame( 30, $date->toValue(Zend_Date::SECOND ));
512 $this->assertSame( 0, $date->toValue(Zend_Date::MILLISECOND ));
513 $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE_SHORT ));
514 $this->assertSame( 30, $date->toValue(Zend_Date::SECOND_SHORT ));
515 $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE_NAME ));
516 $this->assertSame( 0, $date->toValue(Zend_Date::DAYLIGHT ));
517 $this->assertSame( 0, $date->toValue(Zend_Date::GMT_DIFF ));
518 $this->assertFalse( $date->toValue(Zend_Date::GMT_DIFF_SEP ));
519 $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE ));
520 $this->assertSame( 0, $date->toValue(Zend_Date::TIMEZONE_SECS ));
521 $this->assertFalse( $date->toValue(Zend_Date::ISO_8601 ));
522 $this->assertFalse( $date->toValue(Zend_Date::RFC_2822 ));
523 $this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP ));
524 $this->assertFalse( $date->toValue(Zend_Date::ERA ));
525 $this->assertFalse( $date->toValue(Zend_Date::ERA_NAME ));
526 $this->assertFalse( $date->toValue(Zend_Date::DATES ));
527 $this->assertFalse( $date->toValue(Zend_Date::DATE_FULL ));
528 $this->assertFalse( $date->toValue(Zend_Date::DATE_LONG ));
529 $this->assertFalse( $date->toValue(Zend_Date::DATE_MEDIUM ));
530 $this->assertFalse( $date->toValue(Zend_Date::DATE_SHORT ));
531 $this->assertFalse( $date->toValue(Zend_Date::TIMES ));
532 $this->assertFalse( $date->toValue(Zend_Date::TIME_FULL ));
533 $this->assertFalse( $date->toValue(Zend_Date::TIME_LONG ));
534 $this->assertFalse( $date->toValue(Zend_Date::TIME_MEDIUM ));
535 $this->assertFalse( $date->toValue(Zend_Date::TIME_SHORT ));
536 $this->assertFalse( $date->toValue(Zend_Date::DATETIME ));
537 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_FULL ));
538 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_LONG ));
539 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_MEDIUM ));
540 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_SHORT ));
541 $this->assertFalse( $date->toValue(Zend_Date::ATOM ));
542 $this->assertFalse( $date->toValue(Zend_Date::COOKIE ));
543 $this->assertFalse( $date->toValue(Zend_Date::RFC_822 ));
544 $this->assertFalse( $date->toValue(Zend_Date::RFC_850 ));
545 $this->assertFalse( $date->toValue(Zend_Date::RFC_1036 ));
546 $this->assertFalse( $date->toValue(Zend_Date::RFC_1123 ));
547 $this->assertFalse( $date->toValue(Zend_Date::RFC_3339 ));
548 $this->assertFalse( $date->toValue(Zend_Date::RSS ));
549 $this->assertFalse( $date->toValue(Zend_Date::W3C ));
551 $date->setTimezone('Indian/Maldives');
552 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_SHORT ));
553 $this->assertSame( 14, $date->toValue(Zend_Date::DAY_SHORT ));
554 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY ));
555 $this->assertSame( 6, $date->toValue(Zend_Date::WEEKDAY_8601 ));
556 $this->assertFalse( $date->toValue(Zend_Date::DAY_SUFFIX ));
557 $this->assertSame( 6, $date->toValue(Zend_Date::WEEKDAY_DIGIT ));
558 $this->assertSame( 44, $date->toValue(Zend_Date::DAY_OF_YEAR ));
559 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NARROW ));
560 $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NAME ));
561 $this->assertSame( 7, $date->toValue(Zend_Date::WEEK ));
562 $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME ));
563 $this->assertSame( 2, $date->toValue(Zend_Date::MONTH ));
564 $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_SHORT ));
565 $this->assertSame( 2, $date->toValue(Zend_Date::MONTH_SHORT ));
566 $this->assertSame( 28, $date->toValue(Zend_Date::MONTH_DAYS ));
567 $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_NARROW));
568 $this->assertSame( 0, $date->toValue(Zend_Date::LEAPYEAR ));
569 $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR_8601 ));
570 $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR ));
571 $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT ));
572 $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT_8601 ));
573 $this->assertFalse( $date->toValue(Zend_Date::MERIDIEM ));
574 $this->assertSame( 21, $date->toValue(Zend_Date::SWATCH ));
575 $this->assertSame( 4, $date->toValue(Zend_Date::HOUR_SHORT_AM ));
576 $this->assertSame( 4, $date->toValue(Zend_Date::HOUR_SHORT ));
577 $this->assertSame( 4, $date->toValue(Zend_Date::HOUR_AM ));
578 $this->assertSame( 4, $date->toValue(Zend_Date::HOUR ));
579 $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE ));
580 $this->assertSame( 30, $date->toValue(Zend_Date::SECOND ));
581 $this->assertSame( 0, $date->toValue(Zend_Date::MILLISECOND ));
582 $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE_SHORT ));
583 $this->assertSame( 30, $date->toValue(Zend_Date::SECOND_SHORT ));
584 $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE_NAME ));
585 $this->assertSame( 0, $date->toValue(Zend_Date::DAYLIGHT ));
586 $this->assertSame( 500, $date->toValue(Zend_Date::GMT_DIFF ));
587 $this->assertFalse( $date->toValue(Zend_Date::GMT_DIFF_SEP ));
588 $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE ));
589 $this->assertSame( 18000, $date->toValue(Zend_Date::TIMEZONE_SECS ));
590 $this->assertFalse( $date->toValue(Zend_Date::ISO_8601 ));
591 $this->assertFalse( $date->toValue(Zend_Date::RFC_2822 ));
592 $this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP ));
593 $this->assertFalse( $date->toValue(Zend_Date::ERA ));
594 $this->assertFalse( $date->toValue(Zend_Date::ERA_NAME ));
595 $this->assertFalse( $date->toValue(Zend_Date::DATES ));
596 $this->assertFalse( $date->toValue(Zend_Date::DATE_FULL ));
597 $this->assertFalse( $date->toValue(Zend_Date::DATE_LONG ));
598 $this->assertFalse( $date->toValue(Zend_Date::DATE_MEDIUM ));
599 $this->assertFalse( $date->toValue(Zend_Date::DATE_SHORT ));
600 $this->assertFalse( $date->toValue(Zend_Date::TIMES ));
601 $this->assertFalse( $date->toValue(Zend_Date::TIME_FULL ));
602 $this->assertFalse( $date->toValue(Zend_Date::TIME_LONG ));
603 $this->assertFalse( $date->toValue(Zend_Date::TIME_MEDIUM ));
604 $this->assertFalse( $date->toValue(Zend_Date::TIME_SHORT ));
605 $this->assertFalse( $date->toValue(Zend_Date::DATETIME ));
606 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_FULL ));
607 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_LONG ));
608 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_MEDIUM ));
609 $this->assertFalse( $date->toValue(Zend_Date::DATETIME_SHORT ));
610 $this->assertFalse( $date->toValue(Zend_Date::ATOM ));
611 $this->assertFalse( $date->toValue(Zend_Date::COOKIE ));
612 $this->assertFalse( $date->toValue(Zend_Date::RFC_822 ));
613 $this->assertFalse( $date->toValue(Zend_Date::RFC_850 ));
614 $this->assertFalse( $date->toValue(Zend_Date::RFC_1036 ));
615 $this->assertFalse( $date->toValue(Zend_Date::RFC_1123 ));
616 $this->assertFalse( $date->toValue(Zend_Date::RFC_3339 ));
617 $this->assertFalse( $date->toValue(Zend_Date::RSS ));
618 $this->assertFalse( $date->toValue(Zend_Date::W3C ));
622 * Test for toValue
624 public function testGet()
626 $locale = new Zend_Locale('de_AT');
627 $date = new Zend_Date(1234567890,null,$locale);
629 $date->setTimezone('UTC');
630 $this->assertSame( '13', $date->get(Zend_Date::DAY ));
631 $this->assertSame( 'Fre', $date->get(Zend_Date::WEEKDAY_SHORT ));
632 $this->assertSame( '13', $date->get(Zend_Date::DAY_SHORT ));
633 $this->assertSame( 'Freitag', $date->get(Zend_Date::WEEKDAY ));
634 $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_8601 ));
635 $this->assertSame( 'th', $date->get(Zend_Date::DAY_SUFFIX ));
636 $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_DIGIT ));
637 $this->assertSame( '43', $date->get(Zend_Date::DAY_OF_YEAR ));
638 $this->assertSame( 'F', $date->get(Zend_Date::WEEKDAY_NARROW ));
639 $this->assertSame( 'Fr.', $date->get(Zend_Date::WEEKDAY_NAME ));
640 $this->assertSame( '07', $date->get(Zend_Date::WEEK ));
641 $this->assertSame( 'Februar', $date->get(Zend_Date::MONTH_NAME ));
642 $this->assertSame( '02', $date->get(Zend_Date::MONTH ));
643 $this->assertSame( 'Feb', $date->get(Zend_Date::MONTH_NAME_SHORT ));
644 $this->assertSame( '2', $date->get(Zend_Date::MONTH_SHORT ));
645 $this->assertSame( '28', $date->get(Zend_Date::MONTH_DAYS ));
646 $this->assertSame( 'F', $date->get(Zend_Date::MONTH_NAME_NARROW));
647 $this->assertSame( '0', $date->get(Zend_Date::LEAPYEAR ));
648 $this->assertSame( '2009', $date->get(Zend_Date::YEAR_8601 ));
649 $this->assertSame( '2009', $date->get(Zend_Date::YEAR ));
650 $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT ));
651 $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT_8601 ));
652 $this->assertSame( 'nachm.', $date->get(Zend_Date::MERIDIEM ));
653 $this->assertSame( '021', $date->get(Zend_Date::SWATCH ));
654 $this->assertSame( '11', $date->get(Zend_Date::HOUR_SHORT_AM ));
655 $this->assertSame( '23', $date->get(Zend_Date::HOUR_SHORT ));
656 $this->assertSame( '11', $date->get(Zend_Date::HOUR_AM ));
657 $this->assertSame( '23', $date->get(Zend_Date::HOUR ));
658 $this->assertSame( '31', $date->get(Zend_Date::MINUTE ));
659 $this->assertSame( '30', $date->get(Zend_Date::SECOND ));
660 $this->assertSame( '0', $date->get(Zend_Date::MILLISECOND ));
661 $this->assertSame( '31', $date->get(Zend_Date::MINUTE_SHORT ));
662 $this->assertSame( '30', $date->get(Zend_Date::SECOND_SHORT ));
663 $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE_NAME ));
664 $this->assertSame( '0', $date->get(Zend_Date::DAYLIGHT ));
665 $this->assertSame( '+0000', $date->get(Zend_Date::GMT_DIFF ));
666 $this->assertSame( '+00:00', $date->get(Zend_Date::GMT_DIFF_SEP ));
667 $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE ));
668 $this->assertSame( '0', $date->get(Zend_Date::TIMEZONE_SECS ));
669 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ISO_8601 ));
670 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_2822 ));
671 $this->assertSame( '1234567890', $date->get(Zend_Date::TIMESTAMP ));
672 $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA ));
673 $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA_NAME ));
674 $this->assertSame( '13.02.2009', $date->get(Zend_Date::DATES ));
675 $this->assertSame( 'Freitag, 13. Februar 2009', $date->get(Zend_Date::DATE_FULL ));
676 $this->assertSame( '13. Februar 2009', $date->get(Zend_Date::DATE_LONG ));
677 $this->assertSame( '13.02.2009', $date->get(Zend_Date::DATE_MEDIUM ));
678 $this->assertSame( '13.02.09', $date->get(Zend_Date::DATE_SHORT ));
679 $this->assertSame( '23:31:30', $date->get(Zend_Date::TIMES ));
680 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_FULL ));
681 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_LONG ));
682 $this->assertSame( '23:31:30', $date->get(Zend_Date::TIME_MEDIUM ));
683 $this->assertSame( '23:31', $date->get(Zend_Date::TIME_SHORT ));
684 $this->assertSame( '13.02.2009 23:31:30', $date->get(Zend_Date::DATETIME ));
685 $this->assertSame('Freitag, 13. Februar 2009 23:31:30 UTC', $date->get(Zend_Date::DATETIME_FULL ));
686 $this->assertSame( '13. Februar 2009 23:31:30 UTC', $date->get(Zend_Date::DATETIME_LONG ));
687 $this->assertSame( '13.02.2009 23:31:30', $date->get(Zend_Date::DATETIME_MEDIUM ));
688 $this->assertSame( '13.02.09 23:31', $date->get(Zend_Date::DATETIME_SHORT ));
689 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ATOM ));
690 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::COOKIE ));
691 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_822 ));
692 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::RFC_850 ));
693 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_1036 ));
694 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_1123 ));
695 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::RFC_3339 ));
696 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RSS ));
697 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C ));
699 $this->assertSame( '13', $date->get(Zend_Date::DAY, 'es'));
700 $this->assertSame( 'vie', $date->get(Zend_Date::WEEKDAY_SHORT, 'es'));
701 $this->assertSame( '13', $date->get(Zend_Date::DAY_SHORT, 'es'));
702 $this->assertSame( 'viernes', $date->get(Zend_Date::WEEKDAY, 'es'));
703 $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_8601, 'es'));
704 $this->assertSame( 'th', $date->get(Zend_Date::DAY_SUFFIX, 'es'));
705 $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_DIGIT, 'es'));
706 $this->assertSame( '43', $date->get(Zend_Date::DAY_OF_YEAR, 'es'));
707 $this->assertSame( 'v', $date->get(Zend_Date::WEEKDAY_NARROW, 'es'));
708 $this->assertSame( 'vie', $date->get(Zend_Date::WEEKDAY_NAME, 'es'));
709 $this->assertSame( '07', $date->get(Zend_Date::WEEK, 'es'));
710 $this->assertSame( 'febrero', $date->get(Zend_Date::MONTH_NAME, 'es'));
711 $this->assertSame( '02', $date->get(Zend_Date::MONTH, 'es'));
712 $this->assertSame( 'feb', $date->get(Zend_Date::MONTH_NAME_SHORT, 'es'));
713 $this->assertSame( '2', $date->get(Zend_Date::MONTH_SHORT, 'es'));
714 $this->assertSame( '28', $date->get(Zend_Date::MONTH_DAYS, 'es'));
715 $this->assertSame( 'f', $date->get(Zend_Date::MONTH_NAME_NARROW, 'es'));
716 $this->assertSame( '0', $date->get(Zend_Date::LEAPYEAR, 'es'));
717 $this->assertSame( '2009', $date->get(Zend_Date::YEAR_8601, 'es'));
718 $this->assertSame( '2009', $date->get(Zend_Date::YEAR, 'es'));
719 $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT, 'es'));
720 $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT_8601, 'es'));
721 $this->assertSame( 'p.m.', $date->get(Zend_Date::MERIDIEM, 'es'));
722 $this->assertSame( '021', $date->get(Zend_Date::SWATCH, 'es'));
723 $this->assertSame( '11', $date->get(Zend_Date::HOUR_SHORT_AM, 'es'));
724 $this->assertSame( '23', $date->get(Zend_Date::HOUR_SHORT, 'es'));
725 $this->assertSame( '11', $date->get(Zend_Date::HOUR_AM, 'es'));
726 $this->assertSame( '23', $date->get(Zend_Date::HOUR, 'es'));
727 $this->assertSame( '31', $date->get(Zend_Date::MINUTE, 'es'));
728 $this->assertSame( '30', $date->get(Zend_Date::SECOND, 'es'));
729 $this->assertSame( '0', $date->get(Zend_Date::MILLISECOND, 'es'));
730 $this->assertSame( '31', $date->get(Zend_Date::MINUTE_SHORT, 'es'));
731 $this->assertSame( '30', $date->get(Zend_Date::SECOND_SHORT, 'es'));
732 $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE_NAME, 'es'));
733 $this->assertSame( '0', $date->get(Zend_Date::DAYLIGHT, 'es'));
734 $this->assertSame( '+0000', $date->get(Zend_Date::GMT_DIFF, 'es'));
735 $this->assertSame( '+00:00', $date->get(Zend_Date::GMT_DIFF_SEP, 'es'));
736 $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE, 'es'));
737 $this->assertSame( '0', $date->get(Zend_Date::TIMEZONE_SECS, 'es'));
738 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ISO_8601, 'es'));
739 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_2822, 'es'));
740 $this->assertSame( '1234567890', $date->get(Zend_Date::TIMESTAMP, 'es'));
741 $this->assertSame( 'd.C.', $date->get(Zend_Date::ERA, 'es'));
742 $this->assertSame( 'anno Dómini', $date->get(Zend_Date::ERA_NAME, 'es'));
743 $this->assertSame( '13/02/2009', $date->get(Zend_Date::DATES, 'es'));
744 $this->assertSame( 'viernes 13 de febrero de 2009', $date->get(Zend_Date::DATE_FULL, 'es'));
745 $this->assertSame( '13 de febrero de 2009', $date->get(Zend_Date::DATE_LONG, 'es'));
746 $this->assertSame( '13/02/2009', $date->get(Zend_Date::DATE_MEDIUM, 'es'));
747 $this->assertSame( '13/02/09', $date->get(Zend_Date::DATE_SHORT, 'es'));
748 $this->assertSame( '23:31:30', $date->get(Zend_Date::TIMES, 'es'));
749 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_FULL, 'es'));
750 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_LONG, 'es'));
751 $this->assertSame( '23:31:30', $date->get(Zend_Date::TIME_MEDIUM, 'es'));
752 $this->assertSame( '23:31', $date->get(Zend_Date::TIME_SHORT, 'es'));
753 $this->assertSame( '13/02/2009 23:31:30', $date->get(Zend_Date::DATETIME, 'es'));
754 $this->assertSame('viernes 13 de febrero de 2009 23:31:30 UTC', $date->get(Zend_Date::DATETIME_FULL, 'es'));
755 $this->assertSame('13 de febrero de 2009 23:31:30 UTC', $date->get(Zend_Date::DATETIME_LONG, 'es'));
756 $this->assertSame( '13/02/2009 23:31:30', $date->get(Zend_Date::DATETIME_MEDIUM, 'es'));
757 $this->assertSame( '13/02/09 23:31', $date->get(Zend_Date::DATETIME_SHORT, 'es'));
758 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ATOM, 'es'));
759 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::COOKIE, 'es'));
760 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_822, 'es'));
761 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::RFC_850, 'es'));
762 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_1036, 'es'));
763 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_1123, 'es'));
764 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::RFC_3339, 'es'));
765 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RSS, 'es'));
766 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C, 'es'));
768 $date->setTimezone('Indian/Maldives');
769 $this->assertSame( '1234567890', $date->get( ));
770 $this->assertSame( '14', $date->get(Zend_Date::DAY ));
771 $this->assertSame( 'Sam', $date->get(Zend_Date::WEEKDAY_SHORT ));
772 $this->assertSame( '14', $date->get(Zend_Date::DAY_SHORT ));
773 $this->assertSame( 'Samstag', $date->get(Zend_Date::WEEKDAY ));
774 $this->assertSame( '6', $date->get(Zend_Date::WEEKDAY_8601 ));
775 $this->assertSame( 'th', $date->get(Zend_Date::DAY_SUFFIX ));
776 $this->assertSame( '6', $date->get(Zend_Date::WEEKDAY_DIGIT ));
777 $this->assertSame( '44', $date->get(Zend_Date::DAY_OF_YEAR ));
778 $this->assertSame( 'S', $date->get(Zend_Date::WEEKDAY_NARROW ));
779 $this->assertSame( 'Sa.', $date->get(Zend_Date::WEEKDAY_NAME ));
780 $this->assertSame( '07', $date->get(Zend_Date::WEEK ));
781 $this->assertSame( 'Februar', $date->get(Zend_Date::MONTH_NAME ));
782 $this->assertSame( '02', $date->get(Zend_Date::MONTH ));
783 $this->assertSame( 'Feb', $date->get(Zend_Date::MONTH_NAME_SHORT ));
784 $this->assertSame( '2', $date->get(Zend_Date::MONTH_SHORT ));
785 $this->assertSame( '28', $date->get(Zend_Date::MONTH_DAYS ));
786 $this->assertSame( 'F', $date->get(Zend_Date::MONTH_NAME_NARROW));
787 $this->assertSame( '0', $date->get(Zend_Date::LEAPYEAR ));
788 $this->assertSame( '2009', $date->get(Zend_Date::YEAR_8601 ));
789 $this->assertSame( '2009', $date->get(Zend_Date::YEAR ));
790 $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT ));
791 $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT_8601 ));
792 $this->assertSame( 'vorm.', $date->get(Zend_Date::MERIDIEM ));
793 $this->assertSame( '021', $date->get(Zend_Date::SWATCH ));
794 $this->assertSame( '4', $date->get(Zend_Date::HOUR_SHORT_AM ));
795 $this->assertSame( '4', $date->get(Zend_Date::HOUR_SHORT ));
796 $this->assertSame( '04', $date->get(Zend_Date::HOUR_AM ));
797 $this->assertSame( '04', $date->get(Zend_Date::HOUR ));
798 $this->assertSame( '31', $date->get(Zend_Date::MINUTE ));
799 $this->assertSame( '30', $date->get(Zend_Date::SECOND ));
800 $this->assertSame( '0', $date->get(Zend_Date::MILLISECOND ));
801 $this->assertSame( '31', $date->get(Zend_Date::MINUTE_SHORT ));
802 $this->assertSame( '30', $date->get(Zend_Date::SECOND_SHORT ));
803 $this->assertSame( 'Indian/Maldives', $date->get(Zend_Date::TIMEZONE_NAME ));
804 $this->assertSame( '0', $date->get(Zend_Date::DAYLIGHT ));
805 $this->assertSame( '+0500', $date->get(Zend_Date::GMT_DIFF ));
806 $this->assertSame( '+05:00', $date->get(Zend_Date::GMT_DIFF_SEP ));
807 $this->assertSame( 'MVT', $date->get(Zend_Date::TIMEZONE ));
808 $this->assertSame( '18000', $date->get(Zend_Date::TIMEZONE_SECS ));
809 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::ISO_8601 ));
810 $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date::RFC_2822 ));
811 $this->assertSame( '1234567890', $date->get(Zend_Date::TIMESTAMP ));
812 $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA ));
813 $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA_NAME ));
814 $this->assertSame( '14.02.2009', $date->get(Zend_Date::DATES ));
815 $this->assertSame( 'Samstag, 14. Februar 2009', $date->get(Zend_Date::DATE_FULL ));
816 $this->assertSame( '14. Februar 2009', $date->get(Zend_Date::DATE_LONG ));
817 $this->assertSame( '14.02.2009', $date->get(Zend_Date::DATE_MEDIUM ));
818 $this->assertSame( '14.02.09', $date->get(Zend_Date::DATE_SHORT ));
819 $this->assertSame( '04:31:30', $date->get(Zend_Date::TIMES ));
820 $this->assertSame( '04:31:30 Indian/Maldives', $date->get(Zend_Date::TIME_FULL ));
821 $this->assertSame( '04:31:30 MVT', $date->get(Zend_Date::TIME_LONG ));
822 $this->assertSame( '04:31:30', $date->get(Zend_Date::TIME_MEDIUM ));
823 $this->assertSame( '04:31', $date->get(Zend_Date::TIME_SHORT ));
824 $this->assertSame( '14.02.2009 04:31:30', $date->get(Zend_Date::DATETIME ));
825 $this->assertSame('Samstag, 14. Februar 2009 04:31:30 Indian/Maldives', $date->get(Zend_Date::DATETIME_FULL ));
826 $this->assertSame( '14. Februar 2009 04:31:30 MVT', $date->get(Zend_Date::DATETIME_LONG ));
827 $this->assertSame( '14.02.2009 04:31:30', $date->get(Zend_Date::DATETIME_MEDIUM ));
828 $this->assertSame( '14.02.09 04:31', $date->get(Zend_Date::DATETIME_SHORT ));
829 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::ATOM ));
830 $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Zend_Date::COOKIE ));
831 $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Zend_Date::RFC_822 ));
832 $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Zend_Date::RFC_850 ));
833 $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Zend_Date::RFC_1036 ));
834 $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date::RFC_1123 ));
835 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::RFC_3339 ));
836 $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date::RSS ));
837 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C ));
839 // when get() receives a format string it responses like toString();
840 $date->setTimezone('Indian/Maldives');
841 $this->assertSame('2009', $date->get('Y'));
845 * Test for toValue
847 public function testGet2()
849 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
850 $this->markTestSkipped('Extended I18N test skipped');
851 return;
854 $locale = new Zend_Locale('de_AT');
855 $date = new Zend_Date(-62362925370,null,$locale);
856 $this->assertSame('v. Chr.', $date->get(Zend_Date::ERA));
857 $this->assertSame('v. Chr.', $date->get(Zend_Date::ERA_NAME));
861 * Test for set
863 public function testSet()
865 $locale = new Zend_Locale('de_AT');
866 $date = new Zend_Date(0,null,$locale);
867 $d2 = new Zend_Date(1010101010,null,$locale);
868 $date->setTimezone(date_default_timezone_get());
869 $d2->setTimezone(date_default_timezone_get());
871 $retour = $date->set(1234567890);
872 $this->assertSame('1234567890', (string)$retour );
873 $this->assertSame('1010101010', (string)$date->set($d2 ));
874 $this->assertSame('1234567891', (string)$date->set(1234567891));
876 try {
877 $date->set('noday', Zend_Date::DAY);
878 $this->fail('exception expected');
879 } catch (Zend_Date_Exception $e) {
880 // success
883 $date->set($d2, Zend_Date::DAY);
884 $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date::W3C));
885 $date->set( 10, Zend_Date::DAY);
886 $this->assertSame('2009-02-10T04:31:31+05:00', $date->get(Zend_Date::W3C));
887 $date->set( 40, Zend_Date::DAY);
888 $this->assertSame('2009-03-12T04:31:31+05:00', $date->get(Zend_Date::W3C));
889 $date->set(-10, Zend_Date::DAY);
890 $this->assertSame('2009-02-18T04:31:31+05:00', $date->get(Zend_Date::W3C));
891 $date->setTimezone('UTC');
892 $date->set( 10, Zend_Date::DAY);
893 $this->assertSame('2009-02-10T23:31:31+00:00', $date->get(Zend_Date::W3C));
894 $date->setTimezone('Indian/Maldives');
895 $date->set($d2, Zend_Date::DAY);
896 $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date::W3C));
897 $date->setTimezone('UTC');
898 $date->set( 10, Zend_Date::DAY, 'en_US');
899 $this->assertSame('2009-02-10T23:31:31+00:00', $date->get(Zend_Date::W3C));
900 $date->set($d2, Zend_Date::DAY, 'en_US');
901 $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date::W3C));
902 $date->setTimezone('Indian/Maldives');
903 $date->set(-20, Zend_Date::DAY, 'en_US');
904 $this->assertSame('2009-01-11T04:31:31+05:00', $date->get(Zend_Date::W3C));
905 $date->set($d2, Zend_Date::DAY, 'en_US');
906 $this->assertSame('2009-01-04T04:31:31+05:00', $date->get(Zend_Date::W3C));
908 $date->set('10.April.2007', 'dd.MMMM.YYYY');
909 $this->assertSame('2007-04-10T00:00:00+05:00', $date->get(Zend_Date::W3C));
913 * Test for set
915 public function testSet2()
917 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
918 $this->markTestSkipped('Extended I18N test skipped');
919 return;
922 $locale = new Zend_Locale('de_AT');
923 $date = new Zend_Date(0,null,$locale);
924 $d2 = new Zend_Date(1010101010,null,$locale);
926 $date->setTimezone(date_default_timezone_get());
927 $d2->setTimezone(date_default_timezone_get());
928 $date->set(1234567890);
929 try {
930 $date->set('noday', Zend_Date::WEEKDAY_SHORT);
931 $this->fail('exception expected');
932 } catch (Zend_Date_Exception $e) {
933 // success
935 $date->set($d2, Zend_Date::WEEKDAY_SHORT);
936 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
937 $date->set('Son', Zend_Date::WEEKDAY_SHORT);
938 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
939 $date->set('Mon', Zend_Date::WEEKDAY_SHORT);
940 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C));
941 $date->setTimezone('UTC');
942 $date->set('Fre', Zend_Date::WEEKDAY_SHORT);
943 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
944 $date->set($d2, Zend_Date::WEEKDAY_SHORT);
945 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
946 $date->setTimezone('Indian/Maldives');
947 $date->set('Thu', Zend_Date::WEEKDAY_SHORT, 'en_US');
948 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
949 $date->set($d2, Zend_Date::WEEKDAY_SHORT, 'en_US');
950 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
951 $date->setTimezone('UTC');
952 $date->set('Wed', Zend_Date::WEEKDAY_SHORT , 'en_US');
953 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C));
954 $date->set($d2, Zend_Date::WEEKDAY_SHORT, 'en_US');
955 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
956 $date->setTimezone('Indian/Maldives');
958 $date->set(1234567890);
959 try {
960 $date->set('xxx', Zend_Date::DAY_SHORT);
961 $this->fail('exception expected');
962 } catch (Zend_Date_Exception $e) {
963 // success
965 $date->set($d2, Zend_Date::DAY_SHORT);
966 $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
967 $date->set( 10, Zend_Date::DAY_SHORT);
968 $this->assertSame('2009-02-10T04:31:30+05:00', $date->get(Zend_Date::W3C));
969 $date->set( 40, Zend_Date::DAY_SHORT);
970 $this->assertSame('2009-03-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
971 $date->set(-10, Zend_Date::DAY_SHORT);
972 $this->assertSame('2009-02-18T04:31:30+05:00', $date->get(Zend_Date::W3C));
973 $date->setTimeZone('UTC');
974 $date->set( 10, Zend_Date::DAY_SHORT);
975 $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date::W3C));
976 $date->set($d2, Zend_Date::DAY_SHORT);
977 $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
978 $date->setTimezone('Indian/Maldives');
979 $date->set( 10, Zend_Date::DAY_SHORT, 'en_US');
980 $this->assertSame('2009-02-10T04:31:30+05:00', $date->get(Zend_Date::W3C));
981 $date->set($d2, Zend_Date::DAY_SHORT, 'en_US');
982 $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
983 $date->setTimeZone('UTC');
984 $date->set(-20, Zend_Date::DAY_SHORT, 'en_US');
985 $this->assertSame('2009-01-11T23:31:30+00:00', $date->get(Zend_Date::W3C));
986 $date->set($d2, Zend_Date::DAY_SHORT, 'en_US');
987 $this->assertSame('2009-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
988 $date->setTimezone('Indian/Maldives');
990 $date->set(1234567890);
991 try {
992 $date->set('noday', Zend_Date::WEEKDAY);
993 $this->fail('exception expected');
994 } catch (Zend_Date_Exception $e) {
995 // success
997 $date->set($d2, Zend_Date::WEEKDAY);
998 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
999 $date->set('Sonntag', Zend_Date::WEEKDAY);
1000 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
1001 $date->set('Montag', Zend_Date::WEEKDAY);
1002 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C));
1003 $date->setTimeZone('UTC');
1004 $date->set('Freitag', Zend_Date::WEEKDAY);
1005 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1006 $date->set($d2, Zend_Date::WEEKDAY);
1007 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1008 $date->setTimezone('Indian/Maldives');
1009 $date->set('Wednesday', Zend_Date::WEEKDAY, 'en_US');
1010 $this->assertSame('2009-02-11T04:31:30+05:00', $date->get(Zend_Date::W3C));
1011 $date->set($d2, Zend_Date::WEEKDAY, 'en_US');
1012 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1013 $date->setTimeZone('UTC');
1014 $date->set('Thursday', Zend_Date::WEEKDAY, 'en_US');
1015 $this->assertSame('2009-02-12T23:31:30+00:00', $date->get(Zend_Date::W3C));
1016 $date->set($d2, Zend_Date::WEEKDAY, 'en_US');
1017 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1018 $date->setTimezone('Indian/Maldives');
1020 $date->set(1234567890);
1021 try {
1022 $date->set(0, Zend_Date::WEEKDAY_8601);
1023 $this->fail('exception expected');
1024 } catch (Zend_Date_Exception $e) {
1025 // success
1027 try {
1028 $date->set('noday', Zend_Date::WEEKDAY_8601);
1029 $this->fail('exception expected');
1030 } catch (Zend_Date_Exception $e) {
1031 // success
1033 $date->set($d2, Zend_Date::WEEKDAY_8601);
1034 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1035 $date->set(1, Zend_Date::WEEKDAY_8601);
1036 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C));
1037 $date->set(5, Zend_Date::WEEKDAY_8601);
1038 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1039 $date->setTimeZone('UTC');
1040 $date->set(2, Zend_Date::WEEKDAY_8601);
1041 $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date::W3C));
1042 $date->set($d2, Zend_Date::WEEKDAY_8601);
1043 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1044 $date->setTimezone('Indian/Maldives');
1045 $date->set(4, Zend_Date::WEEKDAY_8601, 'en_US');
1046 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1047 $date->set($d2, Zend_Date::WEEKDAY_8601, 'en_US');
1048 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1049 $date->setTimeZone('UTC');
1050 $date->set(3, Zend_Date::WEEKDAY_8601, 'en_US');
1051 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C));
1052 $date->set($d2, Zend_Date::WEEKDAY_8601, 'en_US');
1053 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1054 $date->setTimezone('Indian/Maldives');
1056 $date->set(1234567890);
1057 try {
1058 $date->set($d2, Zend_Date::DAY_SUFFIX);
1059 $this->fail('exception expected');
1060 } catch (Zend_Date_Exception $e) {
1061 // success
1064 $date->set(1234567890);
1065 try {
1066 $date->set(7, Zend_Date::WEEKDAY_DIGIT);
1067 $this->fail();
1068 } catch (Zend_Date_Exception $e) {
1069 // success
1071 try {
1072 $date->set('noday', Zend_Date::WEEKDAY_DIGIT);
1073 $this->fail();
1074 } catch (Zend_Date_Exception $e) {
1075 // success
1077 $date->set($d2, Zend_Date::WEEKDAY_DIGIT);
1078 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1079 $date->set(1, Zend_Date::WEEKDAY_DIGIT);
1080 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C));
1081 $date->set(5, Zend_Date::WEEKDAY_DIGIT);
1082 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1083 $date->setTimeZone('UTC');
1084 $date->set(2, Zend_Date::WEEKDAY_DIGIT);
1085 $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date::W3C));
1086 $date->set($d2, Zend_Date::WEEKDAY_DIGIT);
1087 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1088 $date->setTimezone('Indian/Maldives');
1089 $date->set(4, Zend_Date::WEEKDAY_DIGIT, 'en_US');
1090 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1091 $date->set($d2, Zend_Date::WEEKDAY_DIGIT, 'en_US');
1092 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1093 $date->setTimeZone('UTC');
1094 $date->set(3, Zend_Date::WEEKDAY_DIGIT, 'en_US');
1095 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C));
1096 $date->set($d2, Zend_Date::WEEKDAY_DIGIT, 'en_US');
1097 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1098 $date->setTimezone('Indian/Maldives');
1100 $date->set(1234567890);
1101 try {
1102 $date->set('noday', Zend_Date::DAY_OF_YEAR);
1103 $this->fail();
1104 } catch (Zend_Date_Exception $e) {
1105 // success
1107 $date->set($d2, Zend_Date::DAY_OF_YEAR);
1108 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C));
1109 $date->set( 124, Zend_Date::DAY_OF_YEAR);
1110 $this->assertSame('2009-05-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
1111 $date->set( 524, Zend_Date::DAY_OF_YEAR);
1112 $this->assertSame('2010-06-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
1113 $date->set(-135, Zend_Date::DAY_OF_YEAR);
1114 $this->assertSame('2009-08-18T04:31:30+05:00', $date->get(Zend_Date::W3C));
1115 $date->setTimeZone('UTC');
1116 $date->set( 422, Zend_Date::DAY_OF_YEAR);
1117 $this->assertSame('2010-02-26T23:31:30+00:00', $date->get(Zend_Date::W3C));
1118 $date->set($d2, Zend_Date::DAY_OF_YEAR);
1119 $this->assertSame('2010-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C));
1120 $date->setTimezone('Indian/Maldives');
1121 $date->set( 12, Zend_Date::DAY_OF_YEAR, 'en_US');
1122 $this->assertSame('2010-01-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1123 $date->set($d2, Zend_Date::DAY_OF_YEAR, 'en_US');
1124 $this->assertSame('2010-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C));
1125 $date->setTimeZone('UTC');
1126 $date->set(-253, Zend_Date::DAY_OF_YEAR, 'en_US');
1127 $this->assertSame('2009-04-22T23:31:30+00:00', $date->get(Zend_Date::W3C));
1128 $date->set($d2, Zend_Date::DAY_OF_YEAR, 'en_US');
1129 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C));
1130 $date->setTimezone('Indian/Maldives');
1132 $date->set(1234567890);
1133 try {
1134 $date->set('noday', Zend_Date::WEEKDAY_NARROW);
1135 $this->fail('exception expected');
1136 } catch (Zend_Date_Exception $e) {
1137 // success
1139 $date->set($d2, Zend_Date::WEEKDAY_NARROW);
1140 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1141 $date->set('S', Zend_Date::WEEKDAY_NARROW);
1142 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
1143 $date->set('M', Zend_Date::WEEKDAY_NARROW);
1144 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C));
1145 $date->setTimeZone('UTC');
1146 $date->set('F', Zend_Date::WEEKDAY_NARROW);
1147 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1148 $date->set($d2, Zend_Date::WEEKDAY_NARROW);
1149 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1150 $date->setTimezone('Indian/Maldives');
1151 $date->set('W', Zend_Date::WEEKDAY_NARROW, 'en_US');
1152 $this->assertSame('2009-02-11T04:31:30+05:00', $date->get(Zend_Date::W3C));
1153 $date->set($d2, Zend_Date::WEEKDAY_NARROW, 'en_US');
1154 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1155 $date->setTimeZone('UTC');
1156 $date->set('W', Zend_Date::WEEKDAY_NARROW, 'en_US');
1157 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C));
1158 $date->set($d2, Zend_Date::WEEKDAY_NARROW, 'en_US');
1159 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1160 $date->setTimezone('Indian/Maldives');
1162 $date->set(1234567890);
1163 try {
1164 $date->set('noday', Zend_Date::WEEKDAY_NAME);
1165 $this->fail();
1166 } catch (Zend_Date_Exception $e) {
1167 // success
1169 $date->set($d2, Zend_Date::WEEKDAY_NAME);
1170 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1171 $date->set('So.', Zend_Date::WEEKDAY_NAME);
1172 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
1173 $date->set('Mo.', Zend_Date::WEEKDAY_NAME);
1174 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C));
1175 $date->setTimeZone('UTC');
1176 $date->set('Fr.', Zend_Date::WEEKDAY_NAME);
1177 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1178 $date->set($d2, Zend_Date::WEEKDAY_NAME);
1179 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1180 $date->setTimezone('Indian/Maldives');
1181 $date->set('Thu', Zend_Date::WEEKDAY_NAME, 'en_US');
1182 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1183 $date->set($d2, Zend_Date::WEEKDAY_NAME, 'en_US');
1184 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1185 $date->setTimeZone('UTC');
1186 $date->set('Wed', Zend_Date::WEEKDAY_NAME, 'en_US');
1187 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C));
1188 $date->set($d2, Zend_Date::WEEKDAY_NAME, 'en_US');
1189 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C));
1190 $date->setTimezone('Indian/Maldives');
1192 $date->set(1234567890);
1193 try {
1194 $date->set('noday', Zend_Date::WEEK);
1195 $this->fail();
1196 } catch (Zend_Date_Exception $e) {
1197 // success
1199 $date->set($d2, Zend_Date::WEEK);
1200 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C));
1201 $date->set( 1, Zend_Date::WEEK);
1202 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C));
1203 $date->set( 55, Zend_Date::WEEK);
1204 $this->assertSame('2010-01-16T04:31:30+05:00', $date->get(Zend_Date::W3C));
1205 $date->set(-57, Zend_Date::WEEK);
1206 $this->assertSame('2008-11-29T04:31:30+05:00', $date->get(Zend_Date::W3C));
1207 $date->setTimeZone('UTC');
1208 $date->set( 50, Zend_Date::WEEK);
1209 $this->assertSame('2008-12-12T23:31:30+00:00', $date->get(Zend_Date::W3C));
1210 $date->set($d2, Zend_Date::WEEK);
1211 $this->assertSame('2008-01-05T04:31:30+05:00', $date->get(Zend_Date::W3C));
1212 $date->setTimezone('Indian/Maldives');
1213 $date->set( 10, Zend_Date::WEEK, 'en_US');
1214 $this->assertSame('2008-03-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
1215 $date->set($d2, Zend_Date::WEEK, 'en_US');
1216 $this->assertSame('2008-01-05T04:31:30+05:00', $date->get(Zend_Date::W3C));
1217 $date->setTimeZone('UTC');
1218 $date->set(-25, Zend_Date::WEEK, 'en_US');
1219 $this->assertSame('2007-07-06T23:31:30+00:00', $date->get(Zend_Date::W3C));
1220 $date->set($d2, Zend_Date::WEEK, 'en_US');
1221 $this->assertSame('2007-01-06T04:31:30+05:00', $date->get(Zend_Date::W3C));
1222 $date->setTimezone('Indian/Maldives');
1224 $date->set(1234567890);
1225 try {
1226 $date->set('noday', Zend_Date::MONTH_NAME);
1227 $this->fail('exception expected');
1228 } catch (Zend_Date_Exception $e) {
1229 // success
1231 $date->set($d2, Zend_Date::MONTH_NAME);
1232 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1233 $date->set('März', Zend_Date::MONTH_NAME);
1234 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1235 $date->set('Dezember', Zend_Date::MONTH_NAME);
1236 $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1237 $date->setTimeZone('UTC');
1238 $date->set('August', Zend_Date::MONTH_NAME);
1239 $this->assertSame('2009-08-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1240 $date->set($d2, Zend_Date::MONTH_NAME);
1241 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1242 $date->setTimezone('Indian/Maldives');
1243 $date->set('April', Zend_Date::MONTH_NAME, 'en_US');
1244 $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1245 $date->set($d2, Zend_Date::MONTH_NAME, 'en_US');
1246 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1247 $date->setTimeZone('UTC');
1248 $date->set('July', Zend_Date::MONTH_NAME, 'en_US');
1249 $this->assertSame('2009-07-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1250 $date->set($d2, Zend_Date::MONTH_NAME, 'en_US');
1251 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1252 $date->setTimezone('Indian/Maldives');
1254 $date->set(1234567890);
1255 try {
1256 $date->set('noday', Zend_Date::MONTH);
1257 $this->fail();
1258 } catch (Zend_Date_Exception $e) {
1259 // success
1261 $date->set($d2, Zend_Date::MONTH);
1262 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1263 $date->set('03', Zend_Date::MONTH);
1264 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1265 $date->set( 14, Zend_Date::MONTH);
1266 $this->assertSame('2010-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1267 $date->set(-6, Zend_Date::MONTH);
1268 $this->assertSame('2009-06-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1269 $date->setTimeZone('UTC');
1270 $date->set( 10, Zend_Date::MONTH);
1271 $this->assertSame('2009-10-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1272 $date->set($d2, Zend_Date::MONTH);
1273 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1274 $date->setTimezone('Indian/Maldives');
1275 $date->set( 9, Zend_Date::MONTH, 'en_US');
1276 $this->assertSame('2009-09-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1277 $date->set($d2, Zend_Date::MONTH, 'en_US');
1278 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1279 $date->setTimeZone('UTC');
1280 $date->set(-20, Zend_Date::MONTH, 'en_US');
1281 $this->assertSame('2007-04-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1282 $date->set($d2, Zend_Date::MONTH, 'en_US');
1283 $this->assertSame('2007-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1284 $date->setTimezone('Indian/Maldives');
1286 $date->set(1234567890);
1287 try {
1288 $date->set('noday', Zend_Date::MONTH_NAME_SHORT);
1289 $this->fail('exception expected');
1290 } catch (Zend_Date_Exception $e) {
1291 // success
1293 $date->set($d2, Zend_Date::MONTH_NAME_SHORT);
1294 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1295 $date->set('Mär', Zend_Date::MONTH_NAME_SHORT);
1296 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1297 $date->set('Dez', Zend_Date::MONTH_NAME_SHORT);
1298 $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1299 $date->setTimeZone('UTC');
1300 $date->set('Aug', Zend_Date::MONTH_NAME_SHORT);
1301 $this->assertSame('2009-08-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1302 $date->set($d2, Zend_Date::MONTH_NAME_SHORT);
1303 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1304 $date->setTimezone('Indian/Maldives');
1305 $date->set('Apr', Zend_Date::MONTH_NAME_SHORT, 'en_US');
1306 $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1307 $date->set($d2, Zend_Date::MONTH_NAME_SHORT, 'en_US');
1308 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1309 $date->setTimeZone('UTC');
1310 $date->set('Jul', Zend_Date::MONTH_NAME_SHORT, 'en_US');
1311 $this->assertSame('2009-07-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1312 $date->set($d2, Zend_Date::MONTH_NAME_SHORT, 'en_US');
1313 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1314 $date->setTimezone('Indian/Maldives');
1316 $date->set(1234567890);
1317 try {
1318 $date->set('noday', Zend_Date::MONTH_SHORT);
1319 $this->fail();
1320 } catch (Zend_Date_Exception $e) {
1321 // success
1323 $date->set($d2, Zend_Date::MONTH_SHORT);
1324 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1325 $date->set( 3, Zend_Date::MONTH_SHORT);
1326 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1327 $date->set( 14, Zend_Date::MONTH_SHORT);
1328 $this->assertSame('2010-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1329 $date->set(-6, Zend_Date::MONTH_SHORT);
1330 $this->assertSame('2009-06-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1331 $date->setTimeZone('UTC');
1332 $date->set( 10, Zend_Date::MONTH_SHORT);
1333 $this->assertSame('2009-10-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1334 $date->set($d2, Zend_Date::MONTH_SHORT);
1335 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1336 $date->setTimezone('Indian/Maldives');
1337 $date->set( 9, Zend_Date::MONTH_SHORT, 'en_US');
1338 $this->assertSame('2009-09-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1339 $date->set($d2, Zend_Date::MONTH_SHORT, 'en_US');
1340 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1341 $date->setTimeZone('UTC');
1342 $date->set(-20, Zend_Date::MONTH_SHORT, 'en_US');
1343 $this->assertSame('2007-04-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1344 $date->set($d2, Zend_Date::MONTH_SHORT, 'en_US');
1345 $this->assertSame('2007-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1346 $date->setTimezone('Indian/Maldives');
1348 $date->set(1234567890);
1349 try {
1350 $date->set($d2, Zend_Date::MONTH_DAYS);
1351 $this->fail('exception expected');
1352 } catch (Zend_Date_Exception $e) {
1353 // success
1356 $date->set(1234567890);
1357 try {
1358 $date->set('xxday', Zend_Date::MONTH_NAME_NARROW);
1359 $this->fail('exception expected');
1360 } catch (Zend_Date_Exception $e) {
1361 // success
1363 $date->set($d2, Zend_Date::MONTH_NAME_NARROW);
1364 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1365 $date->set('M', Zend_Date::MONTH_NAME_NARROW);
1366 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1367 $date->set('D', Zend_Date::MONTH_NAME_NARROW);
1368 $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1369 $date->setTimeZone('UTC');
1370 $date->set('A', Zend_Date::MONTH_NAME_NARROW);
1371 $this->assertSame('2009-04-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1372 $date->set($d2, Zend_Date::MONTH_NAME_NARROW);
1373 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1374 $date->setTimezone('Indian/Maldives');
1375 $date->set('A', Zend_Date::MONTH_NAME_NARROW, 'en_US');
1376 $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1377 $date->set($d2, Zend_Date::MONTH_NAME_NARROW, 'en_US');
1378 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1379 $date->setTimeZone('UTC');
1380 $date->set('J', Zend_Date::MONTH_NAME_NARROW, 'en_US');
1381 $this->assertSame('2009-01-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1382 $date->set($d2, Zend_Date::MONTH_NAME_NARROW, 'en_US');
1383 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1384 $date->setTimezone('Indian/Maldives');
1386 $date->set(1234567890);
1387 try {
1388 $date->set($d2, Zend_Date::LEAPYEAR);
1389 $this->fail('exception expected');
1390 } catch (Zend_Date_Exception $e) {
1391 // success
1394 $date->set(1234567890);
1395 try {
1396 $date->set('noday', Zend_Date::YEAR_8601);
1397 $this->fail();
1398 } catch (Zend_Date_Exception $e) {
1399 // success
1401 $date->set($d2, Zend_Date::YEAR_8601);
1402 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1403 $date->set(1970, Zend_Date::YEAR_8601);
1404 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1405 $date->set(2020, Zend_Date::YEAR_8601);
1406 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1407 $date->set(2040, Zend_Date::YEAR_8601);
1408 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1409 $date->setTimeZone('UTC');
1410 $date->set(1900, Zend_Date::YEAR_8601);
1411 $this->assertSame('1900-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1412 $date->set($d2, Zend_Date::YEAR_8601);
1413 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1414 $date->setTimezone('Indian/Maldives');
1415 $date->set(2500, Zend_Date::YEAR_8601, 'en_US');
1416 $this->assertSame('2500-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1417 $date->set($d2, Zend_Date::YEAR_8601, 'en_US');
1418 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1419 $date->setTimeZone('UTC');
1420 $date->set(-20, Zend_Date::YEAR_8601, 'en_US');
1421 $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C));
1422 $date->set($d2, Zend_Date::YEAR_8601, 'en_US');
1423 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1424 $date->setTimezone('Indian/Maldives');
1426 $date->set(1234567890);
1427 try {
1428 $date->set('noday', Zend_Date::YEAR);
1429 $this->fail();
1430 } catch (Zend_Date_Exception $e) {
1431 // success
1433 $date->set($d2, Zend_Date::YEAR);
1434 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1435 $date->set(1970, Zend_Date::YEAR);
1436 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1437 $date->set(2020, Zend_Date::YEAR);
1438 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1439 $date->set(2040, Zend_Date::YEAR);
1440 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1441 $date->setTimeZone('UTC');
1442 $date->set(1900, Zend_Date::YEAR);
1443 $this->assertSame('1900-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1444 $date->set($d2, Zend_Date::YEAR);
1445 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1446 $date->setTimezone('Indian/Maldives');
1447 $date->set(2500, Zend_Date::YEAR, 'en_US');
1448 $this->assertSame('2500-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1449 $date->set($d2, Zend_Date::YEAR, 'en_US');
1450 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1451 $date->setTimeZone('UTC');
1452 $date->set(-20, Zend_Date::YEAR, 'en_US');
1453 $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C));
1454 $date->set($d2, Zend_Date::YEAR, 'en_US');
1455 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1456 $date->setTimezone('Indian/Maldives');
1458 $date->set(1234567890);
1459 try {
1460 $date->set('noday', Zend_Date::YEAR_SHORT);
1461 $this->fail();
1462 } catch (Zend_Date_Exception $e) {
1463 // success
1465 $date->set($d2, Zend_Date::YEAR_SHORT);
1466 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1467 $date->set(70, Zend_Date::YEAR_SHORT);
1468 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1469 $date->set(20, Zend_Date::YEAR_SHORT);
1470 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1471 $date->set(40, Zend_Date::YEAR_SHORT);
1472 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1473 $date->setTimeZone('UTC');
1474 $date->set(0, Zend_Date::YEAR_SHORT);
1475 $this->assertSame('2000-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1476 $date->set($d2, Zend_Date::YEAR_SHORT);
1477 $date->setTimezone('Indian/Maldives');
1478 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1479 $date->set(30, Zend_Date::YEAR_SHORT, 'en_US');
1480 $this->assertSame('2030-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1481 $date->set($d2, Zend_Date::YEAR_SHORT, 'en_US');
1482 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1483 $date->setTimeZone('UTC');
1484 $date->set(-20, Zend_Date::YEAR_SHORT, 'en_US');
1485 $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C));
1486 $date->set($d2, Zend_Date::YEAR_SHORT, 'en_US');
1487 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1488 $date->setTimezone('Indian/Maldives');
1490 $date->set(1234567890);
1491 try {
1492 $date->set('noday', Zend_Date::YEAR_SHORT_8601);
1493 $this->fail();
1494 } catch (Zend_Date_Exception $e) {
1495 // success
1497 $date->set($d2, Zend_Date::YEAR_SHORT_8601);
1498 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1499 $date->set(70, Zend_Date::YEAR_SHORT_8601);
1500 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1501 $date->set(20, Zend_Date::YEAR_SHORT_8601);
1502 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1503 $date->set(40, Zend_Date::YEAR_SHORT_8601);
1504 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1505 $date->setTimeZone('UTC');
1506 $date->set(0, Zend_Date::YEAR_SHORT_8601);
1507 $this->assertSame('2000-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1508 $date->set($d2, Zend_Date::YEAR_SHORT_8601);
1509 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1510 $date->setTimezone('Indian/Maldives');
1511 $date->set(30, Zend_Date::YEAR_SHORT_8601, 'en_US');
1512 $this->assertSame('2030-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1513 $date->set($d2, Zend_Date::YEAR_SHORT_8601, 'en_US');
1514 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1515 $date->setTimeZone('UTC');
1516 $date->set(-20, Zend_Date::YEAR_SHORT_8601, 'en_US');
1517 $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C));
1518 $date->set($d2, Zend_Date::YEAR_SHORT_8601, 'en_US');
1519 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1520 $date->setTimezone('Indian/Maldives');
1522 $date->set(1234567890);
1523 try {
1524 $date->set('noday', Zend_Date::MERIDIEM);
1525 $this->fail();
1526 } catch (Zend_Date_Exception $e) {
1527 // success
1530 $date->set(1234567890);
1531 try {
1532 $date->set('noday', Zend_Date::SWATCH);
1533 $this->fail();
1534 } catch (Zend_Date_Exception $e) {
1535 // success
1537 $date->set($d2, Zend_Date::SWATCH);
1538 $this->assertSame('2009-02-14T00:36:00+05:00', $date->get(Zend_Date::W3C));
1539 $date->set(0, Zend_Date::SWATCH);
1540 $this->assertSame('2009-02-14T00:00:00+05:00', $date->get(Zend_Date::W3C));
1541 $date->set(600, Zend_Date::SWATCH);
1542 $this->assertSame('2009-02-14T14:23:59+05:00', $date->get(Zend_Date::W3C));
1543 $date->set(1700, Zend_Date::SWATCH);
1544 $this->assertSame('2009-02-15T16:47:59+05:00', $date->get(Zend_Date::W3C));
1545 $date->setTimeZone('UTC');
1546 $date->set(1900, Zend_Date::SWATCH);
1547 $this->assertSame('2009-02-16T21:36:00+00:00', $date->get(Zend_Date::W3C));
1548 $date->set($d2, Zend_Date::SWATCH);
1549 $this->assertSame('2009-02-17T00:36:00+05:00', $date->get(Zend_Date::W3C));
1550 $date->setTimezone('Indian/Maldives');
1551 $date->set(3700, Zend_Date::SWATCH, 'en_US');
1552 $this->assertSame('2009-02-20T16:48:00+05:00', $date->get(Zend_Date::W3C));
1553 $date->set($d2, Zend_Date::SWATCH, 'en_US');
1554 $this->assertSame('2009-02-20T00:36:00+05:00', $date->get(Zend_Date::W3C));
1555 $date->setTimeZone('UTC');
1556 $date->set(-200, Zend_Date::SWATCH, 'en_US');
1557 $this->assertSame('2009-02-18T19:12:00+00:00', $date->get(Zend_Date::W3C));
1558 $date->set($d2, Zend_Date::SWATCH, 'en_US');
1559 $this->assertSame('2009-02-19T00:36:00+05:00', $date->get(Zend_Date::W3C));
1560 $date->setTimezone('Indian/Maldives');
1562 $date->set(1234567890);
1563 try {
1564 $date->set('noday', Zend_Date::HOUR_SHORT_AM);
1565 $this->fail();
1566 } catch (Zend_Date_Exception $e) {
1567 // success
1569 $date->set($d2, Zend_Date::HOUR_SHORT_AM);
1570 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1571 $date->set( 3, Zend_Date::HOUR_SHORT_AM);
1572 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C));
1573 $date->set( 14, Zend_Date::HOUR_SHORT_AM);
1574 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C));
1575 $date->set(-6, Zend_Date::HOUR_SHORT_AM);
1576 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C));
1577 $date->setTimeZone('UTC');
1578 $date->set( 30, Zend_Date::HOUR_SHORT_AM);
1579 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C));
1580 $date->set($d2, Zend_Date::HOUR_SHORT_AM);
1581 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1582 $date->setTimezone('Indian/Maldives');
1583 $date->set( 9, Zend_Date::HOUR_SHORT_AM, 'en_US');
1584 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C));
1585 $date->set($d2, Zend_Date::HOUR_SHORT_AM, 'en_US');
1586 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1587 $date->setTimeZone('UTC');
1588 $date->set(-26, Zend_Date::HOUR_SHORT_AM, 'en_US');
1589 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C));
1590 $date->set($d2, Zend_Date::HOUR_SHORT_AM, 'en_US');
1591 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1592 $date->setTimezone('Indian/Maldives');
1594 $date->set(1234567890);
1595 try {
1596 $date->set('noday', Zend_Date::HOUR_SHORT);
1597 $this->fail();
1598 } catch (Zend_Date_Exception $e) {
1599 // success
1601 $date->set($d2, Zend_Date::HOUR_SHORT);
1602 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1603 $date->set( 3, Zend_Date::HOUR_SHORT);
1604 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C));
1605 $date->set( 14, Zend_Date::HOUR_SHORT);
1606 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C));
1607 $date->set(-6, Zend_Date::HOUR_SHORT);
1608 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C));
1609 $date->setTimeZone('UTC');
1610 $date->set( 30, Zend_Date::HOUR_SHORT);
1611 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C));
1612 $date->set($d2, Zend_Date::HOUR_SHORT);
1613 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1614 $date->setTimezone('Indian/Maldives');
1615 $date->set( 9, Zend_Date::HOUR_SHORT, 'en_US');
1616 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C));
1617 $date->set($d2, Zend_Date::HOUR_SHORT, 'en_US');
1618 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1619 $date->setTimeZone('UTC');
1620 $date->set(-26, Zend_Date::HOUR_SHORT, 'en_US');
1621 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C));
1622 $date->set($d2, Zend_Date::HOUR_SHORT, 'en_US');
1623 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1624 $date->setTimezone('Indian/Maldives');
1626 $date->set(1234567890);
1627 try {
1628 $date->set('noday', Zend_Date::HOUR_AM);
1629 $this->fail();
1630 } catch (Zend_Date_Exception $e) {
1631 // success
1633 $date->set($d2, Zend_Date::HOUR_AM);
1634 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1635 $date->set( 3, Zend_Date::HOUR_AM);
1636 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C));
1637 $date->set( 14, Zend_Date::HOUR_AM);
1638 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C));
1639 $date->set(-6, Zend_Date::HOUR_AM);
1640 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C));
1641 $date->setTimeZone('UTC');
1642 $date->set( 30, Zend_Date::HOUR_AM);
1643 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C));
1644 $date->set($d2, Zend_Date::HOUR_AM);
1645 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1646 $date->setTimezone('Indian/Maldives');
1647 $date->set( 9, Zend_Date::HOUR_AM, 'en_US');
1648 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C));
1649 $date->set($d2, Zend_Date::HOUR_AM, 'en_US');
1650 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1651 $date->setTimeZone('UTC');
1652 $date->set(-26, Zend_Date::HOUR_AM, 'en_US');
1653 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C));
1654 $date->set($d2, Zend_Date::HOUR_AM, 'en_US');
1655 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1656 $date->setTimezone('Indian/Maldives');
1658 $date->set(1234567890);
1659 try {
1660 $date->set('noday', Zend_Date::HOUR);
1661 $this->fail();
1662 } catch (Zend_Date_Exception $e) {
1663 // success
1665 $date->set($d2, Zend_Date::HOUR);
1666 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1667 $date->set( 3, Zend_Date::HOUR);
1668 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C));
1669 $date->set( 14, Zend_Date::HOUR);
1670 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C));
1671 $date->set(-6, Zend_Date::HOUR);
1672 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C));
1673 $date->setTimeZone('UTC');
1674 $date->set( 30, Zend_Date::HOUR);
1675 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C));
1676 $date->set($d2, Zend_Date::HOUR);
1677 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1678 $date->setTimezone('Indian/Maldives');
1679 $date->set( 9, Zend_Date::HOUR, 'en_US');
1680 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C));
1681 $date->set($d2, Zend_Date::HOUR, 'en_US');
1682 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
1683 $date->setTimeZone('UTC');
1684 $date->set(-26, Zend_Date::HOUR, 'en_US');
1685 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C));
1686 $date->set($d2, Zend_Date::HOUR, 'en_US');
1687 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C));
1688 $date->setTimezone('Indian/Maldives');
1690 $date->set(1234567890);
1691 try {
1692 $date->set('noday', Zend_Date::MINUTE);
1693 $this->fail();
1694 } catch (Zend_Date_Exception $e) {
1695 // success
1697 $date->set($d2, Zend_Date::MINUTE);
1698 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C));
1699 $date->set( 3, Zend_Date::MINUTE);
1700 $this->assertSame('2009-02-14T04:03:30+05:00', $date->get(Zend_Date::W3C));
1701 $date->set( 65, Zend_Date::MINUTE);
1702 $this->assertSame('2009-02-14T05:05:30+05:00', $date->get(Zend_Date::W3C));
1703 $date->set(-6, Zend_Date::MINUTE);
1704 $this->assertSame('2009-02-14T04:54:30+05:00', $date->get(Zend_Date::W3C));
1705 $date->setTimeZone('UTC');
1706 $date->set( 30, Zend_Date::MINUTE);
1707 $this->assertSame('2009-02-13T23:30:30+00:00', $date->get(Zend_Date::W3C));
1708 $date->set($d2, Zend_Date::MINUTE);
1709 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C));
1710 $date->setTimezone('Indian/Maldives');
1711 $date->set( 9, Zend_Date::MINUTE, 'en_US');
1712 $this->assertSame('2009-02-14T04:09:30+05:00', $date->get(Zend_Date::W3C));
1713 $date->set($d2, Zend_Date::MINUTE, 'en_US');
1714 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C));
1715 $date->setTimeZone('UTC');
1716 $date->set(-65, Zend_Date::MINUTE, 'en_US');
1717 $this->assertSame('2009-02-13T21:55:30+00:00', $date->get(Zend_Date::W3C));
1718 $date->set($d2, Zend_Date::MINUTE, 'en_US');
1719 $this->assertSame('2009-02-14T02:36:30+05:00', $date->get(Zend_Date::W3C));
1720 $date->setTimezone('Indian/Maldives');
1722 $date->set(1234567890);
1723 try {
1724 $date->set('noday', Zend_Date::MINUTE_SHORT);
1725 $this->fail();
1726 } catch (Zend_Date_Exception $e) {
1727 // success
1729 $date->set($d2, Zend_Date::MINUTE_SHORT);
1730 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C));
1731 $date->set( 3, Zend_Date::MINUTE_SHORT);
1732 $this->assertSame('2009-02-14T04:03:30+05:00', $date->get(Zend_Date::W3C));
1733 $date->set( 65, Zend_Date::MINUTE_SHORT);
1734 $this->assertSame('2009-02-14T05:05:30+05:00', $date->get(Zend_Date::W3C));
1735 $date->set(-6, Zend_Date::MINUTE_SHORT);
1736 $this->assertSame('2009-02-14T04:54:30+05:00', $date->get(Zend_Date::W3C));
1737 $date->setTimeZone('UTC');
1738 $date->set( 30, Zend_Date::MINUTE_SHORT);
1739 $this->assertSame('2009-02-13T23:30:30+00:00', $date->get(Zend_Date::W3C));
1740 $date->set($d2, Zend_Date::MINUTE_SHORT);
1741 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C));
1742 $date->setTimezone('Indian/Maldives');
1743 $date->set( 9, Zend_Date::MINUTE_SHORT, 'en_US');
1744 $this->assertSame('2009-02-14T04:09:30+05:00', $date->get(Zend_Date::W3C));
1745 $date->set($d2, Zend_Date::MINUTE_SHORT, 'en_US');
1746 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C));
1747 $date->setTimeZone('UTC');
1748 $date->set(-65, Zend_Date::MINUTE_SHORT, 'en_US');
1749 $this->assertSame('2009-02-13T21:55:30+00:00', $date->get(Zend_Date::W3C));
1750 $date->set($d2, Zend_Date::MINUTE_SHORT, 'en_US');
1751 $this->assertSame('2009-02-14T02:36:30+05:00', $date->get(Zend_Date::W3C));
1752 $date->setTimezone('Indian/Maldives');
1754 $date->set(1234567890);
1755 try {
1756 $date->set('noday', Zend_Date::SECOND);
1757 $this->fail();
1758 } catch (Zend_Date_Exception $e) {
1759 // success
1761 $date->set($d2, Zend_Date::SECOND);
1762 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C));
1763 $date->set( 3, Zend_Date::SECOND);
1764 $this->assertSame('2009-02-14T04:31:03+05:00', $date->get(Zend_Date::W3C));
1765 $date->set( 65, Zend_Date::SECOND);
1766 $this->assertSame('2009-02-14T04:32:05+05:00', $date->get(Zend_Date::W3C));
1767 $date->set(-6, Zend_Date::SECOND);
1768 $this->assertSame('2009-02-14T04:31:54+05:00', $date->get(Zend_Date::W3C));
1769 $date->setTimeZone('UTC');
1770 $date->set( 30, Zend_Date::SECOND);
1771 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1772 $date->set($d2, Zend_Date::SECOND);
1773 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C));
1774 $date->setTimezone('Indian/Maldives');
1775 $date->set( 9, Zend_Date::SECOND, 'en_US');
1776 $this->assertSame('2009-02-14T04:31:09+05:00', $date->get(Zend_Date::W3C));
1777 $date->set($d2, Zend_Date::SECOND, 'en_US');
1778 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C));
1779 $date->setTimeZone('UTC');
1780 $date->set(-65, Zend_Date::SECOND, 'en_US');
1781 $this->assertSame('2009-02-13T23:29:55+00:00', $date->get(Zend_Date::W3C));
1782 $date->set($d2, Zend_Date::SECOND, 'en_US');
1783 $this->assertSame('2009-02-14T04:29:50+05:00', $date->get(Zend_Date::W3C));
1784 $date->setTimezone('Indian/Maldives');
1786 $date->set(1234567890);
1787 try {
1788 $date->set('noday', Zend_Date::SECOND_SHORT);
1789 $this->fail();
1790 } catch (Zend_Date_Exception $e) {
1791 // success
1793 $date->set($d2, Zend_Date::SECOND_SHORT);
1794 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C));
1795 $date->set( 3, Zend_Date::SECOND_SHORT);
1796 $this->assertSame('2009-02-14T04:31:03+05:00', $date->get(Zend_Date::W3C));
1797 $date->set( 65, Zend_Date::SECOND_SHORT);
1798 $this->assertSame('2009-02-14T04:32:05+05:00', $date->get(Zend_Date::W3C));
1799 $date->set(-6, Zend_Date::SECOND_SHORT);
1800 $this->assertSame('2009-02-14T04:31:54+05:00', $date->get(Zend_Date::W3C));
1801 $date->setTimeZone('UTC');
1802 $date->set( 30, Zend_Date::SECOND_SHORT);
1803 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C));
1804 $date->set($d2, Zend_Date::SECOND_SHORT);
1805 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C));
1806 $date->setTimezone('Indian/Maldives');
1807 $date->set( 9, Zend_Date::SECOND_SHORT, 'en_US');
1808 $this->assertSame('2009-02-14T04:31:09+05:00', $date->get(Zend_Date::W3C));
1809 $date->set($d2, Zend_Date::SECOND_SHORT, 'en_US');
1810 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C));
1811 $date->setTimeZone('UTC');
1812 $date->set(-65, Zend_Date::SECOND_SHORT, 'en_US');
1813 $this->assertSame('2009-02-13T23:29:55+00:00', $date->get(Zend_Date::W3C));
1814 $date->set($d2, Zend_Date::SECOND_SHORT, 'en_US');
1815 $this->assertSame('2009-02-14T04:29:50+05:00', $date->get(Zend_Date::W3C));
1816 $date->setTimezone('Indian/Maldives');
1818 $date->set(1234567890);
1819 try {
1820 $date->set('noday', Zend_Date::MILLISECOND);
1821 $this->fail();
1822 } catch (Zend_Date_Exception $e) {
1823 // success
1825 $date->set($d2, Zend_Date::MILLISECOND);
1826 $this->assertSame('0', $date->get(Zend_Date::MILLISECOND));
1827 $date->set( 3, Zend_Date::MILLISECOND);
1828 $this->assertSame('3', $date->get(Zend_Date::MILLISECOND));
1829 $date->set( 1065, Zend_Date::MILLISECOND);
1830 $this->assertSame('65', $date->get(Zend_Date::MILLISECOND));
1831 $date->set(-6, Zend_Date::MILLISECOND);
1832 $this->assertSame('994', $date->get(Zend_Date::MILLISECOND));
1833 $date->set( 30, Zend_Date::MILLISECOND, true);
1834 $this->assertSame('30', $date->get(Zend_Date::MILLISECOND));
1835 $date->set($d2, Zend_Date::MILLISECOND, true);
1836 $this->assertSame('0', $date->get(Zend_Date::MILLISECOND));
1837 $date->set( 9, Zend_Date::MILLISECOND, false, 'en_US');
1838 $this->assertSame('9', $date->get(Zend_Date::MILLISECOND));
1839 $date->set($d2, Zend_Date::MILLISECOND, false, 'en_US');
1840 $this->assertSame('0', $date->get(Zend_Date::MILLISECOND));
1841 $date->set(-65, Zend_Date::MILLISECOND, true , 'en_US');
1842 $this->assertSame('935', $date->get(Zend_Date::MILLISECOND));
1843 $date->set($d2, Zend_Date::MILLISECOND, true , 'en_US');
1844 $this->assertSame('0', $date->get(Zend_Date::MILLISECOND));
1846 $date->set(1234567890);
1847 try {
1848 $date->set('noday', Zend_Date::TIMEZONE_NAME);
1849 $this->fail();
1850 } catch (Zend_Date_Exception $e) {
1851 // success
1854 $date->set(1234567890);
1855 try {
1856 $date->set('noday', Zend_Date::DAYLIGHT);
1857 $this->fail();
1858 } catch (Zend_Date_Exception $e) {
1859 // success
1862 $date->set(1234567890);
1863 try {
1864 $date->set('noday', Zend_Date::GMT_DIFF);
1865 $this->fail();
1866 } catch (Zend_Date_Exception $e) {
1867 // success
1870 $date->set(1234567890);
1871 try {
1872 $date->set('noday', Zend_Date::GMT_DIFF_SEP);
1873 $this->fail();
1874 } catch (Zend_Date_Exception $e) {
1875 // success
1878 $date->set(1234567890);
1879 try {
1880 $date->set('noday', Zend_Date::TIMEZONE);
1881 $this->fail();
1882 } catch (Zend_Date_Exception $e) {
1883 // success
1886 $date->set(1234567890);
1887 try {
1888 $date->set('noday', Zend_Date::TIMEZONE_SECS);
1889 $this->fail();
1890 } catch (Zend_Date_Exception $e) {
1891 // success
1894 $date->set(1234567890);
1895 try {
1896 $date->set('noday', Zend_Date::ISO_8601);
1897 $this->fail();
1898 } catch (Zend_Date_Exception $e) {
1899 // success
1901 $date->set($d2, Zend_Date::ISO_8601);
1902 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
1903 $date->set(1234567890);
1904 $date->set('2007-10-20 20:10:30', Zend_Date::ISO_8601);
1905 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1906 $date->set(1234567890);
1907 $date->set('2007-10-20 201030', Zend_Date::ISO_8601);
1908 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1909 $date->set(1234567890);
1910 $date->set('07-10-20 20:10:30', Zend_Date::ISO_8601);
1911 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1912 $date->set(1234567890);
1913 $date->set('80-10-20 20:10:30', Zend_Date::ISO_8601);
1914 $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1915 $date->set(1234567890);
1916 $date->set('-2007-10-20 20:10:30', Zend_Date::ISO_8601);
1917 $this->assertSame('-2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1918 $date->set(1234567890);
1919 $date->set('-07-10-20 20:10:30', Zend_Date::ISO_8601);
1920 $this->assertSame('-7-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1921 $date->set(1234567890);
1922 $date->set('2007-10-20T20:10:30', Zend_Date::ISO_8601);
1923 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1924 $date->set(1234567890);
1925 $date->set('2007-10-20T201030', Zend_Date::ISO_8601);
1926 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1927 $date->set(1234567890);
1928 $date->set('20-10-20T20:10:30', Zend_Date::ISO_8601);
1929 $this->assertSame('2020-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1930 $date->set(1234567890);
1931 $date->set('80-10-20T20:10:30', Zend_Date::ISO_8601);
1932 $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1933 $date->set(1234567890);
1934 $date->set('-2007-10-20T20:10:30', Zend_Date::ISO_8601);
1935 $this->assertSame('-2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1936 $date->set(1234567890);
1937 $date->set('-07-10-20T20:10:30', Zend_Date::ISO_8601);
1938 $this->assertSame('-7-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1939 $date->set(1234567890);
1940 $date->set('20071020 20:10:30', Zend_Date::ISO_8601);
1941 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1942 $date->set(1234567890);
1943 $date->set('201020 20:10:30', Zend_Date::ISO_8601);
1944 $this->assertSame('2020-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1945 $date->set(1234567890);
1946 $date->set('801020 20:10:30', Zend_Date::ISO_8601);
1947 $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1948 $date->set(1234567890);
1949 $date->set('-071020 20:10:30', Zend_Date::ISO_8601);
1950 $this->assertSame('-7-10-20T20:10:30-07:00', $date->get(Zend_Date::W3C));
1951 $date->set(1234567890);
1952 $date->set('-00071020 20:10:30', Zend_Date::ISO_8601);
1953 $this->assertSame('-7-10-20T20:10:30+00:00', $date->get(Zend_Date::W3C));
1954 $date->setTimezone('Indian/Maldives');
1955 $date->set(1234567890);
1956 $date->set('20071020T20:10:30', Zend_Date::ISO_8601);
1957 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C));
1958 $date->set(1234567890);
1959 $date->set('-00071020T20:10:30', Zend_Date::ISO_8601);
1960 $this->assertSame('-7-10-20T20:10:30+00:00', $date->get(Zend_Date::W3C));
1961 $date->setTimezone('Indian/Maldives');
1962 $date->set(1234567890);
1963 $date->set('2007-10-20', Zend_Date::ISO_8601);
1964 $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date::W3C));
1965 $date->set(1234567890);
1966 $date->set('20071020', Zend_Date::ISO_8601);
1967 $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date::W3C));
1968 $date->set(1234567890);
1969 $date->set('20071020122030', Zend_Date::ISO_8601);
1970 $this->assertSame('2007-10-20T12:20:30+05:00', $date->get(Zend_Date::W3C));
1971 $date->set(1234567890);
1972 $date->set('071020', Zend_Date::ISO_8601);
1973 $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date::W3C));
1974 $date->set(1234567890);
1975 $date->set('07:10:20', Zend_Date::ISO_8601);
1976 $this->assertSame('1970-01-01T07:10:20+05:00', $date->get(Zend_Date::W3C));
1978 $date->set(1234567890);
1979 try {
1980 $date->set('noday', Zend_Date::RFC_2822);
1981 $this->fail();
1982 } catch (Zend_Date_Exception $e) {
1983 // success
1985 $date->set($d2, Zend_Date::RFC_2822);
1986 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
1987 $date->set(1234567890);
1988 $date->set('Thu, 05 Jan 2009 01:31:30 +0500', Zend_Date::RFC_2822);
1989 $this->assertSame('2009-01-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
1990 $date->set(1234567890);
1991 $date->set('Thu, 05 Feb 2009 01:31:30 +0500', Zend_Date::RFC_2822);
1992 $this->assertSame('2009-02-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
1993 $date->set(1234567890);
1994 $date->set('Thu, 05 Mar 2009 01:31:30 +0500', Zend_Date::RFC_2822);
1995 $this->assertSame('2009-03-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
1996 $date->set(1234567890);
1997 $date->set('Thu, 05 Apr 2009 01:31:30 +0500', Zend_Date::RFC_2822);
1998 $this->assertSame('2009-04-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
1999 $date->set(1234567890);
2000 $date->set('Thu, 05 May 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2001 $this->assertSame('2009-05-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2002 $date->set(1234567890);
2003 $date->set('Thu, 05 Jun 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2004 $this->assertSame('2009-06-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2005 $date->set(1234567890);
2006 $date->set('Thu, 05 Jul 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2007 $this->assertSame('2009-07-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2008 $date->set(1234567890);
2009 $date->set('Thu, 05 Aug 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2010 $this->assertSame('2009-08-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2011 $date->set(1234567890);
2012 $date->set('Thu, 05 Sep 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2013 $this->assertSame('2009-09-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2014 $date->set(1234567890);
2015 $date->set('Thu, 05 Oct 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2016 $this->assertSame('2009-10-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2017 $date->set(1234567890);
2018 $date->set('Thu, 05 Nov 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2019 $this->assertSame('2009-11-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2020 $date->set(1234567890);
2021 $date->set('Thu, 05 Dec 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2022 $this->assertSame('2009-12-05T01:31:30+05:00', $date->get(Zend_Date::W3C));
2023 $date->set(1234567890);
2024 try {
2025 $date->set('Thu, 05 Fxx 2009 01:31:30 +0500', Zend_Date::RFC_2822);
2026 $this->fail();
2027 } catch (Zend_Date_Exception $e) {
2028 // success
2031 $date->set(1234567890);
2032 try {
2033 $date->set('noday', Zend_Date::TIMESTAMP);
2034 $this->fail();
2035 } catch (Zend_Date_Exception $e) {
2036 // success
2038 $date->set($d2, Zend_Date::TIMESTAMP);
2039 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2040 $date->set(1234567890);
2041 $date->set('1010101099', Zend_Date::TIMESTAMP);
2042 $this->assertSame('2002-01-04T04:38:19+05:00', $date->get(Zend_Date::W3C));
2044 $date->set(1234567890);
2045 try {
2046 $date->set('noday', Zend_Date::ERA);
2047 $this->fail();
2048 } catch (Zend_Date_Exception $e) {
2049 // success
2052 $date->set(1234567890);
2053 try {
2054 $date->set('noday', Zend_Date::ERA_NAME);
2055 $this->fail();
2056 } catch (Zend_Date_Exception $e) {
2057 // success
2060 $date->set(1234567890);
2061 try {
2062 $date->set('noday', Zend_Date::DATES);
2063 $this->fail();
2064 } catch (Zend_Date_Exception $e) {
2065 // success
2067 $date->set($d2, Zend_Date::DATES);
2068 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
2069 $date->set(1234567890);
2070 $date->set('14.02.2009', Zend_Date::DATES);
2071 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
2073 $date->set(1234567890);
2074 try {
2075 $date->set('noday', Zend_Date::DATE_FULL);
2076 $this->fail();
2077 } catch (Zend_Date_Exception $e) {
2078 // success
2080 $date->set($d2, Zend_Date::DATE_FULL);
2081 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
2082 $date->set(1234567890);
2083 $date->set('Samstag, 14. Februar 2009', Zend_Date::DATE_FULL);
2084 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
2086 $date->set(1234567890);
2087 try {
2088 $date->set('noday', Zend_Date::DATE_LONG);
2089 $this->fail();
2090 } catch (Zend_Date_Exception $e) {
2091 // success
2093 $date->set($d2, Zend_Date::DATE_LONG);
2094 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
2095 $date->set(1234567890);
2096 $date->set('14. Februar 2009', Zend_Date::DATE_LONG);
2097 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
2099 $date->set(1234567890);
2100 try {
2101 $date->set('noday', Zend_Date::DATE_MEDIUM);
2102 $this->fail();
2103 } catch (Zend_Date_Exception $e) {
2104 // success
2106 $date->set($d2, Zend_Date::DATE_MEDIUM);
2107 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
2108 $date->set(1234567890);
2109 $date->set('14.02.2009', Zend_Date::DATE_MEDIUM);
2110 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
2112 $date->set(1234567890);
2113 try {
2114 $date->set('noday', Zend_Date::DATE_SHORT);
2115 $this->fail();
2116 } catch (Zend_Date_Exception $e) {
2117 // success
2119 $date->set($d2, Zend_Date::DATE_SHORT);
2120 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C));
2121 $date->set(1234567890);
2122 $date->set('14.02.09', Zend_Date::DATE_SHORT);
2123 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
2125 $date->set(1234567890);
2126 try {
2127 $date->set('noday', Zend_Date::TIMES);
2128 $this->fail();
2129 } catch (Zend_Date_Exception $e) {
2130 // success
2132 $date->set($d2, Zend_Date::TIMES);
2133 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2134 $date->set(1234567890);
2135 $date->set('15:26:40', Zend_Date::TIMES);
2136 $this->assertSame('2009-02-14T15:26:40+05:00', $date->get(Zend_Date::W3C));
2138 $date->set(1234567890);
2139 try {
2140 $date->set('noday', Zend_Date::TIME_FULL);
2141 $this->fail();
2142 } catch (Zend_Date_Exception $e) {
2143 // success
2145 $date->set($d2, Zend_Date::TIME_FULL);
2146 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2147 $date->set(1234567890);
2148 $date->set('15:26 Uhr CET', Zend_Date::TIME_FULL);
2149 $this->assertSame('2009-02-14T15:26:00+01:00', $date->get(Zend_Date::W3C));
2151 $date->set(1234567890);
2152 try {
2153 $date->set('noday', Zend_Date::TIME_LONG);
2154 $this->fail();
2155 } catch (Zend_Date_Exception $e) {
2156 // success
2158 $date->set($d2, Zend_Date::TIME_LONG);
2159 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2160 $date->set(1234567890);
2161 $date->set('15:26:40 CET', Zend_Date::TIME_LONG);
2162 $this->assertSame('2009-02-14T15:26:40+01:00', $date->get(Zend_Date::W3C));
2164 $date->setTimezone('Indian/Maldives');
2165 $date->set(1234567890);
2166 try {
2167 $date->set('noday', Zend_Date::TIME_MEDIUM);
2168 $this->fail();
2169 } catch (Zend_Date_Exception $e) {
2170 // success
2172 $date->set($d2, Zend_Date::TIME_MEDIUM);
2173 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2174 $date->set(1234567890);
2175 $date->set('15:26:40', Zend_Date::TIME_MEDIUM);
2176 $this->assertSame('2009-02-14T15:26:40+05:00', $date->get(Zend_Date::W3C));
2178 $date->set(1234567890);
2179 try {
2180 $date->set('noday', Zend_Date::TIME_SHORT);
2181 $this->fail();
2182 } catch (Zend_Date_Exception $e) {
2183 // success
2185 $date->set($d2, Zend_Date::TIME_SHORT);
2186 $this->assertSame('2009-02-14T04:36:00+05:00', $date->get(Zend_Date::W3C));
2187 $date->set(1234567890);
2188 $date->set('15:26', Zend_Date::TIME_SHORT);
2189 $this->assertSame('2009-02-14T15:26:00+05:00', $date->get(Zend_Date::W3C));
2191 $date->set(1234567890);
2192 try {
2193 $date->set('noday', Zend_Date::DATETIME);
2194 $this->fail();
2195 } catch (Zend_Date_Exception $e) {
2196 // success
2198 $date->set($d2, Zend_Date::DATETIME);
2199 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2200 $date->set(1234567890);
2201 $date->set('14.02.2009 15:26:03', Zend_Date::DATETIME);
2202 $this->assertSame('2009-02-14T15:26:03+05:00', $date->get(Zend_Date::W3C));
2204 $date->set(1234567890);
2205 try {
2206 $date->set('noday', Zend_Date::DATETIME_FULL);
2207 $this->fail();
2208 } catch (Zend_Date_Exception $e) {
2209 // success
2211 $date->set($d2, Zend_Date::DATETIME_FULL);
2212 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2213 $date->set(1234567890);
2214 $date->set('Samstag, 14. Februar 2009 15:26 Uhr CET', Zend_Date::DATETIME_FULL);
2215 $this->assertSame('2009-02-14T15:26:00+01:00', $date->get(Zend_Date::W3C));
2217 $date->set(1234567890);
2218 try {
2219 $date->set('noday', Zend_Date::DATETIME_LONG);
2220 $this->fail();
2221 } catch (Zend_Date_Exception $e) {
2222 // success
2224 $date->set($d2, Zend_Date::DATETIME_LONG);
2225 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2226 $date->set(1234567890);
2227 $date->set('14. Februar 2009 15:26:03 CET', Zend_Date::DATETIME_LONG);
2228 $this->assertSame('2009-02-14T15:26:03+01:00', $date->get(Zend_Date::W3C));
2230 $date->set(1234567890);
2231 try {
2232 $date->set('noday', Zend_Date::DATETIME_MEDIUM);
2233 $this->fail();
2234 } catch (Zend_Date_Exception $e) {
2235 // success
2237 $date->set($d2, Zend_Date::DATETIME_MEDIUM);
2238 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2239 $date->set(1234567890);
2240 $date->set('14.02.2009 15:26:31', Zend_Date::DATETIME_MEDIUM);
2241 $this->assertSame('2009-02-14T15:26:31+05:00', $date->get(Zend_Date::W3C));
2243 $date->set(1234567890);
2244 try {
2245 $date->set('noday', Zend_Date::DATETIME_SHORT);
2246 $this->fail();
2247 } catch (Zend_Date_Exception $e) {
2248 // success
2250 $date->set($d2, Zend_Date::DATETIME_SHORT);
2251 $this->assertSame('2002-01-04T04:36:00+05:00', $date->get(Zend_Date::W3C));
2252 $date->set(1234567890);
2253 $date->set('14.02.09 15:26', Zend_Date::DATETIME_SHORT);
2254 $this->assertSame('2009-02-14T15:26:00+05:00', $date->get(Zend_Date::W3C));
2256 $date->set(1234567890);
2257 try {
2258 $date->set('noday', Zend_Date::ATOM);
2259 $this->fail();
2260 } catch (Zend_Date_Exception $e) {
2261 // success
2263 $date->set($d2, Zend_Date::ATOM);
2264 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2265 $date->set(1234567890);
2266 $date->set('2009-02-14T00:31:30+05:00', Zend_Date::ATOM);
2267 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2269 $date->set(1234567890);
2270 try {
2271 $date->set('noday', Zend_Date::COOKIE);
2272 $this->fail();
2273 } catch (Zend_Date_Exception $e) {
2274 // success
2276 $date->set($d2, Zend_Date::COOKIE);
2277 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2278 $date->set(1234567890);
2279 $date->set('Saturday, 14-Feb-09 00:31:30 Europe/Vienna', Zend_Date::COOKIE);
2280 $this->assertSame('2009-02-14T00:31:30+01:00', $date->get(Zend_Date::W3C));
2282 $date->set(1234567890);
2283 try {
2284 $date->set('noday', Zend_Date::RFC_822);
2285 $this->fail();
2286 } catch (Zend_Date_Exception $e) {
2287 // success
2289 $date->set($d2, Zend_Date::RFC_822);
2290 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2291 $date->set(1234567890);
2292 $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date::RFC_822);
2293 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2295 $date->set(1234567890);
2296 try {
2297 $date->set('noday', Zend_Date::RFC_850);
2298 $this->fail();
2299 } catch (Zend_Date_Exception $e) {
2300 // success
2302 $date->set($d2, Zend_Date::RFC_850);
2303 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2304 $date->set(1234567890);
2305 $date->set('Saturday, 14-Feb-09 00:31:30 Europe/Vienna', Zend_Date::RFC_850);
2306 $this->assertSame('2009-02-14T00:31:30+01:00', $date->get(Zend_Date::W3C));
2308 $date->set(1234567890);
2309 try {
2310 $date->set('noday', Zend_Date::RFC_1036);
2311 $this->fail();
2312 } catch (Zend_Date_Exception $e) {
2313 // success
2315 $date->set($d2, Zend_Date::RFC_1036);
2316 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2317 $date->set(1234567890);
2318 $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date::RFC_1036);
2319 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2321 $date->set(1234567890);
2322 try {
2323 $date->set('noday', Zend_Date::RFC_1123);
2324 $this->fail();
2325 } catch (Zend_Date_Exception $e) {
2326 // success
2328 $date->set($d2, Zend_Date::RFC_1123);
2329 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2330 $date->set(1234567890);
2331 $date->set('Sat, 14 Feb 2009 00:31:30 +0500', Zend_Date::RFC_1123);
2332 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2334 $date->set(1234567890);
2335 try {
2336 $date->set('noday', Zend_Date::RFC_3339);
2337 $this->fail();
2338 } catch (Zend_Date_Exception $e) {
2339 // success
2341 $date->set($d2, Zend_Date::RFC_3339);
2342 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2343 $date->set(1234567890);
2344 $date->set('2009-02-14T00:31:30+05:00', Zend_Date::RFC_3339);
2345 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2347 $date->set(1234567890);
2348 try {
2349 $date->set('noday', Zend_Date::RSS);
2350 $this->fail();
2351 } catch (Zend_Date_Exception $e) {
2352 // success
2354 $date->set($d2, Zend_Date::RSS);
2355 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2356 $date->set(1234567890);
2357 $date->set('Sat, 14 Feb 2009 00:31:30 +0500', Zend_Date::RSS);
2358 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2359 $date->set('Sat, 14 Feb 2009 00:31:30 GMT', Zend_Date::RSS);
2360 $this->assertSame('2009-02-14T00:31:30+00:00', $date->get(Zend_Date::W3C));
2361 $date->set('Sat, 14 Feb 09 00:31:30 GMT', Zend_Date::RSS);
2362 $this->assertSame('2009-02-14T00:31:30+00:00', $date->get(Zend_Date::W3C));
2363 $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date::RSS);
2364 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2366 $date->set(1234567890);
2367 try {
2368 $date->set('noday', Zend_Date::W3C);
2369 $this->fail();
2370 } catch (Zend_Date_Exception $e) {
2371 // success
2373 $date->set($d2, Zend_Date::W3C);
2374 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2375 $date->set(1234567890);
2376 $date->set('2009-02-14T00:31:30+05:00', Zend_Date::W3C);
2377 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C));
2378 $date->set('2009-02-14T00:31:30-05:00', Zend_Date::W3C);
2379 $this->assertSame('2009-02-14T00:31:30-05:00', $date->get(Zend_Date::W3C));
2381 $date->setTimezone('Indian/Maldives');
2382 $date->set(1234567890);
2383 try {
2384 $date->set('noday', 'xx');
2385 $this->fail();
2386 } catch (Zend_Date_Exception $e) {
2387 // success
2389 try {
2390 $date->set($d2, 'xx');
2391 $this->fail();
2392 } catch (Zend_Date_Exception $e) {
2393 // success
2395 $date->set(1234567890);
2396 $date->set('1000', 'xx');
2397 $this->assertSame('1970-01-01T05:16:40+05:00', $date->get(Zend_Date::W3C));
2401 * Test for add
2403 public function testAdd()
2405 $locale = new Zend_Locale('de_AT');
2406 $date = new Zend_Date(0,null,$locale);
2407 $d2 = new Zend_Date(1010101010,null,$locale);
2409 $retour = $date->set(1234567890);
2410 $this->assertSame((string)$retour,'1234567890');
2411 $this->assertSame((string)$date->add(10),'1234567900');
2412 $this->assertSame((string)$date->add(-10),'1234567890');
2413 $this->assertSame((string)$date->add(0),'1234567890');
2415 $date->set($d2);
2416 $date->add(10, Zend_Date::DAY);
2417 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2418 $date->add(-10, Zend_Date::DAY);
2419 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2421 $date->set($d2);
2422 $date->add('Mon', Zend_Date::WEEKDAY_SHORT);
2423 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C));
2425 $date->set($d2);
2426 $date->add(10, Zend_Date::DAY_SHORT);
2427 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2428 $date->add(-10, Zend_Date::DAY_SHORT);
2429 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2431 $date->set($d2);
2432 $date->add('Montag', Zend_Date::WEEKDAY);
2433 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C));
2435 $date->set($d2);
2436 $date->add(1, Zend_Date::WEEKDAY_8601);
2437 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C));
2439 $date->set($d2);
2440 try {
2441 $date->add($d2, Zend_Date::DAY_SUFFIX);
2442 $this->fail('exception expected');
2443 } catch (Zend_Date_Exception $e) {
2444 // success
2450 * Test for add
2452 public function testAdd2()
2454 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
2455 $this->markTestSkipped('Extended I18N test skipped');
2456 return;
2459 $locale = new Zend_Locale('de_AT');
2460 $date = new Zend_Date(0,null,$locale);
2461 $d2 = new Zend_Date(1010101010,null,$locale);
2463 $date->set($d2);
2464 $date->add(1, Zend_Date::WEEKDAY_DIGIT);
2465 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C));
2467 $date->set($d2);
2468 $date->add(10, Zend_Date::DAY_OF_YEAR);
2469 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2470 $date->add(-10, Zend_Date::DAY_OF_YEAR);
2471 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2473 $date->set($d2);
2474 $date->add('M', Zend_Date::WEEKDAY_NARROW);
2475 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C));
2477 $date->set($d2);
2478 $date->add('Mo.', Zend_Date::WEEKDAY_NAME);
2479 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C));
2481 $date->set($d2);
2482 $date->add(10, Zend_Date::WEEK);
2483 $this->assertSame('2002-03-15T04:36:50+05:00', $date->get(Zend_Date::W3C));
2484 $date->add(-10, Zend_Date::WEEK);
2485 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2487 $date->set($d2);
2488 $date->add('April', Zend_Date::MONTH_NAME);
2489 $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2491 $date->set($d2);
2492 $date->add(10, Zend_Date::MONTH);
2493 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2494 $date->add(-10, Zend_Date::MONTH);
2495 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2497 $date->set($d2);
2498 $date->add('Apr', Zend_Date::MONTH_NAME_SHORT);
2499 $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2501 $date->set($d2);
2502 $date->add(10, Zend_Date::MONTH_SHORT);
2503 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2504 $date->add(-10, Zend_Date::MONTH_SHORT);
2505 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2507 $date->set($d2);
2508 try {
2509 $date->add($d2, Zend_Date::MONTH_DAYS);
2510 $this->fail('exception expected');
2511 } catch (Zend_Date_Exception $e) {
2512 // success
2515 $date->set($d2);
2516 $date->add('M', Zend_Date::MONTH_NAME_NARROW);
2517 $this->assertSame('2002-06-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2519 $date->set($d2);
2520 try {
2521 $date->add($d2, Zend_Date::LEAPYEAR);
2522 $this->fail('exception expected');
2523 } catch (Zend_Date_Exception $e) {
2524 // success
2527 $date->set($d2);
2528 $date->add(10, Zend_Date::YEAR_8601);
2529 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2530 $date->add(-10, Zend_Date::YEAR_8601);
2531 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2533 $date->set($d2);
2534 $date->add(10, Zend_Date::YEAR);
2535 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2536 $date->add(-10, Zend_Date::YEAR);
2537 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2539 $date->set($d2);
2540 $date->add(10, Zend_Date::YEAR_SHORT);
2541 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2542 $date->add(-10, Zend_Date::YEAR_SHORT);
2543 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2545 $date->set($d2);
2546 $date->add(10, Zend_Date::YEAR_SHORT_8601);
2547 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2548 $date->add(-10, Zend_Date::YEAR_SHORT_8601);
2549 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2551 $date->set($d2);
2552 try {
2553 $date->add('noday', Zend_Date::MERIDIEM);
2554 $this->fail();
2555 } catch (Zend_Date_Exception $e) {
2556 // success
2559 $date->set($d2);
2560 $date->add(10, Zend_Date::SWATCH);
2561 $this->assertSame('2002-01-04T04:51:14+05:00', $date->get(Zend_Date::W3C));
2562 $date->add(-10, Zend_Date::SWATCH);
2563 $this->assertSame('2002-01-04T04:36:49+05:00', $date->get(Zend_Date::W3C));
2565 $date->set($d2);
2566 $date->add(10, Zend_Date::HOUR_SHORT_AM);
2567 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2568 $date->add(-10, Zend_Date::HOUR_SHORT_AM);
2569 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2571 $date->set($d2);
2572 $date->add(10, Zend_Date::HOUR_SHORT);
2573 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2574 $date->add(-10, Zend_Date::HOUR_SHORT);
2575 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2577 $date->set($d2);
2578 $date->add(10, Zend_Date::HOUR_AM);
2579 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2580 $date->add(-10, Zend_Date::HOUR_AM);
2581 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2583 $date->set($d2);
2584 $date->add(10, Zend_Date::HOUR);
2585 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2586 $date->add(-10, Zend_Date::HOUR);
2587 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2589 $date->set($d2);
2590 $date->add(10, Zend_Date::MINUTE);
2591 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C));
2592 $date->add(-10, Zend_Date::MINUTE);
2593 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2595 $date->set($d2);
2596 $date->add(10, Zend_Date::MINUTE_SHORT);
2597 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C));
2598 $date->add(-10, Zend_Date::MINUTE_SHORT);
2599 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2601 $date->set($d2);
2602 $date->add(10, Zend_Date::SECOND);
2603 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C));
2604 $date->add(-10, Zend_Date::SECOND);
2605 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2607 $date->set($d2);
2608 $date->add(10, Zend_Date::SECOND_SHORT);
2609 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C));
2610 $date->add(-10, Zend_Date::SECOND_SHORT);
2611 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2613 $date->set($d2);
2614 $date->add(10, Zend_Date::MILLISECOND);
2615 $this->assertSame('10', $date->get(Zend_Date::MILLISECOND));
2616 $date->add(-10, Zend_Date::MILLISECOND);
2617 $this->assertSame( '0', $date->get(Zend_Date::MILLISECOND));
2619 $date->set($d2);
2620 try {
2621 $date->add('noday', Zend_Date::TIMEZONE_NAME);
2622 $this->fail();
2623 } catch (Zend_Date_Exception $e) {
2624 // success
2627 $date->set($d2);
2628 try {
2629 $date->add('noday', Zend_Date::DAYLIGHT);
2630 $this->fail();
2631 } catch (Zend_Date_Exception $e) {
2632 // success
2635 $date->set($d2);
2636 try {
2637 $date->add('noday', Zend_Date::GMT_DIFF);
2638 $this->fail();
2639 } catch (Zend_Date_Exception $e) {
2640 // success
2643 $date->set($d2);
2644 try {
2645 $date->add('noday', Zend_Date::GMT_DIFF_SEP);
2646 $this->fail();
2647 } catch (Zend_Date_Exception $e) {
2648 // success
2651 $date->set($d2);
2652 try {
2653 $date->add('noday', Zend_Date::TIMEZONE);
2654 $this->fail();
2655 } catch (Zend_Date_Exception $e) {
2656 // success
2659 $date->set($d2);
2660 try {
2661 $date->add('noday', Zend_Date::TIMEZONE_SECS);
2662 $this->fail();
2663 } catch (Zend_Date_Exception $e) {
2664 // success
2667 $date->set($d2);
2668 $date->add('1000-01-02 20:05:12', Zend_Date::ISO_8601);
2669 $this->assertSame('3002-02-07T19:42:02+05:00', $date->get(Zend_Date::W3C));
2671 $date->set($d2);
2672 $date->add('Thu, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_2822);
2673 $this->assertSame('3002-02-07T19:42:02+05:00', $date->get(Zend_Date::W3C));
2675 $date->set($d2);
2676 $date->add(10, Zend_Date::TIMESTAMP);
2677 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C));
2679 $date->set($d2);
2680 try {
2681 $date->add('noday', Zend_Date::ERA);
2682 $this->fail();
2683 } catch (Zend_Date_Exception $e) {
2684 // success
2687 $date->set($d2);
2688 try {
2689 $date->add('noday', Zend_Date::ERA_NAME);
2690 $this->fail();
2691 } catch (Zend_Date_Exception $e) {
2692 // success
2695 $date->set($d2);
2696 $date->add('10.02.0005', Zend_Date::DATES);
2697 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2699 $date->set($d2);
2700 $date->add('Samstag, 10. Februar 0005', Zend_Date::DATE_FULL);
2701 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2703 $date->set($d2);
2704 $date->add('10. Februar 0005', Zend_Date::DATE_LONG);
2705 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2707 $date->set($d2);
2708 $date->add('10.02.0005', Zend_Date::DATE_MEDIUM);
2709 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2711 $date->set($d2);
2712 $date->add('10.02.05', Zend_Date::DATE_SHORT);
2713 $this->assertSame('4007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2715 $date->set($d2);
2716 $date->add('10:05:05', Zend_Date::TIMES);
2717 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date::W3C));
2719 $date->set($d2);
2720 $date->add('10:05 Uhr CET', Zend_Date::TIME_FULL);
2721 $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date::W3C));
2723 $date->set($d2);
2724 $date->add('10:05:05 CET', Zend_Date::TIME_LONG);
2725 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date::W3C));
2727 $date->set($d2);
2728 $date->add('10:05:05', Zend_Date::TIME_MEDIUM);
2729 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date::W3C));
2731 $date->set($d2);
2732 $date->add('10:05', Zend_Date::TIME_SHORT);
2733 $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date::W3C));
2735 $date->set($d2);
2736 $date->add('10.02.0005 10:05:05', Zend_Date::DATETIME);
2737 $this->assertSame('2007-03-14T14:41:55+05:00', $date->get(Zend_Date::W3C));
2739 $date->set($d2);
2740 $date->add('Samstag, 10. Februar 0005 10:05 Uhr CET', Zend_Date::DATETIME_FULL);
2741 $this->assertSame('2007-03-14T14:41:50+05:00', $date->get(Zend_Date::W3C));
2743 $date->set($d2);
2744 $date->add('10. Februar 0005 10:05:05 CET', Zend_Date::DATETIME_LONG);
2745 $this->assertSame('2007-03-14T14:41:55+05:00', $date->get(Zend_Date::W3C));
2747 $date->set($d2);
2748 $date->add('10.02.0005 10:05:05', Zend_Date::DATETIME_MEDIUM);
2749 $this->assertSame('2007-03-14T14:41:55+05:00', $date->get(Zend_Date::W3C));
2751 $date->set($d2);
2752 $date->add('10.02.05 10:05', Zend_Date::DATETIME_SHORT);
2753 $this->assertSame('4007-03-14T14:41:50+05:00', $date->get(Zend_Date::W3C));
2755 $date->set($d2);
2756 $date->add('1000-01-02T20:05:12+05:00', Zend_Date::ATOM);
2757 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C));
2759 $date->set($d2);
2760 $date->add('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::COOKIE);
2761 $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date::W3C));
2763 $date->set($d2);
2764 $date->add('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_822);
2765 $this->assertSame('4002-02-06T19:42:02+05:00', $date->get(Zend_Date::W3C));
2767 $date->set($d2);
2768 $date->add('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::RFC_850);
2769 $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date::W3C));
2771 $date->set($d2);
2772 $date->add('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_1036);
2773 $this->assertSame('4002-02-06T19:42:02+05:00', $date->get(Zend_Date::W3C));
2775 $date->set($d2);
2776 $date->add('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_1123);
2777 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C));
2779 $date->set($d2);
2780 $date->add('1000-01-02T20:05:12+05:00', Zend_Date::RFC_3339);
2781 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C));
2783 $date->set($d2);
2784 $date->add('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RSS);
2785 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C));
2787 $date->set($d2);
2788 $date->add('1000-01-02T20:05:12+05:00', Zend_Date::W3C);
2789 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C));
2791 $date->set($d2);
2792 $date->add('1000', 'xx');
2793 $this->assertSame('2002-01-04T04:53:30+05:00', $date->get(Zend_Date::W3C));
2797 * Test for sub
2799 public function testSub()
2801 $locale = new Zend_Locale('de_AT');
2802 $date = new Zend_Date(0,null,$locale);
2803 $d2 = new Zend_Date(1010101010,null,$locale);
2805 $retour = $date->set(1234567890);
2806 $this->assertSame('1234567890', (string)$retour );
2807 $this->assertSame('1234567900', (string)$date->sub(-10));
2808 $this->assertSame('1234567890', (string)$date->sub( 10));
2809 $this->assertSame('1234567890', (string)$date->sub( 0));
2811 $date->set($d2);
2812 $date->sub(-10, Zend_Date::DAY);
2813 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2814 $date->sub(10, Zend_Date::DAY);
2815 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2819 * Test for sub
2821 public function testSub2()
2823 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
2824 $this->markTestSkipped('Extended I18N test skipped');
2825 return;
2828 $locale = new Zend_Locale('de_AT');
2829 $date = new Zend_Date(0,null,$locale);
2830 $d2 = new Zend_Date(1010101010,null,$locale);
2832 $date->set($d2);
2833 $date->sub('Mon', Zend_Date::WEEKDAY_SHORT);
2834 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C));
2836 $date->set($d2);
2837 $date->sub(-10, Zend_Date::DAY_SHORT);
2838 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2839 $date->sub(10, Zend_Date::DAY_SHORT);
2840 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2842 $date->set($d2);
2843 $date->sub('Montag', Zend_Date::WEEKDAY);
2844 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C));
2846 $date->set($d2);
2847 $date->sub(1, Zend_Date::WEEKDAY_8601);
2848 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C));
2850 $date->set($d2);
2851 try {
2852 $date->sub($d2, Zend_Date::DAY_SUFFIX);
2853 $this->fail('exception expected');
2854 } catch (Zend_Date_Exception $e) {
2855 // success
2858 $date->set($d2);
2859 $date->sub(1, Zend_Date::WEEKDAY_DIGIT);
2860 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C));
2862 $date->set($d2);
2863 $date->sub(-10, Zend_Date::DAY_OF_YEAR);
2864 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C));
2865 $date->sub(10, Zend_Date::DAY_OF_YEAR);
2866 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2868 $date->set($d2);
2869 $date->sub('M', Zend_Date::WEEKDAY_NARROW);
2870 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C));
2872 $date->set($d2);
2873 $date->sub('Mo.', Zend_Date::WEEKDAY_NAME);
2874 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C));
2876 $date->set($d2);
2877 $date->sub(-10, Zend_Date::WEEK);
2878 $this->assertSame('2002-03-15T04:36:50+05:00', $date->get(Zend_Date::W3C));
2879 $date->sub(10, Zend_Date::WEEK);
2880 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2882 $date->set($d2);
2883 $date->sub('April', Zend_Date::MONTH_NAME);
2884 $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2886 $date->set($d2);
2887 $date->sub(-10, Zend_Date::MONTH);
2888 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2889 $date->sub(10, Zend_Date::MONTH);
2890 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2892 $date->set($d2);
2893 $date->sub('Apr', Zend_Date::MONTH_NAME_SHORT);
2894 $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2896 $date->set($d2);
2897 $date->sub(-10, Zend_Date::MONTH_SHORT);
2898 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2899 $date->sub(10, Zend_Date::MONTH_SHORT);
2900 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2902 $date->set($d2);
2903 try {
2904 $date->sub($d2, Zend_Date::MONTH_DAYS);
2905 $this->fail('exception expected');
2906 } catch (Zend_Date_Exception $e) {
2907 // success
2910 $date->set($d2);
2911 $date->sub('M', Zend_Date::MONTH_NAME_NARROW);
2912 $this->assertSame('2001-10-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2914 $date->set($d2);
2915 try {
2916 $date->sub($d2, Zend_Date::LEAPYEAR);
2917 $this->fail('exception expected');
2918 } catch (Zend_Date_Exception $e) {
2919 // success
2922 $date->set($d2);
2923 $date->sub(-10, Zend_Date::YEAR_8601);
2924 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2925 $date->sub(10, Zend_Date::YEAR_8601);
2926 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2928 $date->set($d2);
2929 $date->sub(-10, Zend_Date::YEAR);
2930 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2931 $date->sub(10, Zend_Date::YEAR);
2932 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2934 $date->set($d2);
2935 $date->sub(10, Zend_Date::YEAR_SHORT);
2936 $this->assertSame('1992-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2937 $date->sub(-10, Zend_Date::YEAR_SHORT);
2938 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2940 $date->set($d2);
2941 $date->sub(10, Zend_Date::YEAR_SHORT_8601);
2942 $this->assertSame('1992-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2943 $date->sub(-10, Zend_Date::YEAR_SHORT_8601);
2944 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2946 $date->set($d2);
2947 try {
2948 $date->sub('noday', Zend_Date::MERIDIEM);
2949 $this->fail();
2950 } catch (Zend_Date_Exception $e) {
2951 // success
2954 $date->set($d2);
2955 $date->sub(-10, Zend_Date::SWATCH);
2956 $this->assertSame('2002-01-04T04:51:15+05:00', $date->get(Zend_Date::W3C));
2957 $date->sub(10, Zend_Date::SWATCH);
2958 $this->assertSame('2002-01-04T04:36:51+05:00', $date->get(Zend_Date::W3C));
2960 $date->set($d2);
2961 $date->sub(-10, Zend_Date::HOUR_SHORT_AM);
2962 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2963 $date->sub(10, Zend_Date::HOUR_SHORT_AM);
2964 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2966 $date->set($d2);
2967 $date->sub(-10, Zend_Date::HOUR_SHORT);
2968 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2969 $date->sub(10, Zend_Date::HOUR_SHORT);
2970 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2972 $date->set($d2);
2973 $date->sub(-10, Zend_Date::HOUR_AM);
2974 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2975 $date->sub(10, Zend_Date::HOUR_AM);
2976 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2978 $date->set($d2);
2979 $date->sub(-10, Zend_Date::HOUR);
2980 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C));
2981 $date->sub(10, Zend_Date::HOUR);
2982 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2984 $date->set($d2);
2985 $date->sub(-10, Zend_Date::MINUTE);
2986 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C));
2987 $date->sub(10, Zend_Date::MINUTE);
2988 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2990 $date->set($d2);
2991 $date->sub(-10, Zend_Date::MINUTE_SHORT);
2992 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C));
2993 $date->sub(10, Zend_Date::MINUTE_SHORT);
2994 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
2996 $date->set($d2);
2997 $date->sub(-10, Zend_Date::SECOND);
2998 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C));
2999 $date->sub(10, Zend_Date::SECOND);
3000 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
3002 $date->set($d2);
3003 $date->sub(-10, Zend_Date::SECOND_SHORT);
3004 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C));
3005 $date->sub(10, Zend_Date::SECOND_SHORT);
3006 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C));
3008 $date->set($d2);
3009 $date->sub(-10, Zend_Date::MILLISECOND);
3010 $this->assertSame('10', $date->get(Zend_Date::MILLISECOND));
3011 $date->sub(10, Zend_Date::MILLISECOND);
3012 $this->assertSame( '0', $date->get(Zend_Date::MILLISECOND));
3014 $date->set($d2);
3015 try {
3016 $date->sub('noday', Zend_Date::TIMEZONE_NAME);
3017 $this->fail();
3018 } catch (Zend_Date_Exception $e) {
3019 // success
3022 $date->set($d2);
3023 try {
3024 $date->sub('noday', Zend_Date::DAYLIGHT);
3025 $this->fail();
3026 } catch (Zend_Date_Exception $e) {
3027 // success
3030 $date->set($d2);
3031 try {
3032 $date->sub('noday', Zend_Date::GMT_DIFF);
3033 $this->fail();
3034 } catch (Zend_Date_Exception $e) {
3035 // success
3038 $date->set($d2);
3039 try {
3040 $date->sub('noday', Zend_Date::GMT_DIFF_SEP);
3041 $this->fail();
3042 } catch (Zend_Date_Exception $e) {
3043 // success
3046 $date->set($d2);
3047 try {
3048 $date->sub('noday', Zend_Date::TIMEZONE);
3049 $this->fail();
3050 } catch (Zend_Date_Exception $e) {
3051 // success
3054 $date->set($d2);
3055 try {
3056 $date->sub('noday', Zend_Date::TIMEZONE_SECS);
3057 $this->fail();
3058 } catch (Zend_Date_Exception $e) {
3059 // success
3062 $date->set($d2);
3063 $date->sub('1000-01-02 20:05:12', Zend_Date::ISO_8601);
3064 $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date::W3C));
3065 $date->set($d2);
3066 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::ISO_8601);
3067 $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date::W3C));
3069 $date->set($d2);
3070 $date->sub('Thu, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_2822);
3071 $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date::W3C));
3073 $date->set($d2);
3074 $date->sub(-10, Zend_Date::TIMESTAMP);
3075 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C));
3077 $date->set($d2);
3078 try {
3079 $date->sub('noday', Zend_Date::ERA);
3080 $this->fail();
3081 } catch (Zend_Date_Exception $e) {
3082 // success
3085 $date->set($d2);
3086 try {
3087 $date->sub('noday', Zend_Date::ERA_NAME);
3088 $this->fail();
3089 } catch (Zend_Date_Exception $e) {
3090 // success
3093 $date->set($d2);
3094 $date->sub('10.02.0005', Zend_Date::DATES);
3095 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C));
3097 $date->set($d2);
3098 $date->sub('Samstag, 10. Februar 0005', Zend_Date::DATE_FULL);
3099 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C));
3101 $date->set($d2);
3102 $date->sub('10. Februar 0005', Zend_Date::DATE_LONG);
3103 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C));
3105 $date->set($d2);
3106 $date->sub('10.02.0005', Zend_Date::DATE_MEDIUM);
3107 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C));
3109 $date->set($d2);
3110 $date->sub('10.02.05', Zend_Date::DATE_SHORT);
3111 $this->assertSame('-4-10-29T04:36:50+05:00', $date->get(Zend_Date::W3C));
3113 $date->set($d2);
3114 $date->sub('10:05:05', Zend_Date::TIMES);
3115 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date::W3C));
3117 $date->set($d2);
3118 $date->sub('10:05 Uhr CET', Zend_Date::TIME_FULL);
3119 $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date::W3C));
3121 $date->set($d2);
3122 $date->sub('10:05:05 CET', Zend_Date::TIME_LONG);
3123 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date::W3C));
3125 $date->set($d2);
3126 $date->sub('10:05:05', Zend_Date::TIME_MEDIUM);
3127 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date::W3C));
3129 $date->set($d2);
3130 $date->sub('10:05', Zend_Date::TIME_SHORT);
3131 $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date::W3C));
3133 $date->set($d2);
3134 $date->sub('10.02.0005 10:05:05', Zend_Date::DATETIME);
3135 $this->assertSame('1996-10-26T18:31:45+05:00', $date->get(Zend_Date::W3C));
3137 $date->set($d2);
3138 $date->sub('Samstag, 10. Februar 0005 10:05 Uhr CET', Zend_Date::DATETIME_FULL);
3139 $this->assertSame('1996-10-26T18:31:50+05:00', $date->get(Zend_Date::W3C));
3141 $date->set($d2);
3142 $date->sub('10. Februar 0005 10:05:05 CET', Zend_Date::DATETIME_LONG);
3143 $this->assertSame('1996-10-26T18:31:45+05:00', $date->get(Zend_Date::W3C));
3145 $date->set($d2);
3146 $date->sub('10.02.0005 10:05:05', Zend_Date::DATETIME_MEDIUM);
3147 $this->assertSame('1996-10-26T18:31:45+05:00', $date->get(Zend_Date::W3C));
3149 $date->set($d2);
3150 $date->sub('10.02.05 10:05', Zend_Date::DATETIME_SHORT);
3151 $this->assertSame('-4-10-28T18:31:50+05:00', $date->get(Zend_Date::W3C));
3153 $date->set($d2);
3154 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::ATOM);
3155 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C));
3157 $date->set($d2);
3158 $date->sub('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::COOKIE);
3159 $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date::W3C) );
3161 $date->set($d2);
3162 $date->sub('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_822);
3163 $this->assertSame('1-12-03T13:31:38+05:00', $date->get(Zend_Date::W3C));
3165 $date->set($d2);
3166 $date->sub('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::RFC_850);
3167 $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date::W3C));
3169 $date->set($d2);
3170 $date->sub('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_1036);
3171 $this->assertSame('1-12-03T13:31:38+05:00', $date->get(Zend_Date::W3C));
3173 $date->set($d2);
3174 $date->sub('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_1123);
3175 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C));
3177 $date->set($d2);
3178 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::RFC_3339);
3179 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C));
3181 $date->set($d2);
3182 $date->sub('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RSS);
3183 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C));
3185 $date->set($d2);
3186 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::W3C);
3187 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C));
3189 $date->set($d2);
3190 $date->sub('1000', 'xx');
3191 $this->assertSame('2002-01-04T04:20:10+05:00', $date->get(Zend_Date::W3C));
3195 * Test for compare
3197 public function testCompare()
3199 $locale = new Zend_Locale('de_AT');
3200 $date = new Zend_Date(0,null,$locale);
3201 $d2 = new Zend_Date(1010101010,null,$locale);//03.01.2002 15:36:50
3203 $retour = $date->set(1234567890); //13.02.2009 15:31:30
3204 $this->assertSame('1234567890', (string)$retour);
3205 $this->assertSame( 0, $date->compare(1234567890));
3206 $this->assertSame( 1, $date->compare(1234567800));
3207 $this->assertSame(-1, $date->compare(1234567899));
3209 $date->set($d2);//03.01.2002 15:36:50
3210 $this->assertSame( 1, $date->compare(3,Zend_Date::DAY));
3211 $this->assertSame( 0, $date->compare(4,Zend_Date::DAY));
3212 $this->assertSame(-1, $date->compare(5,Zend_Date::DAY));
3214 $this->assertSame( 1, $date->compare('Mon',Zend_Date::WEEKDAY_SHORT));
3215 $this->assertSame(-1, $date->compare('Sam',Zend_Date::WEEKDAY_SHORT));
3217 $date->set($d2);//03.01.2002 15:36:50
3218 $this->assertSame(0, $date->compare(0,Zend_Date::MILLISECOND));
3222 * Test for copy
3224 public function testCopy()
3226 $locale = new Zend_Locale('de_AT');
3227 $date = new Zend_Date(0,null,$locale);
3228 $d2 = new Zend_Date(1010101010,null,$locale);
3230 $date->set(1234567890);
3231 $newdate = clone $date;
3232 $this->assertSame($date->get(),$newdate->get());
3234 $date->set($d2);
3235 $newdate = $date->copyPart(Zend_Date::DAY);
3236 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C ));
3237 $this->assertSame('1970-01-04T05:00:00+05:00', $newdate->get(Zend_Date::W3C));
3241 * Test for equals
3243 public function testEquals()
3245 $locale = new Zend_Locale('de_AT');
3246 $date = new Zend_Date(0,null,$locale);
3247 $d2 = new Zend_Date(1010101010,null,$locale);
3249 $retour = $date->set(1234567890);
3250 $this->assertSame('1234567890', (string)$retour);
3251 $this->assertTrue( $date->equals(1234567890));
3252 $this->assertFalse($date->equals(1234567800));
3254 $date->set($d2);
3255 $this->assertFalse($date->equals(3,Zend_Date::DAY));
3256 $this->assertTrue( $date->equals(4,Zend_Date::DAY));
3260 * Test for isEarlier
3262 public function testIsEarlier()
3264 $locale = new Zend_Locale('de_AT');
3265 $date = new Zend_Date(0,null,$locale);
3266 $d2 = new Zend_Date(1010101010,null,$locale);
3268 $retour = $date->set(1234567890);
3269 $this->assertSame('1234567890', (string)$retour);
3270 $this->assertFalse($date->isEarlier(1234567890));
3271 $this->assertFalse($date->isEarlier(1234567800));
3272 $this->assertTrue( $date->isEarlier(1234567899));
3274 $date->set($d2);
3275 $this->assertFalse($date->isEarlier(3,Zend_Date::DAY));
3276 $this->assertFalse($date->isEarlier(4,Zend_Date::DAY));
3277 $this->assertTrue( $date->isEarlier(5,Zend_Date::DAY));
3281 * Test for isLater
3283 public function testIsLater()
3285 $locale = new Zend_Locale('de_AT');
3286 $date = new Zend_Date(0,null,$locale);
3287 $d2 = new Zend_Date(1010101010,null,$locale);
3289 $retour = $date->set(1234567890);
3290 $this->assertSame('1234567890', (string)$retour);
3291 $this->assertFalse($date->isLater(1234567890));
3292 $this->assertTrue( $date->isLater(1234567800));
3293 $this->assertFalse($date->isLater(1234567899));
3295 $date->set($d2);
3296 $this->assertTrue( $date->isLater(3,Zend_Date::DAY));
3297 $this->assertFalse($date->isLater(4,Zend_Date::DAY));
3298 $this->assertFalse($date->isLater(5,Zend_Date::DAY));
3302 * Test for getTime
3304 public function testGetTime()
3306 $locale = new Zend_Locale('de_AT');
3307 $date = new Zend_Date(1010101010,null,$locale);
3308 $d2 = new Zend_Date(1010101010,null,$locale);
3310 $result = $date->getTime();
3311 $this->assertSame('1970-01-01T04:36:50+05:00', $result->get(Zend_Date::W3C));
3315 * Test for setTime
3317 public function testSetTime()
3319 $locale = new Zend_Locale('de_AT');
3321 $date = new Zend_Date(1234567890,null,$locale);
3322 $d2 = new Zend_Date(1234567899,null,$locale);
3324 $result = $date->setTime(Zend_Date::now());
3325 $this->assertTrue($result instanceof Zend_Date);
3326 $result = $date->setTime('10:20:30');
3327 $this->assertSame('2009-02-14T10:20:30+05:00', $result->get(Zend_Date::W3C));
3328 $this->assertSame('2009-02-14T10:20:30+05:00', $date->get(Zend_Date::W3C));
3329 $date->setTime('30-20-10','ss:mm:HH');
3330 $this->assertSame('2009-02-14T10:20:30+05:00', $date->get(Zend_Date::W3C));
3331 $date->setTime($d2);
3332 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date::W3C));
3334 $date = new Zend_Date(Zend_Date::now(), $locale);
3335 $t1 = $date->get(Zend_Date::TIMESTAMP);
3336 $date->setTime(Zend_Date::now());
3337 $t2 = $date->get(Zend_Date::TIMESTAMP);
3338 $diff = abs($t2 - $t1);
3339 $this->assertTrue($diff < 2, "Instance of Zend_Date has a significantly different time than returned by setTime(): $diff seconds");
3343 * Test for addTime
3345 public function testAddTime()
3347 $locale = new Zend_Locale('de_AT');
3348 $date = new Zend_Date(1234567890,null,$locale);
3349 $d2 = new Zend_Date(1234567899,null,$locale);
3351 $result = $date->addTime(Zend_Date::now());
3352 $this->assertTrue($result instanceof Zend_Date);
3354 $date = new Zend_Date(1234567890,null,$locale);
3355 $result = $date->addTime('10:20:30');
3356 $this->assertSame('2009-02-14T14:52:00+05:00', $result->get(Zend_Date::W3C));
3357 $this->assertSame('2009-02-14T14:52:00+05:00', $date->get(Zend_Date::W3C));
3359 $date = new Zend_Date(1234567890,null,$locale);
3360 $date->addTime('30:20:10','ss:mm:HH');
3361 $this->assertSame('2009-02-14T14:52:00+05:00', $date->get(Zend_Date::W3C));
3363 $date = new Zend_Date(1234567890,null,$locale);
3364 $date->addTime($d2);
3365 $this->assertSame('2009-02-14T09:03:09+05:00', $date->get(Zend_Date::W3C));
3369 * Test for subTime
3371 public function testSubTime()
3373 $locale = new Zend_Locale('de_AT');
3374 $date = new Zend_Date(1234567890,null,$locale);
3375 $d2 = new Zend_Date(1234567899,null,$locale);
3377 $result = $date->subTime(Zend_Date::now());
3378 $this->assertTrue($result instanceof Zend_Date);
3380 $date = new Zend_Date(1234567890,null,$locale);
3381 $result = $date->subTime('10:20:30');
3382 $this->assertSame('2009-02-13T18:11:00+05:00', $result->get(Zend_Date::W3C));
3383 $this->assertSame('2009-02-13T18:11:00+05:00', $date->get(Zend_Date::W3C));
3385 $date = new Zend_Date(1234567890,null,$locale);
3386 $date->subTime('30-20-10','ss:mm:HH');
3387 $this->assertSame('2009-02-13T18:11:00+05:00', $date->get(Zend_Date::W3C));
3389 $date = new Zend_Date(1234567890,null,$locale);
3390 $date->subTime($d2);
3391 $this->assertSame('2009-02-13T23:59:51+05:00', $date->get(Zend_Date::W3C));
3395 * Test for compareTime
3397 public function testCompareTime()
3399 $locale = new Zend_Locale('de_AT');
3400 $date = new Zend_Date(1234567890,null,$locale);
3401 $d2 = new Zend_Date(1234567899,null,$locale);
3403 $date = new Zend_Date(1234567890,null,$locale);
3404 $this->assertSame(-1, $date->compareTime('10:20:30'));
3405 $this->assertSame( 0, $date->compareTime('04:31:30'));
3406 $this->assertSame( 1, $date->compareTime('04:00:30'));
3407 $this->assertSame(-1, $date->compareTime($d2 ));
3411 * Test for setTime
3413 public function testSetHour()
3415 $locale = new Zend_Locale('de_AT');
3417 $date = new Zend_Date(1234567890,null,$locale);
3418 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
3419 for($i=23; $i >= 0; $i--) {
3420 $date->setHour($i);
3421 $hour = $i;
3422 if ($i < 10) {
3423 $hour = '0' . $hour;
3425 $this->assertSame("2009-02-14T$hour:31:30+05:00", $date->get(Zend_Date::W3C));
3430 * Test for getDate
3432 public function testGetDate()
3434 $locale = new Zend_Locale('de_AT');
3435 $date = new Zend_Date(1010101010,null,$locale);
3436 $d2 = new Zend_Date(1010101010,null,$locale);
3438 $result = $date->getDate();
3439 $this->assertSame('2002-01-04T00:00:00+05:00', $result->get(Zend_Date::W3C));
3443 * Test for setDate
3445 public function testSetDate()
3447 $locale = new Zend_Locale('de_AT');
3448 $date = new Zend_Date(1234567890,null,$locale);
3449 $d2 = new Zend_Date(1234567899,null,$locale);
3451 $result = $date->setDate(Zend_Date::now());
3452 $this->assertTrue($result instanceof Zend_Date);
3453 $result = $date->setDate('11.05.2008');
3454 // Hint: the hour changes from 0 to 1 because of DST...
3455 // An hour is added by winter->summertime change
3456 $this->assertSame('2008-05-11T04:31:30+05:00', $result->get(Zend_Date::W3C));
3457 $this->assertSame('2008-05-11T04:31:30+05:00', $date->get(Zend_Date::W3C));
3458 $date->setDate('2008-05-11','YYYY-MM-dd');
3459 $this->assertSame('2008-05-11T04:31:30+05:00', $date->get(Zend_Date::W3C));
3460 $date->setDate($d2);
3461 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C));
3465 * Test for addDate
3467 public function testAddDate()
3469 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3470 $this->markTestSkipped('Extended I18N test skipped');
3471 return;
3474 $locale = new Zend_Locale('de_AT');
3475 $date = new Zend_Date(1234567890,null,$locale);
3476 $d2 = new Zend_Date(1234567899,null,$locale);
3478 $result = $date->addDate(Zend_Date::now());
3479 $this->assertTrue($result instanceof Zend_Date);
3481 $date = new Zend_Date(1234567890,null,$locale);
3482 $result = $date->addDate('02-03-05');
3483 $this->assertSame('4014-05-17T04:31:30+05:00', $result->get(Zend_Date::W3C));
3484 $this->assertSame('4014-05-17T04:31:30+05:00', $date->get(Zend_Date::W3C));
3486 $date = new Zend_Date(1234567890,null,$locale);
3487 $date->addDate('05-03-02','YY-MM-dd');
3488 $this->assertSame('4014-05-17T04:31:30+05:00', $date->get(Zend_Date::W3C));
3490 $date = new Zend_Date(1234567890,null,$locale);
3491 $date->addDate($d2);
3492 $this->assertSame('4018-04-28T04:31:30+05:00', $date->get(Zend_Date::W3C));
3496 * Test for subDate
3498 public function testSubDate()
3500 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3501 $this->markTestSkipped('Extended I18N test skipped');
3502 return;
3505 $locale = new Zend_Locale('de_AT');
3506 $date = new Zend_Date(1234567890,null,$locale);
3507 $d2 = new Zend_Date(1234567899,null,$locale);
3509 $result = $date->subDate(Zend_Date::now());
3510 $this->assertTrue($result instanceof Zend_Date);
3512 $date = new Zend_Date(1234567890,null,$locale);
3513 $result = $date->subDate('03-05-1001');
3514 $this->assertSame('1007-09-08T04:31:30+05:00', $result->get(Zend_Date::W3C));
3515 $this->assertSame('1007-09-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
3517 $date = new Zend_Date(1234567890,null,$locale);
3518 $date->subDate('1001-05-03','YYYY-MM-dd');
3519 $this->assertSame('1007-09-08T04:31:30+05:00', $date->get(Zend_Date::W3C));
3521 $date = new Zend_Date(1234567890,null,$locale);
3522 $date->subDate($d2);
3523 $this->assertSame('-1-12-06T04:31:30+05:00', $date->get(Zend_Date::W3C));
3527 * Test for compareDate
3529 public function testCompareDate()
3531 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3532 $this->markTestSkipped('Extended I18N test skipped');
3533 return;
3536 $locale = new Zend_Locale('de_AT');
3537 $date = new Zend_Date(1234567890,$locale);
3538 $d2 = new Zend_Date(1234567899,$locale);
3540 $date = new Zend_Date(1234567890,$locale);
3541 $this->assertSame( 1, $date->compareDate('10.01.2009'));
3542 $this->assertSame( 0, $date->compareDate('14.02.2009'));
3543 $this->assertSame(-1, $date->compareDate('15.02.2009'));
3544 $this->assertSame( 0, $date->compareDate($d2 ));
3548 * Test for getIso
3550 public function testGetIso()
3552 $locale = new Zend_Locale('de_AT');
3553 $date = new Zend_Date(1010101010,null,$locale);
3554 $d2 = new Zend_Date(1010101010,null,$locale);
3556 $result = $date->getIso();
3557 $this->assertTrue(is_string($result));
3558 $this->assertSame('2002-01-04T04:36:50+05:00', $result);
3562 * Test for setIso
3564 public function testSetIso()
3566 $locale = new Zend_Locale('de_AT');
3567 $date = new Zend_Date(1234567890,null,$locale);
3568 $d2 = new Zend_Date(1234567899,null,$locale);
3570 $result = $date->setIso(Zend_Date::now());
3571 $this->assertTrue($result instanceof Zend_Date);
3572 $result = $date->setIso('2002-01-04T00:00:00+0000');
3573 $this->assertSame('2002-01-04T00:00:00+00:00', $result->get(Zend_Date::W3C));
3574 $this->assertSame('2002-01-04T00:00:00+00:00', $date->get(Zend_Date::W3C));
3575 $date->setIso($d2);
3576 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date::W3C));
3580 * Test for addIso
3582 public function testAddIso()
3584 $locale = new Zend_Locale('de_AT');
3585 $date = new Zend_Date(1234567890,$locale);
3586 $d2 = new Zend_Date(1234567899,$locale);
3588 $result = $date->addIso(Zend_Date::now());
3589 $this->assertTrue($result instanceof Zend_Date);
3593 * Test for addIso
3595 public function testAddIso2()
3597 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3598 $this->markTestSkipped('Extended I18N test skipped');
3599 return;
3602 $locale = new Zend_Locale('de_AT');
3603 $date = new Zend_Date(1234567890,$locale);
3604 $d2 = new Zend_Date(1234567899,$locale);
3606 $result = $date->setIso('2002-01-04T01:00:00+0500');
3607 $result = $date->addIso('0000-00-00T01:00:00+0500');
3608 $this->assertSame('2002-01-03T21:00:00+05:00', $result->get(Zend_Date::W3C));
3609 $this->assertSame('2002-01-03T21:00:00+05:00', $date->get(Zend_Date::W3C));
3611 $date->addIso('0001-01-01T01:01:01+0500');
3612 $this->assertSame('2003-02-04T17:01:01+05:00', $date->get(Zend_Date::W3C));
3614 $date = new Zend_Date(1234567890,$locale);
3615 $date->addIso($d2);
3616 $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date::W3C));
3620 * Test for subIso
3622 public function testSubIso()
3624 $locale = new Zend_Locale('de_AT');
3625 $date = new Zend_Date(1234567890,null,$locale);
3626 $d2 = new Zend_Date(1234567899,null,$locale);
3628 $result = $date->subIso(Zend_Date::now());
3629 $this->assertTrue($result instanceof Zend_Date);
3633 * Test for subIso
3635 public function testSubIso2()
3637 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3638 $this->markTestSkipped('Extended I18N test skipped');
3639 return;
3642 $locale = new Zend_Locale('de_AT');
3643 $date = new Zend_Date(1234567890,null,$locale);
3644 $d2 = new Zend_Date(1234567899,null,$locale);
3645 $result = $date->subIso('0000-00-00T01:00:00+0500');
3646 $this->assertSame('2009-02-14T08:31:30+05:00', $result->get(Zend_Date::W3C));
3647 $this->assertSame('2009-02-14T08:31:30+05:00', $date->get(Zend_Date::W3C));
3649 $result = $date->subIso('0001-01-01T01:01:01+0500');
3650 $this->assertSame('2008-01-14T12:30:29+05:00', $date->get(Zend_Date::W3C));
3652 $date = new Zend_Date(1234567890,null,$locale);
3653 $date->subIso($d2);
3654 $this->assertSame('-1-12-06T04:59:51+05:00', $date->get(Zend_Date::W3C));
3658 * Test for compareIso
3660 public function testCompareIso()
3662 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3663 $this->markTestSkipped('Extended I18N test skipped');
3664 return;
3667 $locale = new Zend_Locale('de_AT');
3668 $date = new Zend_Date(1234567890,null,$locale);
3669 $d2 = new Zend_Date(1234567899,null,$locale);
3671 $date = new Zend_Date(1234567890,null,$locale);
3672 $this->assertSame( 1, $date->compareIso('2002-01-04T04:00:00+0500'));
3673 $this->assertSame( 0, $date->compareIso('2009-02-14T04:31:30+0500'));
3674 $this->assertSame(-1, $date->compareIso('2010-01-04T05:00:00+0500'));
3675 $this->assertSame(-1, $date->compareIso($d2 ));
3679 * Test for getArpa
3681 public function testGetArpa()
3683 $locale = new Zend_Locale('de_AT');
3684 $date = new Zend_Date(1010101010,null,$locale);
3686 $result = $date->getArpa();
3687 $this->assertTrue(is_string($result));
3688 $this->assertSame('Fri, 04 Jan 02 04:36:50 +0500', $result);
3692 * Test for setArpa
3694 public function testSetArpa()
3696 $locale = new Zend_Locale('de_AT');
3697 $date = new Zend_Date(1234567890,$locale);
3698 $d2 = new Zend_Date(1234567899,$locale);
3699 $date->setTimezone('Indian/Maldives');
3701 $result = $date->setArpa(Zend_Date::now());
3702 $this->assertTrue($result instanceof Zend_Date);
3703 $result = $date->setArpa('Sat, 03 May 01 00:00:00 +0500');
3704 $this->assertSame('Thu, 03 May 01 00:00:00 +0500', $result->get(Zend_Date::RFC_822));
3705 $this->assertSame('2001-05-03T00:00:00+05:00', $date->get(Zend_Date::W3C));
3706 $date->setArpa($d2);
3707 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date::W3C));
3711 * Test for addArpa
3713 public function testAddArpa()
3715 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3716 $this->markTestSkipped('Extended I18N test skipped');
3717 return;
3720 $locale = new Zend_Locale('de_AT');
3721 $date = new Zend_Date(1234567890,$locale);
3722 $d2 = new Zend_Date(1234567899,$locale);
3724 $result = $date->addArpa(Zend_Date::now());
3725 $this->assertTrue($result instanceof Zend_Date);
3727 $date = new Zend_Date(1234567890,$locale);
3728 $result = $date->addArpa('Sat, 03 May 01 00:00:00 +0500');
3729 $this->assertSame('Sat, 17 Jul 10 23:31:30 +0500', $result->get(Zend_Date::RFC_822));
3730 $this->assertSame('4010-07-17T23:31:30+05:00', $date->get(Zend_Date::W3C));
3732 $date = new Zend_Date(1234567890,$locale);
3733 $date->addArpa($d2);
3734 $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date::W3C));
3736 $result = $date->setArpa('Fri, 05 Jan 07 03:35:53 +0500');
3737 $arpa = $result->getArpa();
3738 $this->assertSame('Fri, 05 Jan 07 03:35:53 +0500', $arpa);
3742 * Test for subArpa
3744 public function testSubArpa()
3746 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3747 $this->markTestSkipped('Extended I18N test skipped');
3748 return;
3751 $locale = new Zend_Locale('de_AT');
3752 $date = new Zend_Date(1234567890,$locale);
3753 $d2 = new Zend_Date(1234567899,$locale);
3755 $result = $date->subArpa(Zend_Date::now());
3756 $this->assertTrue($result instanceof Zend_Date);
3758 $date = new Zend_Date(1234567890,null,$locale);
3759 $result = $date->subArpa('Sat, 03 May 01 00:00:00 +0500');
3760 $this->assertSame('Wed, 16 Sep 7 09:31:30 +0500', $result->get(Zend_Date::RFC_822));
3761 $this->assertSame('7-09-16T09:31:30+05:00', $date->get(Zend_Date::W3C));
3763 $date = new Zend_Date(1234567890,$locale);
3764 $date->subArpa($d2);
3765 $this->assertSame('-1-12-06T04:59:51+05:00', $date->get(Zend_Date::W3C));
3769 * Test for compareArpa
3771 public function testCompareArpa()
3773 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
3774 $this->markTestSkipped('Extended I18N test skipped');
3775 return;
3778 $locale = new Zend_Locale('de_AT');
3779 $date = new Zend_Date(1234567890,$locale);
3780 $d2 = new Zend_Date(1234567899,$locale);
3782 $date = new Zend_Date(1234567890,$locale);
3783 $this->assertSame(-1, $date->compareArpa('Sat, 14 Feb 09 05:31:30 +0500'));
3784 $this->assertSame( 0, $date->compareArpa('Sat, 14 Feb 09 04:31:30 +0500'));
3785 $this->assertSame( 1, $date->compareArpa('Sat, 13 Feb 09 04:31:30 +0500'));
3786 $this->assertSame(-1, $date->compareArpa($d2 ));
3790 * Test for false locale setting
3792 public function testReducedParams()
3794 $locale = new Zend_Locale('de_AT');
3795 $date = new Zend_Date(1010101010,$locale);
3797 $date->setArpa('Sat, 03 May 01 00:00:00 +0500',$locale);
3798 $this->assertSame('Thu, 03 May 01 00:00:00 +0500', $date->get(Zend_Date::RFC_822));
3802 * Test for SunFunc
3804 public function testSunFunc()
3806 $locale = new Zend_Locale('de_AT');
3807 $date = new Zend_Date(1010101010,$locale);
3808 $date->setTimezone(date_default_timezone_get());
3810 $result = Zend_Date_Cities::City('vienna');
3811 $this->assertTrue(is_array($result));
3812 $result = $date->getSunset($result);
3813 $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date::W3C));
3815 unset($result);
3816 $result = Zend_Date_Cities::City('vienna', 'civil');
3817 $this->assertTrue(is_array($result));
3818 $result = $date->getSunset($result);
3819 $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date::W3C));
3821 unset($result);
3822 $result = Zend_Date_Cities::City('vienna', 'nautic');
3823 $this->assertTrue(is_array($result));
3824 $result = $date->getSunset($result);
3825 $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date::W3C));
3827 unset($result);
3828 $result = Zend_Date_Cities::City('vienna', 'astronomic');
3829 $this->assertTrue(is_array($result));
3830 $result = $date->getSunset($result);
3831 $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date::W3C));
3833 unset($result);
3834 $result = Zend_Date_Cities::City('BERLIN');
3835 $this->assertTrue(is_array($result));
3836 $result = $date->getSunrise($result);
3837 $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date::W3C));
3839 unset($result);
3840 $result = Zend_Date_Cities::City('London');
3841 $this->assertTrue(is_array($result));
3842 $result = $date->getSunInfo($result);
3843 $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C ));
3844 $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C ));
3845 $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C ));
3846 $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C));
3847 $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date::W3C ));
3848 $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date::W3C ));
3849 $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C ));
3850 $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C ));
3852 unset($result);
3853 $result = array('longitude' => 0);
3854 try {
3855 $result = $date->getSunrise($result);
3856 $this->fail();
3857 } catch (Zend_Date_Exception $e) {
3858 // success
3861 unset($result);
3862 $result = array('latitude' => 0);
3863 try {
3864 $result = $date->getSunrise($result);
3865 $this->fail();
3866 } catch (Zend_Date_Exception $e) {
3867 // success
3870 unset($result);
3871 $result = array('longitude' => 180.1, 'latitude' => 0);
3872 try {
3873 $result = $date->getSunrise($result);
3874 $this->fail();
3875 } catch (Zend_Date_Exception $e) {
3876 // success
3879 unset($result);
3880 $result = array('longitude' => -180.1, 'latitude' => 0);
3881 try {
3882 $result = $date->getSunrise($result);
3883 $this->fail();
3884 } catch (Zend_Date_Exception $e) {
3885 // success
3888 unset($result);
3889 $result = array('longitude' => 0, 'latitude' => 90.1);
3890 try {
3891 $result = $date->getSunrise($result);
3892 $this->fail();
3893 } catch (Zend_Date_Exception $e) {
3894 // success
3897 unset($result);
3898 $result = array('longitude' => 0, 'latitude' => -90.1);
3899 try {
3900 $result = $date->getSunrise($result);
3901 $this->fail();
3902 } catch (Zend_Date_Exception $e) {
3903 // success
3906 unset($result);
3907 $result = array('latitude' => 0, 'longitude' => 0);
3908 $result = $date->getSunInfo($result);
3909 $this->assertTrue(is_array($result));
3911 unset($result);
3912 $result = array('latitude' => 0, 'longitude' => 0);
3913 $result = $date->getSunrise($result);
3914 $this->assertTrue($result instanceof Zend_Date);
3918 * Test for Timezone
3920 public function testTimezone()
3922 $locale = new Zend_Locale('de_AT');
3923 $date = new Zend_Date(1010101010,$locale);
3924 $date->setTimezone(date_default_timezone_get());
3926 $result = $date->getTimezone();
3927 $this->assertSame('Indian/Maldives', $result);
3929 try {
3930 $result = $date->setTimezone('unknown');
3931 // if function timezone_identifiers_list is not available false should be returned
3932 $this->assertFalse($result);
3933 } catch (Zend_Date_Exception $e) {
3934 // success
3936 $result = $date->getTimezone();
3937 $this->assertSame('Indian/Maldives', $result);
3939 $result = $date->setTimezone('America/Chicago');
3940 $this->assertTrue($result instanceof Zend_Date);
3941 $result = $date->getTimezone();
3942 $this->assertSame('America/Chicago', $result);
3944 $date = new Zend_Date('01.01.2000T00:00:00Z',Zend_Date::ISO_8601);
3945 $result = $date->getTimezone();
3946 $this->assertSame('Etc/UTC', $result);
3950 * Test for LeapYear
3952 public function testLeapYear()
3954 $locale = new Zend_Locale('de_AT');
3956 $date = new Zend_Date('01.01.2006', Zend_Date::DATES, $locale);
3957 $this->assertFalse($date->isLeapYear());
3959 unset($date);
3960 $date = new Zend_Date('01.01.2004', Zend_Date::DATES, $locale);
3961 $this->assertTrue($date->isLeapYear());
3963 try {
3964 $result = Zend_Date::checkLeapYear('noyear');
3965 $this->fail('exception expected');
3966 } catch (Zend_Date_Exception $e) {
3967 // succeed
3972 * Test for Today
3974 public function testToday()
3976 $locale = new Zend_Locale('de_AT');
3978 $date = new Zend_Date(Zend_Date::now());
3979 $d2 = new Zend_Date(1010101010,$locale);
3981 $this->assertFalse($d2->isToday());
3982 $this->assertTrue($date->isToday());
3986 * Test for Yesterday
3988 public function testYesterday()
3990 $locale = new Zend_Locale('de_AT');
3992 $date = new Zend_Date(Zend_Date::now());
3993 $d2 = new Zend_Date(1010101010,$locale);
3994 $date->subDay(1);
3995 $this->assertFalse($d2->isYesterday());
3996 $this->assertTrue($date->isYesterday());
4000 * Test for Tomorrow
4002 public function testTomorrow()
4004 $locale = new Zend_Locale('de_AT');
4006 $date = new Zend_Date(Zend_Date::now());
4007 $d2 = new Zend_Date(1010101010,$locale);
4009 $date->addDay(1);
4010 $this->assertFalse($d2->isTomorrow());
4011 $this->assertTrue($date->isTomorrow());
4015 * test isToday(), isTomorrow(), and isYesterday() for cases other than time() = "now"
4017 public function testIsDay()
4019 date_default_timezone_set('Europe/Vienna'); // should have DST
4020 $locale = new Zend_Locale('de_AT');
4021 $date = new Zend_Date_TestHelper('01.01.2006', Zend_Date::DATES, $locale);
4023 $date->_setTime($date->mktime(0, 0, 0, 1, 1, 2006));
4024 $this->assertTrue($date->isToday());
4025 $this->assertFalse($date->isTomorrow());
4026 $date->_setTime($date->mktime(0, 0, 0, 1, 1, 2006));
4027 $this->assertFalse($date->isYesterday());
4029 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2005));
4030 $this->assertTrue($date->isTomorrow());
4031 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2005));
4032 $this->assertFalse($date->isYesterday());
4034 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2006));
4035 $this->assertFalse($date->isTomorrow());
4036 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2006));
4037 $this->assertFalse($date->isYesterday());
4039 $date->_setTime($date->mktime(0, 0, 0, 1, 0, 2006));
4040 $this->assertTrue($date->isTomorrow());
4041 $date->_setTime($date->mktime(0, 0, 0, 1, 0, 2006));
4042 $this->assertFalse($date->isYesterday());
4044 $date->_setTime($date->mktime(0, 0, 0, 1, 2, 2006));
4045 $this->assertFalse($date->isTomorrow());
4046 $date->_setTime($date->mktime(0, 0, 0, 1, 2, 2006));
4047 $this->assertTrue($date->isYesterday());
4051 * Test for Now
4053 public function testNow()
4055 $locale = new Zend_Locale('de_AT');
4057 $date = Zend_Date::now();
4059 $reference = date('U');
4060 $this->assertTrue(($reference - $date->get(Zend_Date::TIMESTAMP)) < 2);
4064 * Test for getYear
4066 public function testGetYear()
4068 $locale = new Zend_Locale('de_AT');
4070 $date = new Zend_Date(1234567890,$locale);
4071 $d2 = new Zend_Date(1610101010,$locale);
4072 $date->setTimeZone(date_default_timezone_get());
4073 $d2->setTimeZone(date_default_timezone_get());
4075 $result = $date->getYear();
4076 $this->assertTrue($result instanceof Zend_Date);
4077 $this->assertSame('01.01.2009 05:00:00', $result->toString());
4078 $this->assertSame('01.01.2021 05:00:00', $d2->getYear()->toString());
4082 * Test for setYear
4084 public function testSetYear()
4086 $locale = new Zend_Locale('de_AT');
4088 $date = new Zend_Date(1577833200,$locale);
4089 $date2 = new Zend_Date(2006, Zend_Date::YEAR);
4090 $date->setTimeZone(date_default_timezone_get());
4092 $date->setYear(2000);
4093 $this->assertSame('2000-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4095 $date->setYear(1800);
4096 $this->assertSame('1800-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4098 $date->setYear(2100);
4099 $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4101 $date->setYear($date2);
4102 $this->assertSame('2006-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4104 try {
4105 $date->setYear('noyear');
4106 $this->fail();
4107 } catch (Zend_Date_Exception $e) {
4108 // success
4113 * Test for addYear
4115 public function testAddYear()
4117 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
4118 $this->markTestSkipped('Extended I18N test skipped');
4119 return;
4122 $locale = new Zend_Locale('de_AT');
4124 $date = new Zend_Date(1577833200,$locale);
4125 $date->setTimeZone(date_default_timezone_get());
4127 $date->addYear(1);
4128 $this->assertSame('2021-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4129 $date->addYear(1);
4130 $this->assertSame('2022-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4131 $date->addYear(1);
4132 $this->assertSame('2023-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4133 $date->addYear(1);
4134 $this->assertSame('2024-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4135 $date->addYear(1);
4136 $this->assertSame('2025-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4138 $date->setYear(1500);
4139 $this->assertSame('1500-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4140 $date->addYear(20);
4141 $this->assertSame('1520-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4143 $date->setYear(2100);
4144 $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4145 $date->addYear(20);
4146 $this->assertSame('2120-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4148 $date->setDay(4);
4149 $date->setMonth(4);
4150 $date->setYear(2020);
4151 $this->assertSame('2020-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4152 $date->addYear(1);
4153 $this->assertSame('2021-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4154 $date->addYear(1);
4155 $this->assertSame('2022-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4156 $date->addYear(1);
4157 $this->assertSame('2023-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4158 $date->addYear(1);
4159 $this->assertSame('2024-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4160 $date->addYear(1);
4161 $this->assertSame('2025-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4163 $date->setYear(1500);
4164 $this->assertSame('1500-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4165 $date->addYear(20);
4166 $this->assertSame('1520-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4168 $date->setYear(2100);
4169 $this->assertSame('2100-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4170 $date->addYear(20);
4171 $this->assertSame('2120-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C));
4175 * Test for subYear
4177 public function testSubYear()
4179 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) {
4180 $this->markTestSkipped('Extended I18N test skipped');
4181 return;
4184 $locale = new Zend_Locale('de_AT');
4186 $date = new Zend_Date(1577833200,$locale);
4187 $date->setTimeZone(date_default_timezone_get());
4189 $date->subYear(1);
4190 $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4191 $date->subYear(1);
4192 $this->assertSame('2018-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4193 $date->subYear(1);
4194 $this->assertSame('2017-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4195 $date->subYear(1);
4196 $this->assertSame('2016-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4197 $date->subYear(1);
4198 $this->assertSame('2015-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4200 $date->setYear(1500);
4201 $this->assertSame('1500-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4202 $date->subYear(20);
4203 $this->assertSame('1480-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4205 $date->setYear(2100);
4206 $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4207 $date->subYear(20);
4208 $this->assertSame('2080-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4212 * Test for compareYear
4214 public function testCompareYear()
4216 $locale = new Zend_Locale('de_AT');
4217 $date = new Zend_Date(1234567890,$locale);
4218 $d2 = new Zend_Date(1234567899,$locale);
4220 $date = new Zend_Date(1234567890,$locale);
4221 $this->assertSame(-1, $date->compareYear(2010));
4222 $this->assertSame( 0, $date->compareYear(2009));
4223 $this->assertSame( 1, $date->compareYear(2008));
4224 $this->assertSame( 0, $date->compareYear($d2 ));
4228 * Test for getMonth
4230 public function testGetMonth()
4232 $locale = new Zend_Locale('de_AT');
4234 $date = new Zend_Date(1234567890,$locale);
4235 $d2 = new Zend_Date(1610101010,$locale);
4236 $date->setTimeZone(date_default_timezone_get());
4237 $d2->setTimeZone(date_default_timezone_get());
4239 $result = $date->getMonth();
4240 $this->assertTrue($result instanceof Zend_Date);
4241 $this->assertSame('01.02.1970 05:00:00', $result->toString( ));
4242 $this->assertSame('01.02.1970 05:00:00', $date->getMonth()->toString());
4246 * Test for setMonth
4248 public function testSetMonth()
4250 $locale = new Zend_Locale('de_AT');
4252 $date = new Zend_Date(1577833200,$locale);
4253 $date2 = new Zend_Date(2006, Zend_Date::YEAR);
4254 $date->setTimeZone(date_default_timezone_get());
4256 $date->setMonth(3);
4257 $this->assertSame('2020-03-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4259 $date->setMonth(-3);
4260 $this->assertSame('2019-09-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4262 $date->setMonth('March', 'en');
4263 $this->assertSame('2019-03-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4265 $date->setMonth($date2);
4266 $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4268 try {
4269 $date->setMonth('nomonth');
4270 $this->fail();
4271 } catch (Zend_Date_Exception $e) {
4272 // success
4277 * Test for addMonth
4279 public function testAddMonth()
4281 date_default_timezone_set('Europe/Vienna');
4282 $locale = new Zend_Locale('de_AT');
4284 $date = new Zend_Date(1577833200,$locale);
4285 $date->setTimeZone(date_default_timezone_get());
4287 $date->addMonth(1);
4288 $this->assertSame('2020-02-01T00:00:00+01:00', $date->get(Zend_Date::W3C));
4289 $date->addMonth(1);
4290 $this->assertSame('2020-03-01T00:00:00+01:00', $date->get(Zend_Date::W3C));
4291 $date->addMonth(1);
4292 $this->assertSame('2020-04-01T00:00:00+02:00', $date->get(Zend_Date::W3C));
4293 $date->addMonth(1);
4294 $this->assertSame('2020-05-01T00:00:00+02:00', $date->get(Zend_Date::W3C));
4295 $date->addMonth(1);
4296 $this->assertSame('2020-06-01T00:00:00+02:00', $date->get(Zend_Date::W3C));
4297 $date->addMonth(5);
4298 $this->assertSame('2020-11-01T00:00:00+01:00', $date->get(Zend_Date::W3C));
4300 Zend_Date::setOptions(array('fix_dst' => true));
4301 $date = new Zend_Date('2007-10-01 00:00:00', Zend_Date::ISO_8601);
4302 $this->assertSame('2007-10-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4303 $date->addMonth(1);
4304 $this->assertSame('2007-11-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4306 $date = new Zend_Date('2007-10-01 23:00:00', Zend_Date::ISO_8601);
4307 $this->assertSame('2007-10-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4308 $date->addMonth(1);
4309 $this->assertSame('2007-11-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4311 $date = new Zend_Date('2007-03-01 00:00:00', Zend_Date::ISO_8601);
4312 $this->assertSame('2007-03-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4313 $date->addMonth(1);
4314 $this->assertSame('2007-04-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4316 $date = new Zend_Date('2007-03-01 23:00:00', Zend_Date::ISO_8601);
4317 $this->assertSame('2007-03-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4318 $date->addMonth(1);
4319 $this->assertSame('2007-04-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4321 Zend_Date::setOptions(array('fix_dst' => false));
4322 $date = new Zend_Date('2007-10-01 00:00:00', Zend_Date::ISO_8601);
4323 $this->assertSame('2007-10-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4324 $date->addMonth(1);
4325 $this->assertSame('2007-10-31 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4327 $date = new Zend_Date('2007-10-01 23:00:00', Zend_Date::ISO_8601);
4328 $this->assertSame('2007-10-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4329 $date->addMonth(1);
4330 $this->assertSame('2007-11-01 22:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4332 $date = new Zend_Date('2007-03-01 00:00:00', Zend_Date::ISO_8601);
4333 $this->assertSame('2007-03-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4334 $date->addMonth(1);
4335 $this->assertSame('2007-04-01 01:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4337 $date = new Zend_Date('2007-03-01 23:00:00', Zend_Date::ISO_8601);
4338 $this->assertSame('2007-03-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4339 $date->addMonth(1);
4340 $this->assertSame('2007-04-02 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4342 $date = new Zend_Date('2007-01-31 00:00:00', Zend_Date::ISO_8601);
4343 $this->assertSame('2007-01-31 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4344 $date->addMonth(1);
4345 $this->assertSame('2007-02-28 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4347 $date = new Zend_Date('2007-01-31 00:00:00', Zend_Date::ISO_8601);
4348 $this->assertSame('2007-01-31 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4349 Zend_Date::setOptions(array('extend_month' => true));
4350 $date->addMonth(1);
4351 $this->assertSame('2007-03-03 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4353 date_default_timezone_set('America/Chicago');
4354 $date = new Zend_Date(1577858400,$locale);
4355 $date->setTimeZone(date_default_timezone_get());
4356 $this->assertSame('2020-01-01T00:00:00-06:00', $date->get(Zend_Date::ISO_8601));
4357 $date->addMonth(12);
4358 $this->assertSame('2021-01-01T00:00:00-06:00', $date->get(Zend_Date::ISO_8601));
4362 * Test for subMonth
4364 public function testSubMonth()
4366 $locale = new Zend_Locale('de_AT');
4368 $date = new Zend_Date(1577833200,$locale);
4369 $date->setTimeZone(date_default_timezone_get());
4371 $date->subMonth(1);
4372 $this->assertSame('2019-12-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4373 $date->subMonth(12);
4374 $this->assertSame('2018-12-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
4378 * Test for compareMonth
4380 public function testCompareMonth()
4382 $locale = new Zend_Locale('de_AT');
4383 $date = new Zend_Date(1234567890,$locale);
4384 $d2 = new Zend_Date(1234567899,$locale);
4386 $date = new Zend_Date(1234567890,$locale);
4387 $this->assertSame( 1, $date->compareMonth( 1));
4388 $this->assertSame( 0, $date->compareMonth( 2));
4389 $this->assertSame(-1, $date->compareMonth( 3));
4390 $this->assertSame( 0, $date->compareYear($d2));
4394 * Test accessors for _Locale member property of Zend_Date
4396 public function testLocale()
4398 $date = new Zend_Date(Zend_Date::now());
4399 $locale = new Zend_Locale('en_US');
4400 $date->setLocale($locale);
4401 $this->assertSame('en_US', $date->getLocale());
4405 * test for getWeek
4407 public function testGetWeek()
4409 $locale = new Zend_Locale('de_AT');
4410 $date = new Zend_Date(1168293600, $locale);
4412 //Tuesday
4413 $date->addDay(1);
4414 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4416 //Wednesday
4417 $date->addDay(1);
4418 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4420 //Thursday
4421 $date->addDay(1);
4422 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4424 //Friday
4425 $date->addDay(1);
4426 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4428 //Friday 05:30 am
4429 $date->addTime('05:30:00');
4430 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4432 //Saturday
4433 $date->addDay(1);
4434 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4436 //Saturday [ar_EG]
4437 // The right value for AM/PM has to be set in arabic letters
4438 $this->assertSame('08‏/01‏/1970 5:00:00 ص', $date->getWeek('ar_EG')->toString());
4439 $date->setTimeZone('UTC');
4440 $this->assertSame('08‏/01‏/1970 12:00:00 ص', $date->getWeek('ar_EG')->toString());
4441 $date->setTimeZone('Indian/Maldives');
4442 $this->assertSame('08‏/01‏/1970 5:00:00 ص', $date->getWeek('ar_EG')->toString());
4444 //Sunday [start of a new week as defined per ISO 8601]
4445 $date->addDay(1);
4446 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4448 //Monday
4449 $date->addDay(1);
4450 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4452 //Monday 03:45 pm
4453 $date->addTime('15:45:00');
4454 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4458 * test setting dates to specify weekdays
4460 public function testDay()
4462 // all tests and calculations below are in GMT (that is intention for this test)
4463 $date = new Zend_Date(0, 'de_AT');
4464 $date->setTimeZone('UTC');
4465 $dw = $date->getDay();
4466 $this->assertSame('01.01.1970 00:00:00', $dw->toString());
4467 for($day = 1; $day < 31; $day++) {
4468 $date->setDay($day);
4469 $dw = $date->getDay();
4470 $weekday = str_pad($day, 2, '0', STR_PAD_LEFT);
4471 $this->assertSame("$weekday.01.1970 00:00:00", $dw->toString());
4476 * test setWeekday
4478 public function testSetWeekday()
4480 $date = new Zend_Date('2006-01-01','YYYY-MM-dd', 'en');
4481 $date->setWeekday(1);
4482 $this->assertSame('2005-12-26T00:00:00+05:00', $date->getIso());
4484 $date->set('2006-01-02', 'YYYY-MM-dd');
4485 $date->setWeekday(1);
4486 $this->assertSame('2006-01-02T00:00:00+05:00', $date->getIso());
4490 * test setLocale/getLocale
4492 public function testSetLocale()
4494 $date = new Zend_Date(0, 'de');
4496 $this->assertSame('de', $date->getLocale());
4497 $date->setLocale('en');
4498 $this->assertSame('en', $date->getLocale());
4499 $date->setLocale('en_XX');
4500 $this->assertSame('en', $date->getLocale());
4501 $date->setLocale('de_AT');
4502 $this->assertSame('de_AT', $date->getLocale());
4503 $locale = new Zend_Locale('ar');
4504 $date->setLocale($locale);
4505 $this->assertSame('ar', $date->getLocale());
4507 try {
4508 $date->setLocale('xx_XX');
4509 $this->fail();
4510 } catch (Zend_Date_Exception $e) {
4511 // success
4516 * test looseBehaviour
4518 public function testLoose()
4520 $date = new Zend_Date(0, 'de_DE');
4522 try {
4523 $date->set(null, Zend_Date::YEAR);
4524 $this->fail();
4525 } catch (Zend_Date_Exception $e) {
4526 // success
4529 $date->set(10, 'de_DE');
4530 $this->assertEquals(10, $date->getTimestamp());
4532 try {
4533 $date->add(null, Zend_Date::YEAR);
4534 $this->fail();
4535 } catch (Zend_Date_Exception $e) {
4536 // success
4539 $date->add(10, 'de_DE');
4540 $this->assertEquals(20, $date->getTimestamp());
4542 try {
4543 $date->sub(null, Zend_Date::YEAR);
4544 $this->fail();
4545 } catch (Zend_Date_Exception $e) {
4546 // success
4549 $date->sub(10, 'de_DE');
4550 $this->assertEquals(10, $date->getTimestamp());
4552 try {
4553 $date->compare(null, Zend_Date::YEAR);
4554 $this->fail();
4555 } catch (Zend_Date_Exception $e) {
4556 // success
4559 try {
4560 $date->equals(null, Zend_Date::YEAR);
4561 $this->fail();
4562 } catch (Zend_Date_Exception $e) {
4563 // success
4566 try {
4567 $date->isEarlier(null, Zend_Date::YEAR);
4568 $this->fail();
4569 } catch (Zend_Date_Exception $e) {
4570 // success
4573 try {
4574 $date->isLater(null, Zend_Date::YEAR);
4575 $this->fail();
4576 } catch (Zend_Date_Exception $e) {
4577 // success
4580 try {
4581 $date->setTime(null);
4582 $this->fail();
4583 } catch (Zend_Date_Exception $e) {
4584 // success
4587 try {
4588 $date->addTime(null);
4589 $this->fail();
4590 } catch (Zend_Date_Exception $e) {
4591 // success
4594 try {
4595 $date->subTime(null);
4596 $this->fail();
4597 } catch (Zend_Date_Exception $e) {
4598 // success
4601 try {
4602 $date->compareTime(null);
4603 $this->fail();
4604 } catch (Zend_Date_Exception $e) {
4605 // success
4608 try {
4609 $date->setDate(null);
4610 $this->fail();
4611 } catch (Zend_Date_Exception $e) {
4612 // success
4615 try {
4616 $date->addDate(null);
4617 $this->fail();
4618 } catch (Zend_Date_Exception $e) {
4619 // success
4622 try {
4623 $date->subDate(null);
4624 $this->fail();
4625 } catch (Zend_Date_Exception $e) {
4626 // success
4629 try {
4630 $date->compareDate(null);
4631 $this->fail();
4632 } catch (Zend_Date_Exception $e) {
4633 // success
4636 try {
4637 $date->setIso(null);
4638 $this->fail();
4639 } catch (Zend_Date_Exception $e) {
4640 // success
4643 try {
4644 $date->addIso(null);
4645 $this->fail();
4646 } catch (Zend_Date_Exception $e) {
4647 // success
4650 try {
4651 $date->subIso(null);
4652 $this->fail();
4653 } catch (Zend_Date_Exception $e) {
4654 // success
4657 try {
4658 $date->compareIso(null);
4659 $this->fail();
4660 } catch (Zend_Date_Exception $e) {
4661 // success
4664 try {
4665 $date->setArpa(null);
4666 $this->fail();
4667 } catch (Zend_Date_Exception $e) {
4668 // success
4671 try {
4672 $date->addArpa(null);
4673 $this->fail();
4674 } catch (Zend_Date_Exception $e) {
4675 // success
4678 try {
4679 $date->subArpa(null);
4680 $this->fail();
4681 } catch (Zend_Date_Exception $e) {
4682 // success
4685 try {
4686 $date->compareArpa(null);
4687 $this->fail();
4688 } catch (Zend_Date_Exception $e) {
4689 // success
4692 try {
4693 $date->setYear(null);
4694 $this->fail();
4695 } catch (Zend_Date_Exception $e) {
4696 // success
4699 try {
4700 $date->addYear(null);
4701 $this->fail();
4702 } catch (Zend_Date_Exception $e) {
4703 // success
4706 try {
4707 $date->subYear(null);
4708 $this->fail();
4709 } catch (Zend_Date_Exception $e) {
4710 // success
4713 try {
4714 $date->compareYear(null);
4715 $this->fail();
4716 } catch (Zend_Date_Exception $e) {
4717 // success
4720 try {
4721 $date->setMonth(null);
4722 $this->fail();
4723 } catch (Zend_Date_Exception $e) {
4724 // success
4727 try {
4728 $date->addMonth(null);
4729 $this->fail();
4730 } catch (Zend_Date_Exception $e) {
4731 // success
4734 try {
4735 $date->subMonth(null);
4736 $this->fail();
4737 } catch (Zend_Date_Exception $e) {
4738 // success
4741 try {
4742 $date->compareMonth(null);
4743 $this->fail();
4744 } catch (Zend_Date_Exception $e) {
4745 // success
4748 try {
4749 $date->setDay(null);
4750 $this->fail();
4751 } catch (Zend_Date_Exception $e) {
4752 // success
4755 try {
4756 $date->addDay(null);
4757 $this->fail();
4758 } catch (Zend_Date_Exception $e) {
4759 // success
4762 try {
4763 $date->subDay(null);
4764 $this->fail();
4765 } catch (Zend_Date_Exception $e) {
4766 // success
4769 try {
4770 $date->compareDay(null);
4771 $this->fail();
4772 } catch (Zend_Date_Exception $e) {
4773 // success
4776 try {
4777 $date->setWeekday(null);
4778 $this->fail();
4779 } catch (Zend_Date_Exception $e) {
4780 // success
4783 try {
4784 $date->addWeekday(null);
4785 $this->fail();
4786 } catch (Zend_Date_Exception $e) {
4787 // success
4790 try {
4791 $date->subWeekday(null);
4792 $this->fail();
4793 } catch (Zend_Date_Exception $e) {
4794 // success
4797 try {
4798 $date->compareWeekday(null);
4799 $this->fail();
4800 } catch (Zend_Date_Exception $e) {
4801 // success
4804 try {
4805 $date->setDayOfYear(null);
4806 $this->fail();
4807 } catch (Zend_Date_Exception $e) {
4808 // success
4811 try {
4812 $date->addDayOfYear(null);
4813 $this->fail();
4814 } catch (Zend_Date_Exception $e) {
4815 // success
4818 try {
4819 $date->subDayOfYear(null);
4820 $this->fail();
4821 } catch (Zend_Date_Exception $e) {
4822 // success
4825 try {
4826 $date->compareDayOfYear(null);
4827 $this->fail();
4828 } catch (Zend_Date_Exception $e) {
4829 // success
4832 try {
4833 $date->setHour(null);
4834 $this->fail();
4835 } catch (Zend_Date_Exception $e) {
4836 // success
4839 try {
4840 $date->addHour(null);
4841 $this->fail();
4842 } catch (Zend_Date_Exception $e) {
4843 // success
4846 try {
4847 $date->subHour(null);
4848 $this->fail();
4849 } catch (Zend_Date_Exception $e) {
4850 // success
4853 try {
4854 $date->compareHour(null);
4855 $this->fail();
4856 } catch (Zend_Date_Exception $e) {
4857 // success
4860 try {
4861 $date->setMinute(null);
4862 $this->fail();
4863 } catch (Zend_Date_Exception $e) {
4864 // success
4867 try {
4868 $date->addMinute(null);
4869 $this->fail();
4870 } catch (Zend_Date_Exception $e) {
4871 // success
4874 try {
4875 $date->subMinute(null);
4876 $this->fail();
4877 } catch (Zend_Date_Exception $e) {
4878 // success
4881 try {
4882 $date->compareMinute(null);
4883 $this->fail();
4884 } catch (Zend_Date_Exception $e) {
4885 // success
4888 try {
4889 $date->setSecond(null);
4890 $this->fail();
4891 } catch (Zend_Date_Exception $e) {
4892 // success
4895 try {
4896 $date->addSecond(null);
4897 $this->fail();
4898 } catch (Zend_Date_Exception $e) {
4899 // success
4902 try {
4903 $date->subSecond(null);
4904 $this->fail();
4905 } catch (Zend_Date_Exception $e) {
4906 // success
4909 try {
4910 $date->compareSecond(null);
4911 $this->fail();
4912 } catch (Zend_Date_Exception $e) {
4913 // success
4916 try {
4917 $date->setWeek(null);
4918 $this->fail();
4919 } catch (Zend_Date_Exception $e) {
4920 // success
4923 try {
4924 $date->addWeek(null);
4925 $this->fail();
4926 } catch (Zend_Date_Exception $e) {
4927 // success
4930 try {
4931 $date->subWeek(null);
4932 $this->fail();
4933 } catch (Zend_Date_Exception $e) {
4934 // success
4937 try {
4938 $date->compareWeek(null);
4939 $this->fail();
4940 } catch (Zend_Date_Exception $e) {
4941 // success
4945 public function testTimesync()
4947 try {
4948 $server = new Zend_TimeSync('ntp://pool.ntp.org', 'alias');
4949 $date1 = $server->getDate();
4950 // need to use the proxy class to simulate time() returning wrong value
4951 $date2 = new Zend_Date_TestHelper(time());
4953 $info = $server->getInfo();
4955 if ($info['offset'] != 0) {
4956 $this->assertFalse($date1->getTimestamp() == $date2->getTimestamp());
4957 } else {
4958 $this->assertSame($date1->getTimestamp(), $date2->getTimestamp());
4960 } catch (Zend_TimeSync_Exception $e) {
4961 $this->markTestIncomplete('NTP timeserver not available.');
4965 public function testUsePhpDateFormat()
4967 Zend_Date::setOptions(array('format_type' => 'iso'));
4969 // PHP date() format specifier tests
4970 $date1 = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US');
4971 $date2 = new Zend_Date('2006-01-02 23:58:59', 'YYYY-MM-dd HH:mm:ss', 'en_US');
4972 $this->assertSame($date1->getTimestamp(), $date2->getTimestamp());
4974 date_default_timezone_set('GMT');
4975 $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
4976 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'eee'));
4977 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'dd'));
4978 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString( 'EEE', 'en'));
4979 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'd'));
4980 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString( 'EEEE', 'en'));
4981 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'e'));
4982 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'SS'));
4983 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'D'));
4984 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'ww'));
4985 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString( 'MMMM', 'en'));
4986 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'MM'));
4987 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString( 'MMM', 'en'));
4988 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'M'));
4989 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 'ddd'));
4990 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'l'));
4991 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'YYYY'));
4992 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'yyyy'));
4993 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'yy'));
4994 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString( 'a', 'en')));
4995 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString( 'a', 'en')));
4996 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
4997 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'h'));
4998 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'H'));
4999 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'hh'));
5000 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'HH'));
5001 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'mm'));
5002 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 'ss'));
5003 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'zzzz'));
5004 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5005 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'Z'));
5006 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'ZZZZ'));
5007 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'z'));
5008 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'X'));
5009 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString('yyyy-MM-ddTHH:mm:ssZZZZ'));
5010 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5011 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5013 // PHP date() format specifier tests
5014 $date1 = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US');
5015 Zend_Date::setOptions(array('format_type' => 'php'));
5016 $date2 = new Zend_Date('2006-01-02 23:58:59', 'Y-m-d H:i:s', 'en_US');
5017 $this->assertSame($date1->getTimestamp(), $date2->getTimestamp());
5019 date_default_timezone_set('GMT');
5020 $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5021 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
5022 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
5023 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
5024 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j'));
5025 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en'));
5026 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N'));
5027 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S'));
5028 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z'));
5029 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W'));
5030 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en'));
5031 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm'));
5032 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en'));
5033 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n'));
5034 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't'));
5035 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L'));
5036 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o'));
5037 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y'));
5038 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y'));
5039 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5040 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5041 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5042 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g'));
5043 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G'));
5044 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h'));
5045 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H'));
5046 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i'));
5047 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's'));
5048 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e'));
5049 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5050 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O'));
5051 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P'));
5052 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T'));
5053 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z'));
5054 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c'));
5055 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5056 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5058 date_default_timezone_set('GMT');
5059 $date = new Zend_Date(mktime(20,10,0,10,10,2000)); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5060 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
5061 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
5062 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
5063 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j'));
5064 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en'));
5065 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N'));
5066 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S'));
5067 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z'));
5068 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W'));
5069 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en'));
5070 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm'));
5071 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en'));
5072 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n'));
5073 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't'));
5074 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L'));
5075 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o'));
5076 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y'));
5077 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y'));
5078 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5079 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5080 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5081 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g'));
5082 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G'));
5083 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h'));
5084 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H'));
5085 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i'));
5086 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's'));
5087 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e'));
5088 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5089 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O'));
5090 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P'));
5091 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T'));
5092 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z'));
5093 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c'));
5094 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5095 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5097 date_default_timezone_set('Indian/Maldives');
5098 $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5099 $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
5100 $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
5101 $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
5102 $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j'));
5103 $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en'));
5104 $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N'));
5105 $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S'));
5106 $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z'));
5107 $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W'));
5108 $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en'));
5109 $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm'));
5110 $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en'));
5111 $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n'));
5112 $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't'));
5113 $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L'));
5114 $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o'));
5115 $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y'));
5116 $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y'));
5117 $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5118 $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5119 $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B'));
5120 $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g'));
5121 $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G'));
5122 $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h'));
5123 $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H'));
5124 $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i'));
5125 $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's'));
5126 $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e'));
5127 $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I'));
5128 $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O'));
5129 $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P'));
5130 $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T'));
5131 $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z'));
5132 $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c'));
5133 $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r'));
5134 $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U'));
5136 date_default_timezone_set('Indian/Maldives');
5137 $date = new Zend_Date(mktime(20,10,0,10,10,2000)); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5138 $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
5139 $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
5140 $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
5141 $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j'));
5142 $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en'));
5143 $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N'));
5144 $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S'));
5145 $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z'));
5146 $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W'));
5147 $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en'));
5148 $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm'));
5149 $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en'));
5150 $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n'));
5151 $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't'));
5152 $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L'));
5153 $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o'));
5154 $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y'));
5155 $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y'));
5156 $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5157 $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5158 $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B'));
5159 $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g'));
5160 $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G'));
5161 $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h'));
5162 $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H'));
5163 $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i'));
5164 $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's'));
5165 $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e'));
5166 $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I'));
5167 $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O'));
5168 $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P'));
5169 $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T'));
5170 $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z'));
5171 $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c'));
5172 $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r'));
5173 $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U'));
5174 Zend_Date::setOptions(array('format_type' => 'iso'));
5177 public function testDaylightsaving()
5179 $date = new Zend_Date('2007.03.25', Zend_Date::DATES);
5180 $date->set('16:00:00', Zend_Date::TIMES);
5181 $this->assertEquals('2007-03-25T16:00:00+05:00', $date->get(Zend_Date::W3C));
5182 $date->set('01:00:00', Zend_Date::TIMES);
5183 $this->assertEquals('2007-03-25T01:00:00+05:00', $date->get(Zend_Date::W3C));
5186 public function testSetOptions()
5188 $options = Zend_Date::setOptions();
5189 $this->assertTrue(is_array($options));
5190 $this->assertEquals('iso', $options['format_type']);
5192 Zend_Date::setOptions(array('format_type' => 'php'));
5193 $options = Zend_Date::setOptions();
5194 $this->assertEquals('php', $options['format_type']);
5196 try {
5197 Zend_Date::setOptions(array('format_type' => 'non'));
5198 $this->fail();
5199 } catch (Zend_Date_Exception $e) {
5200 // success
5203 try {
5204 Zend_Date::setOptions(array('unknown' => 'non'));
5205 $this->fail();
5206 } catch (Zend_Date_Exception $e) {
5207 // success
5209 try {
5210 Zend_Date::setOptions(array('fix_dst' => 2));
5211 $this->fail();
5212 } catch (Zend_Date_Exception $e) {
5213 // success
5216 try {
5217 Zend_Date::setOptions(array('fix_dst' => 2));
5218 $this->fail();
5219 } catch (Zend_Date_Exception $e) {
5220 // success
5223 require_once 'Zend/Cache.php';
5224 $cache = Zend_Cache::factory('Core', 'File',
5225 array('lifetime' => 120, 'automatic_serialization' => true),
5226 array('cache_dir' => dirname(__FILE__) . '/_files/'));
5227 Zend_Date::setOptions(array('cache' => $cache));
5230 public function testIsDate()
5232 $this->assertTrue(Zend_Date::isDate('25.03.2007', 'de_AT'));
5233 $this->assertTrue(Zend_Date::isDate('2007.03.25', 'YYYY.MM.dd'));
5234 $this->assertTrue(Zend_Date::isDate('25.Mai.2007', 'dd.MMMM.YYYY', 'de_AT'));
5235 $this->assertTrue(Zend_Date::isDate('25.Mai.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT'));
5236 $this->assertFalse(Zend_Date::isDate('32.Mai.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT'));
5237 $this->assertFalse(Zend_Date::isDate('30.Februar.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT'));
5238 $this->assertFalse(Zend_Date::isDate('30.Februar.2007 30:00:00', 'dd.MMMM.YYYY HH:mm:ss', 'de_AT'));
5239 $this->assertFalse(Zend_Date::isDate(3.01));
5242 public function testToArray()
5244 $date = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US');
5245 $return = $date->toArray();
5246 $orig = array('day' => 02, 'month' => 01, 'year' => 2006, 'hour' => 23, 'minute' => 58,
5247 'second' => 59, 'timezone' => 'MVT', 'timestamp' => 1136228339, 'weekday' => 1,
5248 'dayofyear' => 1, 'week' => '01', 'gmtsecs' => 18000);
5249 $this->assertEquals($orig, $return);
5252 public function testFromArray()
5254 $date = new Zend_Date(array('day' => 04, 'month' => 12, 'year' => 2006, 'hour' => 10,
5255 'minute' => 56, 'second' => 30), 'en_US');
5256 $this->assertSame('2006-12-04T10:56:30+05:00', $date->getIso());
5259 public function testTimezoneArray()
5261 date_default_timezone_set('UTC');
5263 $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1,
5264 'hour' => 20, 'minute' => 45, 'second' => 37, 'en_US'));
5265 $this->assertSame('2007-01-01T20:45:37+00:00', $date->getIso());
5267 date_default_timezone_set('CET');
5268 $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1,
5269 'hour' => 1, 'minute' => 45, 'second' => 37, 'en_US'));
5270 $this->assertSame('2007-01-01T01:45:37+01:00', $date->getIso());
5272 $date = new Zend_Date(array('year' => 2006, 'month' => 4, 'day' => 18,
5273 'hour' => 12, 'minute' => 3, 'second' => 10, 'de_AT'));
5274 $this->assertSame('2006-04-18T12:03:10+02:00', $date->getIso());
5276 $date = new Zend_Date(array('year' => 2009, 'month' => 1, 'day' => 28,
5277 'hour' => 23, 'minute' => 30, 'second' => 00, 'de'));
5278 $this->assertSame('2009-01-28T23:30:00+01:00', $date->getIso());
5280 $date = new Zend_Date(array('year' => 2009, 'month' => 8, 'day' => 28,
5281 'hour' => 22, 'minute' => 00, 'second' => 00, 'de'));
5282 $this->assertSame('2009-08-28T22:00:00+02:00', $date->getIso());
5285 public function testExtendedDst()
5287 Zend_Date::setOptions(array('format_type' => 'iso'));
5288 $date = new Zend_Date();
5289 $date->setTimezone('UTC');
5290 $date->set('25-05-2050 12:00:00');
5291 $this->assertSame('2050-05-25 12:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5292 $date->setTimezone('Europe/Warsaw');
5293 $this->assertSame('2050-05-25 14:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5295 $date->setTimezone('UTC');
5296 $date->set('25-05-2020 12:00:00');
5297 $this->assertSame('2020-05-25 12:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5298 $date->setTimezone('Europe/Warsaw');
5299 $this->assertSame('2020-05-25 14:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5302 public function testGetFullYear()
5304 $this->assertSame(1970, Zend_Date::getFullYear(70));
5305 $this->assertSame(1999, Zend_Date::getFullYear(99));
5306 $this->assertSame(2000, Zend_Date::getFullYear(0));
5307 $this->assertSame(2037, Zend_Date::getFullYear(37));
5308 $this->assertSame(2069, Zend_Date::getFullYear(69));
5309 $this->assertSame(-4, Zend_Date::getFullYear(-4));
5310 $this->assertSame(100, Zend_Date::getFullYear(100));
5314 * Test for ZF-3677
5316 public function testZF3677()
5318 $locale = new Zend_Locale('de_AT');
5319 require_once 'Zend/Registry.php';
5320 Zend_Registry::set('Zend_Locale', $locale);
5322 $date = new Zend_Date('13',null,$locale);
5323 $this->assertSame($date->getLocale(), $locale->toString());
5327 * Test for ZF-4867
5329 public function testZF4867()
5331 date_default_timezone_set('America/New_York');
5332 $date1 = new Zend_Date('2006-01-01 01:00:00 Europe/Paris', Zend_Date::ISO_8601);
5333 $this->assertEquals('Europe/Paris', $date1->getTimezone());
5337 * Test for ZF-5203
5339 public function testMultiByteWeekdaysShouldNotBeTruncated()
5341 $date1 = new Zend_Date('pl');
5342 $date1->setWeekday(3);
5343 $this->assertEquals('ś', $date1->get(Zend_Date::WEEKDAY_NARROW));
5347 * Test for False Month Addition
5349 public function testAddingMonthWhenChangingTimezone()
5351 $date = new Zend_Date(mktime(22, 59, 59, 1, 10, 2009));
5352 $this->assertEquals(10, $date->toString('d'));
5353 $this->assertEquals( 1, $date->toString('M'));
5354 $date->setTimezone('Europe/Berlin');
5355 $date->addMonth(1);
5356 $this->assertEquals(10, $date->toString('d'));
5357 $this->assertEquals( 2, $date->toString('M'));
5361 * Test for False Month Addition
5363 public function testGmtOffsetValues()
5365 date_default_timezone_set('Pacific/Auckland');
5366 $time = time();
5367 $date = new Zend_Date($time);
5368 $stamp = $date->getGmtOffset();
5370 $localtime = localtime($time, true);
5371 $offset = mktime($localtime['tm_hour'],
5372 $localtime['tm_min'],
5373 $localtime['tm_sec'],
5374 $localtime['tm_mon'] + 1,
5375 $localtime['tm_mday'],
5376 $localtime['tm_year'] + 1900)
5377 - gmmktime($localtime['tm_hour'],
5378 $localtime['tm_min'],
5379 $localtime['tm_sec'],
5380 $localtime['tm_mon'] + 1,
5381 $localtime['tm_mday'],
5382 $localtime['tm_year'] + 1900);
5384 $this->assertEquals($stamp, $offset);
5386 $date->addMonth(6);
5387 $stamp = $date->getGmtOffset();
5390 $localtime = localtime($time, true);
5391 $offset = mktime($localtime['tm_hour'],
5392 $localtime['tm_min'],
5393 $localtime['tm_sec'],
5394 $localtime['tm_mon'] + 7,
5395 $localtime['tm_mday'],
5396 $localtime['tm_year'] + 1900)
5397 - gmmktime($localtime['tm_hour'],
5398 $localtime['tm_min'],
5399 $localtime['tm_sec'],
5400 $localtime['tm_mon'] + 7,
5401 $localtime['tm_mday'],
5402 $localtime['tm_year'] + 1900);
5404 $this->assertEquals($stamp, $offset);
5407 public function testIsDateWithConstants()
5409 $this->assertTrue(Zend_Date::isDate('2009-02-13T23:31:30+00:00', Zend_Date::W3C, 'de_AT'));
5411 $date = new Zend_Date();
5412 $string = $date->toString(Zend_Date::DATES);
5413 $this->assertTrue(Zend_Date::isDate($string, Zend_Date::DATES));
5417 * @ZF-7154
5419 public function testZF7154()
5421 $locale = new Zend_Locale('de_AT');
5423 $date = new Zend_Date(1577833200,$locale);
5424 $date2 = new Zend_Date(2006, Zend_Date::YEAR);
5425 $date->setTimeZone(date_default_timezone_get());
5427 $date->setYear(2000);
5428 $date->setMonth('Apr');
5429 $this->assertSame('2000-04-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
5431 $date->setYear(2004);
5432 $date->setMonth('Februar');
5433 $this->assertSame('2004-02-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
5437 * @ZF-7202
5439 public function testZF7202()
5441 $date = new Zend_Date();
5442 $timezone = $date->getTimezoneFromString('03:58:09 Jul 06, 2009 Indian/Reunion');
5443 $this->assertSame('Indian/Reunion', $timezone);
5447 * @ZF-7589
5449 public function testSetDateWithArray()
5451 $date = new Zend_Date(1234567890);
5452 $result = $date->setDate(array('year' => 2009, 'month' => 8, 'day' => 14));
5454 $this->assertSame('2009-08-14T04:31:30+05:00', $result->get(Zend_Date::W3C));
5458 * @ZF-7454
5460 public function testSetWithoutHourAtDSTChange()
5462 $this->assertTrue(Zend_Date::isDate("23/05/2010", "dd/MM/yyyy", "it_IT"));
5463 $this->assertTrue(Zend_Date::isDate("24/05/2010", "dd/MM/yyyy", "it_IT"));
5467 * @ZF-7456
5469 public function testSetArrayDateWithoutHour()
5471 $date = new Zend_Date(array(
5472 'year'=>2008,
5473 'month'=>3,
5474 'day'=>1)
5476 $this->assertEquals('2008-03-01T00:00:00+05:00', $date->getIso());
5480 * @ZF-7745
5483 public function testSetFirstDayOfLeapYear()
5485 $date = new Zend_Date(2008, Zend_Date::YEAR);
5486 $date->setDayOfYear(1);
5487 $this->assertEquals('2008-01-01T00:00:00+05:00', $date->getIso());
5489 $date->setDayOfYear(61);
5490 $this->assertEquals('2008-03-01T00:00:00+05:00', $date->getIso());
5492 $date->setDayOfYear(62);
5493 $this->assertEquals('2008-03-02T00:00:00+05:00', $date->getIso());
5497 * @ZF-7913
5499 public function testUsePhpNFormat()
5501 Zend_Date::setOptions(array('format_type' => 'php'));
5503 date_default_timezone_set('GMT');
5504 $date = new Zend_Date(mktime(20,10,0,09,20,2009));
5505 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
5506 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
5507 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
5508 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j'));
5509 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en'));
5510 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N'));
5511 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S'));
5512 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z'));
5513 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W'));
5514 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en'));
5515 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm'));
5516 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en'));
5517 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n'));
5518 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't'));
5519 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L'));
5520 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o'));
5521 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y'));
5522 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y'));
5523 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5524 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5525 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5526 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g'));
5527 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G'));
5528 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h'));
5529 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H'));
5530 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i'));
5531 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's'));
5532 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e'));
5533 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5534 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O'));
5535 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P'));
5536 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T'));
5537 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z'));
5538 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c'));
5539 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5540 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5542 date_default_timezone_set('Indian/Maldives');
5543 $date = new Zend_Date(mktime(20,10,0,09,20,2009));
5544 $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
5545 $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
5546 $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
5547 $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j'));
5548 $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en'));
5549 $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N'));
5550 $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S'));
5551 $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z'));
5552 $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W'));
5553 $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en'));
5554 $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm'));
5555 $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en'));
5556 $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n'));
5557 $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't'));
5558 $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L'));
5559 $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o'));
5560 $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y'));
5561 $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y'));
5562 $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5563 $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5564 $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B'));
5565 $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g'));
5566 $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G'));
5567 $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h'));
5568 $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H'));
5569 $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i'));
5570 $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's'));
5571 $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e'));
5572 $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I'));
5573 $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O'));
5574 $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P'));
5575 $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T'));
5576 $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z'));
5577 $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c'));
5578 $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r'));
5579 $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U'));
5580 Zend_Date::setOptions(array('format_type' => 'iso'));
5584 * @ZF-7912
5586 public function testPhpFormatWithIsEmpty()
5588 Zend_Date::setOptions(array('format_type' => 'php'));
5589 $date1 = new Zend_Date();
5590 $date2 = clone $date1;
5591 $date2->add(1, 'd');
5593 $this->assertTrue($date1->isEarlier($date2, 'd.M.y'));
5594 $this->assertFalse($date2->isEarlier($date1, 'd.M.y'));
5595 $this->assertFalse($date1->isLater($date2, 'd.M.y'));
5596 $this->assertTrue($date2->isLater($date1, 'd.M.y'));
5599 public function testPhpFormatWithToString()
5601 Zend_Date::setOptions(array('format_type' => 'php'));
5602 $date = new Zend_Date('10.10.2009 10:10:10');
5603 $this->assertEquals('10.10.2009 10:10:10', $date->toString("d.m.Y H:i:s"));
5604 $date->setTime("23:59:59");
5605 $this->assertEquals('10.10.2009 23:59:59', $date->toString("d.m.Y H:i:s"));
5609 class Zend_Date_TestHelper extends Zend_Date
5611 public function _setTime($timestamp)
5613 $this->_getTime($timestamp);
5616 protected function _getTime($timestamp = null)
5618 static $_timestamp = null;
5619 if ($timestamp !== null) {
5620 $_timestamp = $timestamp;
5622 if ($_timestamp !== null) {
5623 return $_timestamp;
5625 return time();
5628 public function mktime($hour, $minute, $second, $month, $day, $year, $dst= -1, $gmt = false)
5630 return parent::mktime($hour, $minute, $second, $month, $day, $year, $dst, $gmt);