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.
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
26 require_once dirname(__FILE__
) . '/../TestHelper.php';
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);
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";
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
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
);
87 * Test for date object creation
89 public function testCreation()
91 // look if locale is detectable
93 $locale = new Zend_Locale();
94 } catch (Zend_Locale_Exception
$e) {
95 $this->markTestSkipped('Autodetection of locale failed');
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
110 $locale = new Zend_Locale();
111 } catch (Zend_Locale_Exception
$e) {
112 $this->markTestSkipped('Autodetection of locale failed');
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
132 $locale = new Zend_Locale();
133 } catch (Zend_Locale_Exception
$e) {
134 $this->markTestSkipped('Autodetection of locale failed');
138 date_default_timezone_set('America/New_York');
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
170 $locale = new Zend_Locale();
171 } catch (Zend_Locale_Exception
$e) {
172 $this->markTestSkipped('Autodetection of locale failed');
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
187 $locale = new Zend_Locale();
188 } catch (Zend_Locale_Exception
$e) {
189 $this->markTestSkipped('Autodetection of locale failed');
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
227 $locale = new Zend_Locale();
228 } catch (Zend_Locale_Exception
$e) {
229 $this->markTestSkipped('Autodetection of locale failed');
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()
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) {
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());
312 $result = $date->addTimestamp(array('notimestamp' => 1000));
313 $this->fail("exception expected");
314 } catch (Zend_Date_Exception
$e) {
320 * Test for addTimestamp
322 public function testAddTimestamp2()
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) {
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()
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) {
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());
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"));
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
));
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'));
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');
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
));
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));
877 $date->set('noday', Zend_Date
::DAY
);
878 $this->fail('exception expected');
879 } catch (Zend_Date_Exception
$e) {
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
));
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');
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);
930 $date->set('noday', Zend_Date
::WEEKDAY_SHORT
);
931 $this->fail('exception expected');
932 } catch (Zend_Date_Exception
$e) {
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);
960 $date->set('xxx', Zend_Date
::DAY_SHORT
);
961 $this->fail('exception expected');
962 } catch (Zend_Date_Exception
$e) {
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);
992 $date->set('noday', Zend_Date
::WEEKDAY
);
993 $this->fail('exception expected');
994 } catch (Zend_Date_Exception
$e) {
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);
1022 $date->set(0, Zend_Date
::WEEKDAY_8601
);
1023 $this->fail('exception expected');
1024 } catch (Zend_Date_Exception
$e) {
1028 $date->set('noday', Zend_Date
::WEEKDAY_8601
);
1029 $this->fail('exception expected');
1030 } catch (Zend_Date_Exception
$e) {
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);
1058 $date->set($d2, Zend_Date
::DAY_SUFFIX
);
1059 $this->fail('exception expected');
1060 } catch (Zend_Date_Exception
$e) {
1064 $date->set(1234567890);
1066 $date->set(7, Zend_Date
::WEEKDAY_DIGIT
);
1068 } catch (Zend_Date_Exception
$e) {
1072 $date->set('noday', Zend_Date
::WEEKDAY_DIGIT
);
1074 } catch (Zend_Date_Exception
$e) {
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);
1102 $date->set('noday', Zend_Date
::DAY_OF_YEAR
);
1104 } catch (Zend_Date_Exception
$e) {
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);
1134 $date->set('noday', Zend_Date
::WEEKDAY_NARROW
);
1135 $this->fail('exception expected');
1136 } catch (Zend_Date_Exception
$e) {
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);
1164 $date->set('noday', Zend_Date
::WEEKDAY_NAME
);
1166 } catch (Zend_Date_Exception
$e) {
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);
1194 $date->set('noday', Zend_Date
::WEEK
);
1196 } catch (Zend_Date_Exception
$e) {
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);
1226 $date->set('noday', Zend_Date
::MONTH_NAME
);
1227 $this->fail('exception expected');
1228 } catch (Zend_Date_Exception
$e) {
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);
1256 $date->set('noday', Zend_Date
::MONTH
);
1258 } catch (Zend_Date_Exception
$e) {
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);
1288 $date->set('noday', Zend_Date
::MONTH_NAME_SHORT
);
1289 $this->fail('exception expected');
1290 } catch (Zend_Date_Exception
$e) {
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);
1318 $date->set('noday', Zend_Date
::MONTH_SHORT
);
1320 } catch (Zend_Date_Exception
$e) {
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);
1350 $date->set($d2, Zend_Date
::MONTH_DAYS
);
1351 $this->fail('exception expected');
1352 } catch (Zend_Date_Exception
$e) {
1356 $date->set(1234567890);
1358 $date->set('xxday', Zend_Date
::MONTH_NAME_NARROW
);
1359 $this->fail('exception expected');
1360 } catch (Zend_Date_Exception
$e) {
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);
1388 $date->set($d2, Zend_Date
::LEAPYEAR
);
1389 $this->fail('exception expected');
1390 } catch (Zend_Date_Exception
$e) {
1394 $date->set(1234567890);
1396 $date->set('noday', Zend_Date
::YEAR_8601
);
1398 } catch (Zend_Date_Exception
$e) {
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);
1428 $date->set('noday', Zend_Date
::YEAR
);
1430 } catch (Zend_Date_Exception
$e) {
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);
1460 $date->set('noday', Zend_Date
::YEAR_SHORT
);
1462 } catch (Zend_Date_Exception
$e) {
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);
1492 $date->set('noday', Zend_Date
::YEAR_SHORT_8601
);
1494 } catch (Zend_Date_Exception
$e) {
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);
1524 $date->set('noday', Zend_Date
::MERIDIEM
);
1526 } catch (Zend_Date_Exception
$e) {
1530 $date->set(1234567890);
1532 $date->set('noday', Zend_Date
::SWATCH
);
1534 } catch (Zend_Date_Exception
$e) {
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);
1564 $date->set('noday', Zend_Date
::HOUR_SHORT_AM
);
1566 } catch (Zend_Date_Exception
$e) {
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);
1596 $date->set('noday', Zend_Date
::HOUR_SHORT
);
1598 } catch (Zend_Date_Exception
$e) {
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);
1628 $date->set('noday', Zend_Date
::HOUR_AM
);
1630 } catch (Zend_Date_Exception
$e) {
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);
1660 $date->set('noday', Zend_Date
::HOUR
);
1662 } catch (Zend_Date_Exception
$e) {
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);
1692 $date->set('noday', Zend_Date
::MINUTE
);
1694 } catch (Zend_Date_Exception
$e) {
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);
1724 $date->set('noday', Zend_Date
::MINUTE_SHORT
);
1726 } catch (Zend_Date_Exception
$e) {
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);
1756 $date->set('noday', Zend_Date
::SECOND
);
1758 } catch (Zend_Date_Exception
$e) {
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);
1788 $date->set('noday', Zend_Date
::SECOND_SHORT
);
1790 } catch (Zend_Date_Exception
$e) {
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);
1820 $date->set('noday', Zend_Date
::MILLISECOND
);
1822 } catch (Zend_Date_Exception
$e) {
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);
1848 $date->set('noday', Zend_Date
::TIMEZONE_NAME
);
1850 } catch (Zend_Date_Exception
$e) {
1854 $date->set(1234567890);
1856 $date->set('noday', Zend_Date
::DAYLIGHT
);
1858 } catch (Zend_Date_Exception
$e) {
1862 $date->set(1234567890);
1864 $date->set('noday', Zend_Date
::GMT_DIFF
);
1866 } catch (Zend_Date_Exception
$e) {
1870 $date->set(1234567890);
1872 $date->set('noday', Zend_Date
::GMT_DIFF_SEP
);
1874 } catch (Zend_Date_Exception
$e) {
1878 $date->set(1234567890);
1880 $date->set('noday', Zend_Date
::TIMEZONE
);
1882 } catch (Zend_Date_Exception
$e) {
1886 $date->set(1234567890);
1888 $date->set('noday', Zend_Date
::TIMEZONE_SECS
);
1890 } catch (Zend_Date_Exception
$e) {
1894 $date->set(1234567890);
1896 $date->set('noday', Zend_Date
::ISO_8601
);
1898 } catch (Zend_Date_Exception
$e) {
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);
1980 $date->set('noday', Zend_Date
::RFC_2822
);
1982 } catch (Zend_Date_Exception
$e) {
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);
2025 $date->set('Thu, 05 Fxx 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2027 } catch (Zend_Date_Exception
$e) {
2031 $date->set(1234567890);
2033 $date->set('noday', Zend_Date
::TIMESTAMP
);
2035 } catch (Zend_Date_Exception
$e) {
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);
2046 $date->set('noday', Zend_Date
::ERA
);
2048 } catch (Zend_Date_Exception
$e) {
2052 $date->set(1234567890);
2054 $date->set('noday', Zend_Date
::ERA_NAME
);
2056 } catch (Zend_Date_Exception
$e) {
2060 $date->set(1234567890);
2062 $date->set('noday', Zend_Date
::DATES
);
2064 } catch (Zend_Date_Exception
$e) {
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);
2075 $date->set('noday', Zend_Date
::DATE_FULL
);
2077 } catch (Zend_Date_Exception
$e) {
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);
2088 $date->set('noday', Zend_Date
::DATE_LONG
);
2090 } catch (Zend_Date_Exception
$e) {
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);
2101 $date->set('noday', Zend_Date
::DATE_MEDIUM
);
2103 } catch (Zend_Date_Exception
$e) {
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);
2114 $date->set('noday', Zend_Date
::DATE_SHORT
);
2116 } catch (Zend_Date_Exception
$e) {
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);
2127 $date->set('noday', Zend_Date
::TIMES
);
2129 } catch (Zend_Date_Exception
$e) {
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);
2140 $date->set('noday', Zend_Date
::TIME_FULL
);
2142 } catch (Zend_Date_Exception
$e) {
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);
2153 $date->set('noday', Zend_Date
::TIME_LONG
);
2155 } catch (Zend_Date_Exception
$e) {
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);
2167 $date->set('noday', Zend_Date
::TIME_MEDIUM
);
2169 } catch (Zend_Date_Exception
$e) {
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);
2180 $date->set('noday', Zend_Date
::TIME_SHORT
);
2182 } catch (Zend_Date_Exception
$e) {
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);
2193 $date->set('noday', Zend_Date
::DATETIME
);
2195 } catch (Zend_Date_Exception
$e) {
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);
2206 $date->set('noday', Zend_Date
::DATETIME_FULL
);
2208 } catch (Zend_Date_Exception
$e) {
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);
2219 $date->set('noday', Zend_Date
::DATETIME_LONG
);
2221 } catch (Zend_Date_Exception
$e) {
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);
2232 $date->set('noday', Zend_Date
::DATETIME_MEDIUM
);
2234 } catch (Zend_Date_Exception
$e) {
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);
2245 $date->set('noday', Zend_Date
::DATETIME_SHORT
);
2247 } catch (Zend_Date_Exception
$e) {
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);
2258 $date->set('noday', Zend_Date
::ATOM
);
2260 } catch (Zend_Date_Exception
$e) {
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);
2271 $date->set('noday', Zend_Date
::COOKIE
);
2273 } catch (Zend_Date_Exception
$e) {
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);
2284 $date->set('noday', Zend_Date
::RFC_822
);
2286 } catch (Zend_Date_Exception
$e) {
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);
2297 $date->set('noday', Zend_Date
::RFC_850
);
2299 } catch (Zend_Date_Exception
$e) {
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);
2310 $date->set('noday', Zend_Date
::RFC_1036
);
2312 } catch (Zend_Date_Exception
$e) {
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);
2323 $date->set('noday', Zend_Date
::RFC_1123
);
2325 } catch (Zend_Date_Exception
$e) {
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);
2336 $date->set('noday', Zend_Date
::RFC_3339
);
2338 } catch (Zend_Date_Exception
$e) {
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);
2349 $date->set('noday', Zend_Date
::RSS
);
2351 } catch (Zend_Date_Exception
$e) {
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);
2368 $date->set('noday', Zend_Date
::W3C
);
2370 } catch (Zend_Date_Exception
$e) {
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);
2384 $date->set('noday', 'xx');
2386 } catch (Zend_Date_Exception
$e) {
2390 $date->set($d2, 'xx');
2392 } catch (Zend_Date_Exception
$e) {
2395 $date->set(1234567890);
2396 $date->set('1000', 'xx');
2397 $this->assertSame('1970-01-01T05:16:40+05:00', $date->get(Zend_Date
::W3C
));
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');
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
));
2422 $date->add('Mon', Zend_Date
::WEEKDAY_SHORT
);
2423 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2432 $date->add('Montag', Zend_Date
::WEEKDAY
);
2433 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2436 $date->add(1, Zend_Date
::WEEKDAY_8601
);
2437 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2441 $date->add($d2, Zend_Date
::DAY_SUFFIX
);
2442 $this->fail('exception expected');
2443 } catch (Zend_Date_Exception
$e) {
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');
2459 $locale = new Zend_Locale('de_AT');
2460 $date = new Zend_Date(0,null,$locale);
2461 $d2 = new Zend_Date(1010101010,null,$locale);
2464 $date->add(1, Zend_Date
::WEEKDAY_DIGIT
);
2465 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2474 $date->add('M', Zend_Date
::WEEKDAY_NARROW
);
2475 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2478 $date->add('Mo.', Zend_Date
::WEEKDAY_NAME
);
2479 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2488 $date->add('April', Zend_Date
::MONTH_NAME
);
2489 $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2498 $date->add('Apr', Zend_Date
::MONTH_NAME_SHORT
);
2499 $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2509 $date->add($d2, Zend_Date
::MONTH_DAYS
);
2510 $this->fail('exception expected');
2511 } catch (Zend_Date_Exception
$e) {
2516 $date->add('M', Zend_Date
::MONTH_NAME_NARROW
);
2517 $this->assertSame('2002-06-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2521 $date->add($d2, Zend_Date
::LEAPYEAR
);
2522 $this->fail('exception expected');
2523 } catch (Zend_Date_Exception
$e) {
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
));
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
));
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
));
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
));
2553 $date->add('noday', Zend_Date
::MERIDIEM
);
2555 } catch (Zend_Date_Exception
$e) {
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
2621 $date->add('noday', Zend_Date
::TIMEZONE_NAME
);
2623 } catch (Zend_Date_Exception
$e) {
2629 $date->add('noday', Zend_Date
::DAYLIGHT
);
2631 } catch (Zend_Date_Exception
$e) {
2637 $date->add('noday', Zend_Date
::GMT_DIFF
);
2639 } catch (Zend_Date_Exception
$e) {
2645 $date->add('noday', Zend_Date
::GMT_DIFF_SEP
);
2647 } catch (Zend_Date_Exception
$e) {
2653 $date->add('noday', Zend_Date
::TIMEZONE
);
2655 } catch (Zend_Date_Exception
$e) {
2661 $date->add('noday', Zend_Date
::TIMEZONE_SECS
);
2663 } catch (Zend_Date_Exception
$e) {
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
));
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
));
2676 $date->add(10, Zend_Date
::TIMESTAMP
);
2677 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
2681 $date->add('noday', Zend_Date
::ERA
);
2683 } catch (Zend_Date_Exception
$e) {
2689 $date->add('noday', Zend_Date
::ERA_NAME
);
2691 } catch (Zend_Date_Exception
$e) {
2696 $date->add('10.02.0005', Zend_Date
::DATES
);
2697 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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
));
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
));
2716 $date->add('10:05:05', Zend_Date
::TIMES
);
2717 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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
));
2732 $date->add('10:05', Zend_Date
::TIME_SHORT
);
2733 $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
2792 $date->add('1000', 'xx');
2793 $this->assertSame('2002-01-04T04:53:30+05:00', $date->get(Zend_Date
::W3C
));
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));
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
));
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');
2828 $locale = new Zend_Locale('de_AT');
2829 $date = new Zend_Date(0,null,$locale);
2830 $d2 = new Zend_Date(1010101010,null,$locale);
2833 $date->sub('Mon', Zend_Date
::WEEKDAY_SHORT
);
2834 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2843 $date->sub('Montag', Zend_Date
::WEEKDAY
);
2844 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2847 $date->sub(1, Zend_Date
::WEEKDAY_8601
);
2848 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2852 $date->sub($d2, Zend_Date
::DAY_SUFFIX
);
2853 $this->fail('exception expected');
2854 } catch (Zend_Date_Exception
$e) {
2859 $date->sub(1, Zend_Date
::WEEKDAY_DIGIT
);
2860 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2869 $date->sub('M', Zend_Date
::WEEKDAY_NARROW
);
2870 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2873 $date->sub('Mo.', Zend_Date
::WEEKDAY_NAME
);
2874 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2883 $date->sub('April', Zend_Date
::MONTH_NAME
);
2884 $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2893 $date->sub('Apr', Zend_Date
::MONTH_NAME_SHORT
);
2894 $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
2904 $date->sub($d2, Zend_Date
::MONTH_DAYS
);
2905 $this->fail('exception expected');
2906 } catch (Zend_Date_Exception
$e) {
2911 $date->sub('M', Zend_Date
::MONTH_NAME_NARROW
);
2912 $this->assertSame('2001-10-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2916 $date->sub($d2, Zend_Date
::LEAPYEAR
);
2917 $this->fail('exception expected');
2918 } catch (Zend_Date_Exception
$e) {
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
));
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
));
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
));
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
));
2948 $date->sub('noday', Zend_Date
::MERIDIEM
);
2950 } catch (Zend_Date_Exception
$e) {
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
3016 $date->sub('noday', Zend_Date
::TIMEZONE_NAME
);
3018 } catch (Zend_Date_Exception
$e) {
3024 $date->sub('noday', Zend_Date
::DAYLIGHT
);
3026 } catch (Zend_Date_Exception
$e) {
3032 $date->sub('noday', Zend_Date
::GMT_DIFF
);
3034 } catch (Zend_Date_Exception
$e) {
3040 $date->sub('noday', Zend_Date
::GMT_DIFF_SEP
);
3042 } catch (Zend_Date_Exception
$e) {
3048 $date->sub('noday', Zend_Date
::TIMEZONE
);
3050 } catch (Zend_Date_Exception
$e) {
3056 $date->sub('noday', Zend_Date
::TIMEZONE_SECS
);
3058 } catch (Zend_Date_Exception
$e) {
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
));
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
));
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
));
3074 $date->sub(-10, Zend_Date
::TIMESTAMP
);
3075 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
3079 $date->sub('noday', Zend_Date
::ERA
);
3081 } catch (Zend_Date_Exception
$e) {
3087 $date->sub('noday', Zend_Date
::ERA_NAME
);
3089 } catch (Zend_Date_Exception
$e) {
3094 $date->sub('10.02.0005', Zend_Date
::DATES
);
3095 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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
));
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
));
3114 $date->sub('10:05:05', Zend_Date
::TIMES
);
3115 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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
));
3130 $date->sub('10:05', Zend_Date
::TIME_SHORT
);
3131 $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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
));
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
));
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
));
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
));
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
) );
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
));
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
));
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
));
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
));
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
));
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
));
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
));
3190 $date->sub('1000', 'xx');
3191 $this->assertSame('2002-01-04T04:20:10+05:00', $date->get(Zend_Date
::W3C
));
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
));
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());
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
));
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));
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));
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
));
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));
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
));
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
));
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");
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
));
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 ));
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--) {
3423 $hour = '0' . $hour;
3425 $this->assertSame("2009-02-14T$hour:31:30+05:00", $date->get(Zend_Date
::W3C
));
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
));
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
));
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');
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
));
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');
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');
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 ));
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);
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
));
3576 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date
::W3C
));
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
);
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');
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);
3616 $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date
::W3C
));
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
);
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');
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);
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');
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 ));
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);
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
));
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');
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);
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');
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');
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
));
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
));
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
));
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
));
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
));
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
));
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
));
3853 $result = array('longitude' => 0);
3855 $result = $date->getSunrise($result);
3857 } catch (Zend_Date_Exception
$e) {
3862 $result = array('latitude' => 0);
3864 $result = $date->getSunrise($result);
3866 } catch (Zend_Date_Exception
$e) {
3871 $result = array('longitude' => 180.1, 'latitude' => 0);
3873 $result = $date->getSunrise($result);
3875 } catch (Zend_Date_Exception
$e) {
3880 $result = array('longitude' => -180.1, 'latitude' => 0);
3882 $result = $date->getSunrise($result);
3884 } catch (Zend_Date_Exception
$e) {
3889 $result = array('longitude' => 0, 'latitude' => 90.1);
3891 $result = $date->getSunrise($result);
3893 } catch (Zend_Date_Exception
$e) {
3898 $result = array('longitude' => 0, 'latitude' => -90.1);
3900 $result = $date->getSunrise($result);
3902 } catch (Zend_Date_Exception
$e) {
3907 $result = array('latitude' => 0, 'longitude' => 0);
3908 $result = $date->getSunInfo($result);
3909 $this->assertTrue(is_array($result));
3912 $result = array('latitude' => 0, 'longitude' => 0);
3913 $result = $date->getSunrise($result);
3914 $this->assertTrue($result instanceof Zend_Date
);
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);
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) {
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);
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());
3960 $date = new Zend_Date('01.01.2004', Zend_Date
::DATES
, $locale);
3961 $this->assertTrue($date->isLeapYear());
3964 $result = Zend_Date
::checkLeapYear('noyear');
3965 $this->fail('exception expected');
3966 } catch (Zend_Date_Exception
$e) {
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);
3995 $this->assertFalse($d2->isYesterday());
3996 $this->assertTrue($date->isYesterday());
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);
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());
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);
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());
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
));
4105 $date->setYear('noyear');
4107 } catch (Zend_Date_Exception
$e) {
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');
4122 $locale = new Zend_Locale('de_AT');
4124 $date = new Zend_Date(1577833200,$locale);
4125 $date->setTimeZone(date_default_timezone_get());
4128 $this->assertSame('2021-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4130 $this->assertSame('2022-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4132 $this->assertSame('2023-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4134 $this->assertSame('2024-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
4146 $this->assertSame('2120-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4150 $date->setYear(2020);
4151 $this->assertSame('2020-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4153 $this->assertSame('2021-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4155 $this->assertSame('2022-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4157 $this->assertSame('2023-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4159 $this->assertSame('2024-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
4171 $this->assertSame('2120-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
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');
4184 $locale = new Zend_Locale('de_AT');
4186 $date = new Zend_Date(1577833200,$locale);
4187 $date->setTimeZone(date_default_timezone_get());
4190 $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4192 $this->assertSame('2018-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4194 $this->assertSame('2017-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4196 $this->assertSame('2016-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
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
));
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
));
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 ));
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());
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());
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
));
4269 $date->setMonth('nomonth');
4271 } catch (Zend_Date_Exception
$e) {
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());
4288 $this->assertSame('2020-02-01T00:00:00+01:00', $date->get(Zend_Date
::W3C
));
4290 $this->assertSame('2020-03-01T00:00:00+01:00', $date->get(Zend_Date
::W3C
));
4292 $this->assertSame('2020-04-01T00:00:00+02:00', $date->get(Zend_Date
::W3C
));
4294 $this->assertSame('2020-05-01T00:00:00+02:00', $date->get(Zend_Date
::W3C
));
4296 $this->assertSame('2020-06-01T00:00:00+02:00', $date->get(Zend_Date
::W3C
));
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'));
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'));
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'));
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'));
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'));
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'));
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'));
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'));
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'));
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));
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
));
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());
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());
4407 public function testGetWeek()
4409 $locale = new Zend_Locale('de_AT');
4410 $date = new Zend_Date(1168293600, $locale);
4414 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4418 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4422 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4426 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4429 $date->addTime('05:30:00');
4430 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4434 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
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]
4446 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4450 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
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());
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());
4508 $date->setLocale('xx_XX');
4510 } catch (Zend_Date_Exception
$e) {
4516 * test looseBehaviour
4518 public function testLoose()
4520 $date = new Zend_Date(0, 'de_DE');
4523 $date->set(null, Zend_Date
::YEAR
);
4525 } catch (Zend_Date_Exception
$e) {
4529 $date->set(10, 'de_DE');
4530 $this->assertEquals(10, $date->getTimestamp());
4533 $date->add(null, Zend_Date
::YEAR
);
4535 } catch (Zend_Date_Exception
$e) {
4539 $date->add(10, 'de_DE');
4540 $this->assertEquals(20, $date->getTimestamp());
4543 $date->sub(null, Zend_Date
::YEAR
);
4545 } catch (Zend_Date_Exception
$e) {
4549 $date->sub(10, 'de_DE');
4550 $this->assertEquals(10, $date->getTimestamp());
4553 $date->compare(null, Zend_Date
::YEAR
);
4555 } catch (Zend_Date_Exception
$e) {
4560 $date->equals(null, Zend_Date
::YEAR
);
4562 } catch (Zend_Date_Exception
$e) {
4567 $date->isEarlier(null, Zend_Date
::YEAR
);
4569 } catch (Zend_Date_Exception
$e) {
4574 $date->isLater(null, Zend_Date
::YEAR
);
4576 } catch (Zend_Date_Exception
$e) {
4581 $date->setTime(null);
4583 } catch (Zend_Date_Exception
$e) {
4588 $date->addTime(null);
4590 } catch (Zend_Date_Exception
$e) {
4595 $date->subTime(null);
4597 } catch (Zend_Date_Exception
$e) {
4602 $date->compareTime(null);
4604 } catch (Zend_Date_Exception
$e) {
4609 $date->setDate(null);
4611 } catch (Zend_Date_Exception
$e) {
4616 $date->addDate(null);
4618 } catch (Zend_Date_Exception
$e) {
4623 $date->subDate(null);
4625 } catch (Zend_Date_Exception
$e) {
4630 $date->compareDate(null);
4632 } catch (Zend_Date_Exception
$e) {
4637 $date->setIso(null);
4639 } catch (Zend_Date_Exception
$e) {
4644 $date->addIso(null);
4646 } catch (Zend_Date_Exception
$e) {
4651 $date->subIso(null);
4653 } catch (Zend_Date_Exception
$e) {
4658 $date->compareIso(null);
4660 } catch (Zend_Date_Exception
$e) {
4665 $date->setArpa(null);
4667 } catch (Zend_Date_Exception
$e) {
4672 $date->addArpa(null);
4674 } catch (Zend_Date_Exception
$e) {
4679 $date->subArpa(null);
4681 } catch (Zend_Date_Exception
$e) {
4686 $date->compareArpa(null);
4688 } catch (Zend_Date_Exception
$e) {
4693 $date->setYear(null);
4695 } catch (Zend_Date_Exception
$e) {
4700 $date->addYear(null);
4702 } catch (Zend_Date_Exception
$e) {
4707 $date->subYear(null);
4709 } catch (Zend_Date_Exception
$e) {
4714 $date->compareYear(null);
4716 } catch (Zend_Date_Exception
$e) {
4721 $date->setMonth(null);
4723 } catch (Zend_Date_Exception
$e) {
4728 $date->addMonth(null);
4730 } catch (Zend_Date_Exception
$e) {
4735 $date->subMonth(null);
4737 } catch (Zend_Date_Exception
$e) {
4742 $date->compareMonth(null);
4744 } catch (Zend_Date_Exception
$e) {
4749 $date->setDay(null);
4751 } catch (Zend_Date_Exception
$e) {
4756 $date->addDay(null);
4758 } catch (Zend_Date_Exception
$e) {
4763 $date->subDay(null);
4765 } catch (Zend_Date_Exception
$e) {
4770 $date->compareDay(null);
4772 } catch (Zend_Date_Exception
$e) {
4777 $date->setWeekday(null);
4779 } catch (Zend_Date_Exception
$e) {
4784 $date->addWeekday(null);
4786 } catch (Zend_Date_Exception
$e) {
4791 $date->subWeekday(null);
4793 } catch (Zend_Date_Exception
$e) {
4798 $date->compareWeekday(null);
4800 } catch (Zend_Date_Exception
$e) {
4805 $date->setDayOfYear(null);
4807 } catch (Zend_Date_Exception
$e) {
4812 $date->addDayOfYear(null);
4814 } catch (Zend_Date_Exception
$e) {
4819 $date->subDayOfYear(null);
4821 } catch (Zend_Date_Exception
$e) {
4826 $date->compareDayOfYear(null);
4828 } catch (Zend_Date_Exception
$e) {
4833 $date->setHour(null);
4835 } catch (Zend_Date_Exception
$e) {
4840 $date->addHour(null);
4842 } catch (Zend_Date_Exception
$e) {
4847 $date->subHour(null);
4849 } catch (Zend_Date_Exception
$e) {
4854 $date->compareHour(null);
4856 } catch (Zend_Date_Exception
$e) {
4861 $date->setMinute(null);
4863 } catch (Zend_Date_Exception
$e) {
4868 $date->addMinute(null);
4870 } catch (Zend_Date_Exception
$e) {
4875 $date->subMinute(null);
4877 } catch (Zend_Date_Exception
$e) {
4882 $date->compareMinute(null);
4884 } catch (Zend_Date_Exception
$e) {
4889 $date->setSecond(null);
4891 } catch (Zend_Date_Exception
$e) {
4896 $date->addSecond(null);
4898 } catch (Zend_Date_Exception
$e) {
4903 $date->subSecond(null);
4905 } catch (Zend_Date_Exception
$e) {
4910 $date->compareSecond(null);
4912 } catch (Zend_Date_Exception
$e) {
4917 $date->setWeek(null);
4919 } catch (Zend_Date_Exception
$e) {
4924 $date->addWeek(null);
4926 } catch (Zend_Date_Exception
$e) {
4931 $date->subWeek(null);
4933 } catch (Zend_Date_Exception
$e) {
4938 $date->compareWeek(null);
4940 } catch (Zend_Date_Exception
$e) {
4945 public function testTimesync()
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());
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']);
5197 Zend_Date
::setOptions(array('format_type' => 'non'));
5199 } catch (Zend_Date_Exception
$e) {
5204 Zend_Date
::setOptions(array('unknown' => 'non'));
5206 } catch (Zend_Date_Exception
$e) {
5210 Zend_Date
::setOptions(array('fix_dst' => 2));
5212 } catch (Zend_Date_Exception
$e) {
5217 Zend_Date
::setOptions(array('fix_dst' => 2));
5219 } catch (Zend_Date_Exception
$e) {
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));
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());
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());
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');
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');
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);
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
));
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
));
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);
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
));
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"));
5469 public function testSetArrayDateWithoutHour()
5471 $date = new Zend_Date(array(
5476 $this->assertEquals('2008-03-01T00:00:00+05:00', $date->getIso());
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());
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'));
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) {
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);