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-2010 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-2010 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;
65 private $_orig = array();
67 public function setUp()
69 $this->originalTimezone
= date_default_timezone_get();
70 date_default_timezone_set('Indian/Maldives');
71 require_once 'Zend/Cache.php';
72 $this->_cache
= Zend_Cache
::factory('Core', 'File',
73 array('lifetime' => 120, 'automatic_serialization' => true),
74 array('cache_dir' => dirname(__FILE__
) . '/_files/'));
75 $this->_orig
= Zend_Date
::setOptions();
77 Zend_Date
::setOptions(array('cache' => $this->_cache
));
78 Zend_Date
::setOptions(array('fix_dst' => true));
79 Zend_Date
::setOptions(array('extend_month' => false));
80 Zend_Date
::setOptions(array('format_type' => 'iso'));
83 public function tearDown()
85 Zend_Date
::setOptions($this->_orig
);
86 $this->_cache
->clean(Zend_Cache
::CLEANING_MODE_ALL
);
87 date_default_timezone_set($this->originalTimezone
);
91 * Test for date object creation
93 public function testCreation()
95 // look if locale is detectable
97 $locale = new Zend_Locale();
98 } catch (Zend_Locale_Exception
$e) {
99 $this->markTestSkipped('Autodetection of locale failed');
103 $date = new Zend_Date(0);
104 $this->assertTrue($date instanceof Zend_Date
);
108 * Test for date object creation using default format for a locale
110 public function testCreationDefaultFormat()
112 // look if locale is detectable
114 $locale = new Zend_Locale();
115 } catch (Zend_Locale_Exception
$e) {
116 $this->markTestSkipped('Autodetection of locale failed');
120 $date = new Zend_Date('2006-01-01');
121 $this->assertTrue($date instanceof Zend_Date
);
122 $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Zend_Date
::ISO_8601
));
124 $date = new Zend_Date('2006-01-01', 'en_US');
125 $this->assertTrue($date instanceof Zend_Date
);
126 $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Zend_Date
::ISO_8601
));
130 * Test for date object creation using default format for a locale
132 public function testCreationDefaultFormatConsistency()
134 // look if locale is detectable
136 $locale = new Zend_Locale();
137 } catch (Zend_Locale_Exception
$e) {
138 $this->markTestSkipped('Autodetection of locale failed');
142 date_default_timezone_set('America/New_York');
144 //2006-01-01T00:00:00+05:00
145 $date1 = new Zend_Date('2006-01-01 01:00:00', Zend_Date
::ISO_8601
, $locale);
146 $date1string = $date1->get(Zend_Date
::ISO_8601
);
148 // en_US defines AM/PM, hour 0 does not exist
149 // ISO defines dates without AM, 0 exists instead of 12 PM
150 // therefor hour is set to 1 to verify
151 $date2 = new Zend_Date('2006-01-01', Zend_Date
::DATES
, $locale);
152 $date2->setTime('01:00:00');
153 $this->assertSame($date1string, $date2->get(Zend_Date
::ISO_8601
));
154 $date2 = new Zend_Date('01-01-2006', Zend_Date
::DATES
, $locale);
155 $date2->setTime('01:00:00');
156 $this->assertSame($date1string, $date2->get(Zend_Date
::ISO_8601
));
157 $date2 = new Zend_Date('2006-01-01', null, $locale);
158 $date2->setTime('01:00:00');
159 $this->assertSame($date1string, $date2->get(Zend_Date
::ISO_8601
));
160 $date2 = new Zend_Date('2006-01-01');
161 $date2->setTime('01:00:00');
162 $this->assertSame($date1string, $date2->get(Zend_Date
::ISO_8601
));
163 $date2 = new Zend_Date('2006-01-01 01:00:00');
164 $this->assertSame($date1string, $date2->get(Zend_Date
::ISO_8601
));
168 * Test for creation with timestamp
170 public function testCreationTimestamp()
172 // look if locale is detectable
174 $locale = new Zend_Locale();
175 } catch (Zend_Locale_Exception
$e) {
176 $this->markTestSkipped('Autodetection of locale failed');
180 $date = new Zend_Date('12345678');
181 $this->assertTrue($date instanceof Zend_Date
);
185 * Test for creation but only part of date
187 public function testCreationDatePart()
189 // look if locale is detectable
191 $locale = new Zend_Locale();
192 } catch (Zend_Locale_Exception
$e) {
193 $this->markTestSkipped('Autodetection of locale failed');
197 $date = new Zend_Date('13',Zend_Date
::HOUR
);
198 $this->assertTrue($date instanceof Zend_Date
);
200 $date = new Zend_Date('20070802', 'YYYYMMdd');
201 $this->assertSame("2007-08-02T00:00:00+05:00", $date->getIso());
205 * Test for creation but only a defined locale
207 public function testCreationLocale()
209 $locale = new Zend_Locale('de_AT');
210 $date = new Zend_Date('13',null,$locale);
211 $this->assertTrue($date instanceof Zend_Date
);
215 * Test for creation but only part of date with locale
217 public function testCreationLocalePart()
219 $locale = new Zend_Locale('de_AT');
220 $date = new Zend_Date('13',Zend_Date
::HOUR
,$locale);
221 $this->assertTrue($date instanceof Zend_Date
);
225 * Test for date object creation using default format for a locale
227 public function testCreationDefaultLoose()
229 // look if locale is detectable
231 $locale = new Zend_Locale();
232 } catch (Zend_Locale_Exception
$e) {
233 $this->markTestSkipped('Autodetection of locale failed');
238 $date = new Zend_Date();
240 $date = $date->getTimestamp();
241 $this->assertTrue(abs($date - time()) < 2);
243 date_default_timezone_set('GMT');
244 $date = new Zend_Date(Zend_Date
::YEAR
);
246 $date = $date->getTimestamp();
247 $reference = gmmktime(0,0,0,1,1,date('Y'));
248 $this->assertTrue($reference == $date);
250 $date = new Zend_Date('ar_EG');
251 $this->assertSame('ar_EG', $date->getLocale());
252 $date = $date->getTimestamp();
253 $this->assertTrue(abs($date - time()) < 2);
257 * Test for getTimestamp
259 public function testGetTimestamp()
261 $locale = new Zend_Locale('de_AT');
262 $date = new Zend_Date(10000000);
263 $this->assertSame(10000000, $date->getTimestamp());
267 * Test for getUnixTimestamp
269 public function testgetUnixTimestamp2()
271 $locale = new Zend_Locale('de_AT');
272 $date = new Zend_Date(-100000000);
273 $this->assertSame(-100000000, $date->getTimestamp());
277 * Test for setTimestamp
279 public function testSetTimestamp()
281 $locale = new Zend_Locale('de_AT');
282 $date = new Zend_Date(0,Zend_Date
::TIMESTAMP
,$locale);
283 $result = $date->setTimestamp(10000000);
284 $this->assertSame('10000000', (string)$result->getTimestamp());
288 * Test for setTimestamp
290 public function testSetTimestamp2()
293 $locale = new Zend_Locale('de_AT');
294 $date = new Zend_Date(0,null,$locale);
295 $result = $date->setTimestamp('notimestamp');
296 $this->Fail("exception expected");
297 } catch (Zend_Date_Exception
$e) {
303 * Test for addTimestamp
305 public function testAddTimestamp()
307 $locale = new Zend_Locale('de_AT');
308 $date = new Zend_Date(0,null,$locale);
309 $result = $date->addTimestamp(10000000);
310 $this->assertSame('10000000', (string)$result->getTimestamp());
312 $result = $date->addTimestamp(array('timestamp' => 1000));
313 $this->assertSame('10001000', (string)$result->getTimestamp());
316 $result = $date->addTimestamp(array('notimestamp' => 1000));
317 $this->fail("exception expected");
318 } catch (Zend_Date_Exception
$e) {
324 * Test for addTimestamp
326 public function testAddTimestamp2()
329 $locale = new Zend_Locale('de_AT');
330 $date = new Zend_Date(0,null,$locale);
331 $result = $date->addTimestamp('notimestamp');
332 $this->fail("exception expected");
333 } catch (Zend_Date_Exception
$e) {
339 * Test for subTimestamp
341 public function testSubTimestamp()
343 $locale = new Zend_Locale('de_AT');
344 $date = new Zend_Date(0,null,$locale);
345 $result = $date->subTimestamp(10000000);
346 $this->assertSame('-10000000', (string)$result->getTimestamp());
350 * Test for subTimestamp
352 public function testSubTimestamp2()
355 $locale = new Zend_Locale('de_AT');
356 $date = new Zend_Date(0,null,$locale);
357 $result = $date->subTimestamp('notimestamp');
358 $this->fail("exception expected");
359 } catch (Zend_Date_Exception
$e) {
365 * Test for compareTimestamp
367 public function testCompareTimestamp()
369 $locale = new Zend_Locale('de_AT');
370 $date1 = new Zend_Date(0,null,$locale);
371 $date2 = new Zend_Date(0,null,$locale);
372 $this->assertSame(0, $date1->compareTimestamp($date2));
374 $date2 = new Zend_Date(100,null,$locale);
375 $this->assertSame(-1, $date1->compareTimestamp($date2));
377 $date2 = new Zend_Date(-100,null,$locale);
378 $this->assertSame(1, $date1->compareTimestamp($date2));
382 * Test for __toString
384 public function test_ToString()
386 $locale = new Zend_Locale('de_AT');
387 $date = new Zend_Date(0,null,$locale);
388 $date->setTimezone(date_default_timezone_get());
389 $this->assertSame('01.01.1970 05:00:00', $date->__toString());
395 public function testToString()
397 $locale = new Zend_Locale('de_AT');
398 $date = new Zend_Date(1234567890,null,$locale);
399 $date->setTimezone(date_default_timezone_get());
400 $this->assertSame('14.02.2009 04:31:30', $date->toString( ));
401 $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString('en_US' ));
402 $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString(null, 'en_US'));
403 $this->assertSame('2009', $date->toString('yyy', null ));
404 $this->assertSame('14.02.2009 04:31:30', $date->toString(null, null ));
406 $date->setTimeZone('UTC');
407 $this->assertSame('Feb 13, 2009 11:31:30 PM', $date->toString(null, 'en_US'));
409 $date->setTimeZone('Indian/Maldives');
410 $this->assertSame( "xxyy'yyxx", $date->toString("xx'yy''yy'xx"));
411 $this->assertSame( 'n.', $date->toString("GGGGG"));
412 $this->assertSame( 'n. Chr.', $date->toString( "GGGG"));
413 $this->assertSame( 'n. Chr.', $date->toString( "GGG"));
414 $this->assertSame( 'n. Chr.', $date->toString( "GG"));
415 $this->assertSame( 'n. Chr.', $date->toString( "G"));
416 $this->assertSame( '02009', $date->toString("yyyyy"));
417 $this->assertSame( '2009', $date->toString( "yyyy"));
418 $this->assertSame( '2009', $date->toString( "yyy"));
419 $this->assertSame( '09', $date->toString( "yy"));
420 $this->assertSame( '2009', $date->toString( "y"));
421 $this->assertSame( '02009', $date->toString("YYYYY"));
422 $this->assertSame( '2009', $date->toString( "YYYY"));
423 $this->assertSame( '2009', $date->toString( "YYY"));
424 $this->assertSame( '09', $date->toString( "YY"));
425 $this->assertSame( '2009', $date->toString( "Y"));
426 $this->assertSame( 'F', $date->toString("MMMMM"));
427 $this->assertSame( 'Februar', $date->toString( "MMMM"));
428 $this->assertSame( 'Feb', $date->toString( "MMM"));
429 $this->assertSame( '02', $date->toString( "MM"));
430 $this->assertSame( '2', $date->toString( "M"));
431 $this->assertSame( '07', $date->toString( "ww"));
432 $this->assertSame( '7', $date->toString( "w"));
433 $this->assertSame( '14', $date->toString( "dd"));
434 $this->assertSame( '14', $date->toString( "d"));
435 $this->assertSame( '044', $date->toString( "DDD"));
436 $this->assertSame( '44', $date->toString( "DD"));
437 $this->assertSame( '44', $date->toString( "D"));
438 $this->assertSame( 'S', $date->toString("EEEEE"));
439 $this->assertSame( 'Samstag', $date->toString( "EEEE"));
440 $this->assertSame( 'Sam', $date->toString( "EEE"));
441 $this->assertSame( 'Sa.', $date->toString( "EE"));
442 $this->assertSame( 'S', $date->toString( "E"));
443 $this->assertSame( '06', $date->toString( "ee"));
444 $this->assertSame( '6', $date->toString( "e"));
445 $this->assertSame( 'vorm.', $date->toString( "a"));
446 $this->assertSame( '04', $date->toString( "hh"));
447 $this->assertSame( '4', $date->toString( "h"));
448 $this->assertSame( '04', $date->toString( "HH"));
449 $this->assertSame( '4', $date->toString( "H"));
450 $this->assertSame( '31', $date->toString( "mm"));
451 $this->assertSame( '31', $date->toString( "m"));
452 $this->assertSame( '30', $date->toString( "ss"));
453 $this->assertSame( '30', $date->toString( "s"));
454 $this->assertSame( '0', $date->toString( "S"));
455 $this->assertSame('Indian/Maldives', $date->toString( "zzzz"));
456 $this->assertSame( 'MVT', $date->toString( "zzz"));
457 $this->assertSame( 'MVT', $date->toString( "zz"));
458 $this->assertSame( 'MVT', $date->toString( "z"));
459 $this->assertSame( '+05:00', $date->toString( "ZZZZ"));
460 $this->assertSame( '+0500', $date->toString( "ZZZ"));
461 $this->assertSame( '+0500', $date->toString( "ZZ"));
462 $this->assertSame( '+0500', $date->toString( "Z"));
463 $this->assertSame( '16290000', $date->toString("AAAAA"));
464 $this->assertSame( '16290000', $date->toString( "AAAA"));
465 $this->assertSame( '16290000', $date->toString( "AAA"));
466 $this->assertSame( '16290000', $date->toString( "AA"));
467 $this->assertSame( '16290000', $date->toString( "A"));
469 $date = new Zend_Date("1-1-01",null,$locale);
470 $date->setTimezone(date_default_timezone_get());
471 $this->assertSame('01', $date->toString("yy"));
477 public function testToValue()
479 $locale = new Zend_Locale('de_AT');
480 $date = new Zend_Date(1234567890,null,$locale);
481 $date->setTimezone(date_default_timezone_get());
482 $this->assertSame(1234567890, $date->toValue() );
483 $this->assertSame( 14, $date->toValue(Zend_Date
::DAY
));
485 $date->setTimezone('UTC');
486 $this->assertSame( 13, $date->toValue(Zend_Date
::DAY
));
487 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY_SHORT
));
488 $this->assertSame( 13, $date->toValue(Zend_Date
::DAY_SHORT
));
489 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY
));
490 $this->assertSame( 5, $date->toValue(Zend_Date
::WEEKDAY_8601
));
491 $this->assertFalse( $date->toValue(Zend_Date
::DAY_SUFFIX
));
492 $this->assertSame( 5, $date->toValue(Zend_Date
::WEEKDAY_DIGIT
));
493 $this->assertSame( 43, $date->toValue(Zend_Date
::DAY_OF_YEAR
));
494 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY_NARROW
));
495 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY_NAME
));
496 $this->assertSame( 7, $date->toValue(Zend_Date
::WEEK
));
497 $this->assertFalse( $date->toValue(Zend_Date
::MONTH_NAME
));
498 $this->assertSame( 2, $date->toValue(Zend_Date
::MONTH
));
499 $this->assertFalse( $date->toValue(Zend_Date
::MONTH_NAME_SHORT
));
500 $this->assertSame( 2, $date->toValue(Zend_Date
::MONTH_SHORT
));
501 $this->assertSame( 28, $date->toValue(Zend_Date
::MONTH_DAYS
));
502 $this->assertFalse( $date->toValue(Zend_Date
::MONTH_NAME_NARROW
));
503 $this->assertSame( 0, $date->toValue(Zend_Date
::LEAPYEAR
));
504 $this->assertSame( 2009, $date->toValue(Zend_Date
::YEAR_8601
));
505 $this->assertSame( 2009, $date->toValue(Zend_Date
::YEAR
));
506 $this->assertSame( 9, $date->toValue(Zend_Date
::YEAR_SHORT
));
507 $this->assertSame( 9, $date->toValue(Zend_Date
::YEAR_SHORT_8601
));
508 $this->assertFalse( $date->toValue(Zend_Date
::MERIDIEM
));
509 $this->assertSame( 21, $date->toValue(Zend_Date
::SWATCH
));
510 $this->assertSame( 11, $date->toValue(Zend_Date
::HOUR_SHORT_AM
));
511 $this->assertSame( 23, $date->toValue(Zend_Date
::HOUR_SHORT
));
512 $this->assertSame( 11, $date->toValue(Zend_Date
::HOUR_AM
));
513 $this->assertSame( 23, $date->toValue(Zend_Date
::HOUR
));
514 $this->assertSame( 31, $date->toValue(Zend_Date
::MINUTE
));
515 $this->assertSame( 30, $date->toValue(Zend_Date
::SECOND
));
516 $this->assertSame( 0, $date->toValue(Zend_Date
::MILLISECOND
));
517 $this->assertSame( 31, $date->toValue(Zend_Date
::MINUTE_SHORT
));
518 $this->assertSame( 30, $date->toValue(Zend_Date
::SECOND_SHORT
));
519 $this->assertFalse( $date->toValue(Zend_Date
::TIMEZONE_NAME
));
520 $this->assertSame( 0, $date->toValue(Zend_Date
::DAYLIGHT
));
521 $this->assertSame( 0, $date->toValue(Zend_Date
::GMT_DIFF
));
522 $this->assertFalse( $date->toValue(Zend_Date
::GMT_DIFF_SEP
));
523 $this->assertFalse( $date->toValue(Zend_Date
::TIMEZONE
));
524 $this->assertSame( 0, $date->toValue(Zend_Date
::TIMEZONE_SECS
));
525 $this->assertFalse( $date->toValue(Zend_Date
::ISO_8601
));
526 $this->assertFalse( $date->toValue(Zend_Date
::RFC_2822
));
527 $this->assertSame(1234567890, $date->toValue(Zend_Date
::TIMESTAMP
));
528 $this->assertFalse( $date->toValue(Zend_Date
::ERA
));
529 $this->assertFalse( $date->toValue(Zend_Date
::ERA_NAME
));
530 $this->assertFalse( $date->toValue(Zend_Date
::DATES
));
531 $this->assertFalse( $date->toValue(Zend_Date
::DATE_FULL
));
532 $this->assertFalse( $date->toValue(Zend_Date
::DATE_LONG
));
533 $this->assertFalse( $date->toValue(Zend_Date
::DATE_MEDIUM
));
534 $this->assertFalse( $date->toValue(Zend_Date
::DATE_SHORT
));
535 $this->assertFalse( $date->toValue(Zend_Date
::TIMES
));
536 $this->assertFalse( $date->toValue(Zend_Date
::TIME_FULL
));
537 $this->assertFalse( $date->toValue(Zend_Date
::TIME_LONG
));
538 $this->assertFalse( $date->toValue(Zend_Date
::TIME_MEDIUM
));
539 $this->assertFalse( $date->toValue(Zend_Date
::TIME_SHORT
));
540 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME
));
541 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_FULL
));
542 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_LONG
));
543 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_MEDIUM
));
544 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_SHORT
));
545 $this->assertFalse( $date->toValue(Zend_Date
::ATOM
));
546 $this->assertFalse( $date->toValue(Zend_Date
::COOKIE
));
547 $this->assertFalse( $date->toValue(Zend_Date
::RFC_822
));
548 $this->assertFalse( $date->toValue(Zend_Date
::RFC_850
));
549 $this->assertFalse( $date->toValue(Zend_Date
::RFC_1036
));
550 $this->assertFalse( $date->toValue(Zend_Date
::RFC_1123
));
551 $this->assertFalse( $date->toValue(Zend_Date
::RFC_3339
));
552 $this->assertFalse( $date->toValue(Zend_Date
::RSS
));
553 $this->assertFalse( $date->toValue(Zend_Date
::W3C
));
555 $date->setTimezone('Indian/Maldives');
556 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY_SHORT
));
557 $this->assertSame( 14, $date->toValue(Zend_Date
::DAY_SHORT
));
558 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY
));
559 $this->assertSame( 6, $date->toValue(Zend_Date
::WEEKDAY_8601
));
560 $this->assertFalse( $date->toValue(Zend_Date
::DAY_SUFFIX
));
561 $this->assertSame( 6, $date->toValue(Zend_Date
::WEEKDAY_DIGIT
));
562 $this->assertSame( 44, $date->toValue(Zend_Date
::DAY_OF_YEAR
));
563 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY_NARROW
));
564 $this->assertFalse( $date->toValue(Zend_Date
::WEEKDAY_NAME
));
565 $this->assertSame( 7, $date->toValue(Zend_Date
::WEEK
));
566 $this->assertFalse( $date->toValue(Zend_Date
::MONTH_NAME
));
567 $this->assertSame( 2, $date->toValue(Zend_Date
::MONTH
));
568 $this->assertFalse( $date->toValue(Zend_Date
::MONTH_NAME_SHORT
));
569 $this->assertSame( 2, $date->toValue(Zend_Date
::MONTH_SHORT
));
570 $this->assertSame( 28, $date->toValue(Zend_Date
::MONTH_DAYS
));
571 $this->assertFalse( $date->toValue(Zend_Date
::MONTH_NAME_NARROW
));
572 $this->assertSame( 0, $date->toValue(Zend_Date
::LEAPYEAR
));
573 $this->assertSame( 2009, $date->toValue(Zend_Date
::YEAR_8601
));
574 $this->assertSame( 2009, $date->toValue(Zend_Date
::YEAR
));
575 $this->assertSame( 9, $date->toValue(Zend_Date
::YEAR_SHORT
));
576 $this->assertSame( 9, $date->toValue(Zend_Date
::YEAR_SHORT_8601
));
577 $this->assertFalse( $date->toValue(Zend_Date
::MERIDIEM
));
578 $this->assertSame( 21, $date->toValue(Zend_Date
::SWATCH
));
579 $this->assertSame( 4, $date->toValue(Zend_Date
::HOUR_SHORT_AM
));
580 $this->assertSame( 4, $date->toValue(Zend_Date
::HOUR_SHORT
));
581 $this->assertSame( 4, $date->toValue(Zend_Date
::HOUR_AM
));
582 $this->assertSame( 4, $date->toValue(Zend_Date
::HOUR
));
583 $this->assertSame( 31, $date->toValue(Zend_Date
::MINUTE
));
584 $this->assertSame( 30, $date->toValue(Zend_Date
::SECOND
));
585 $this->assertSame( 0, $date->toValue(Zend_Date
::MILLISECOND
));
586 $this->assertSame( 31, $date->toValue(Zend_Date
::MINUTE_SHORT
));
587 $this->assertSame( 30, $date->toValue(Zend_Date
::SECOND_SHORT
));
588 $this->assertFalse( $date->toValue(Zend_Date
::TIMEZONE_NAME
));
589 $this->assertSame( 0, $date->toValue(Zend_Date
::DAYLIGHT
));
590 $this->assertSame( 500, $date->toValue(Zend_Date
::GMT_DIFF
));
591 $this->assertFalse( $date->toValue(Zend_Date
::GMT_DIFF_SEP
));
592 $this->assertFalse( $date->toValue(Zend_Date
::TIMEZONE
));
593 $this->assertSame( 18000, $date->toValue(Zend_Date
::TIMEZONE_SECS
));
594 $this->assertFalse( $date->toValue(Zend_Date
::ISO_8601
));
595 $this->assertFalse( $date->toValue(Zend_Date
::RFC_2822
));
596 $this->assertSame(1234567890, $date->toValue(Zend_Date
::TIMESTAMP
));
597 $this->assertFalse( $date->toValue(Zend_Date
::ERA
));
598 $this->assertFalse( $date->toValue(Zend_Date
::ERA_NAME
));
599 $this->assertFalse( $date->toValue(Zend_Date
::DATES
));
600 $this->assertFalse( $date->toValue(Zend_Date
::DATE_FULL
));
601 $this->assertFalse( $date->toValue(Zend_Date
::DATE_LONG
));
602 $this->assertFalse( $date->toValue(Zend_Date
::DATE_MEDIUM
));
603 $this->assertFalse( $date->toValue(Zend_Date
::DATE_SHORT
));
604 $this->assertFalse( $date->toValue(Zend_Date
::TIMES
));
605 $this->assertFalse( $date->toValue(Zend_Date
::TIME_FULL
));
606 $this->assertFalse( $date->toValue(Zend_Date
::TIME_LONG
));
607 $this->assertFalse( $date->toValue(Zend_Date
::TIME_MEDIUM
));
608 $this->assertFalse( $date->toValue(Zend_Date
::TIME_SHORT
));
609 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME
));
610 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_FULL
));
611 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_LONG
));
612 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_MEDIUM
));
613 $this->assertFalse( $date->toValue(Zend_Date
::DATETIME_SHORT
));
614 $this->assertFalse( $date->toValue(Zend_Date
::ATOM
));
615 $this->assertFalse( $date->toValue(Zend_Date
::COOKIE
));
616 $this->assertFalse( $date->toValue(Zend_Date
::RFC_822
));
617 $this->assertFalse( $date->toValue(Zend_Date
::RFC_850
));
618 $this->assertFalse( $date->toValue(Zend_Date
::RFC_1036
));
619 $this->assertFalse( $date->toValue(Zend_Date
::RFC_1123
));
620 $this->assertFalse( $date->toValue(Zend_Date
::RFC_3339
));
621 $this->assertFalse( $date->toValue(Zend_Date
::RSS
));
622 $this->assertFalse( $date->toValue(Zend_Date
::W3C
));
628 public function testGet()
630 $locale = new Zend_Locale('de_AT');
631 $date = new Zend_Date(1234567890,null,$locale);
633 $date->setTimezone('UTC');
634 $this->assertSame( '13', $date->get(Zend_Date
::DAY
));
635 $this->assertSame( 'Fre', $date->get(Zend_Date
::WEEKDAY_SHORT
));
636 $this->assertSame( '13', $date->get(Zend_Date
::DAY_SHORT
));
637 $this->assertSame( 'Freitag', $date->get(Zend_Date
::WEEKDAY
));
638 $this->assertSame( '5', $date->get(Zend_Date
::WEEKDAY_8601
));
639 $this->assertSame( 'th', $date->get(Zend_Date
::DAY_SUFFIX
));
640 $this->assertSame( '5', $date->get(Zend_Date
::WEEKDAY_DIGIT
));
641 $this->assertSame( '43', $date->get(Zend_Date
::DAY_OF_YEAR
));
642 $this->assertSame( 'F', $date->get(Zend_Date
::WEEKDAY_NARROW
));
643 $this->assertSame( 'Fr.', $date->get(Zend_Date
::WEEKDAY_NAME
));
644 $this->assertSame( '07', $date->get(Zend_Date
::WEEK
));
645 $this->assertSame( 'Februar', $date->get(Zend_Date
::MONTH_NAME
));
646 $this->assertSame( '02', $date->get(Zend_Date
::MONTH
));
647 $this->assertSame( 'Feb', $date->get(Zend_Date
::MONTH_NAME_SHORT
));
648 $this->assertSame( '2', $date->get(Zend_Date
::MONTH_SHORT
));
649 $this->assertSame( '28', $date->get(Zend_Date
::MONTH_DAYS
));
650 $this->assertSame( 'F', $date->get(Zend_Date
::MONTH_NAME_NARROW
));
651 $this->assertSame( '0', $date->get(Zend_Date
::LEAPYEAR
));
652 $this->assertSame( '2009', $date->get(Zend_Date
::YEAR_8601
));
653 $this->assertSame( '2009', $date->get(Zend_Date
::YEAR
));
654 $this->assertSame( '09', $date->get(Zend_Date
::YEAR_SHORT
));
655 $this->assertSame( '09', $date->get(Zend_Date
::YEAR_SHORT_8601
));
656 $this->assertSame( 'nachm.', $date->get(Zend_Date
::MERIDIEM
));
657 $this->assertSame( '021', $date->get(Zend_Date
::SWATCH
));
658 $this->assertSame( '11', $date->get(Zend_Date
::HOUR_SHORT_AM
));
659 $this->assertSame( '23', $date->get(Zend_Date
::HOUR_SHORT
));
660 $this->assertSame( '11', $date->get(Zend_Date
::HOUR_AM
));
661 $this->assertSame( '23', $date->get(Zend_Date
::HOUR
));
662 $this->assertSame( '31', $date->get(Zend_Date
::MINUTE
));
663 $this->assertSame( '30', $date->get(Zend_Date
::SECOND
));
664 $this->assertSame( '0', $date->get(Zend_Date
::MILLISECOND
));
665 $this->assertSame( '31', $date->get(Zend_Date
::MINUTE_SHORT
));
666 $this->assertSame( '30', $date->get(Zend_Date
::SECOND_SHORT
));
667 $this->assertSame( 'UTC', $date->get(Zend_Date
::TIMEZONE_NAME
));
668 $this->assertSame( '0', $date->get(Zend_Date
::DAYLIGHT
));
669 $this->assertSame( '+0000', $date->get(Zend_Date
::GMT_DIFF
));
670 $this->assertSame( '+00:00', $date->get(Zend_Date
::GMT_DIFF_SEP
));
671 $this->assertSame( 'UTC', $date->get(Zend_Date
::TIMEZONE
));
672 $this->assertSame( '0', $date->get(Zend_Date
::TIMEZONE_SECS
));
673 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::ISO_8601
));
674 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date
::RFC_2822
));
675 $this->assertSame( '1234567890', $date->get(Zend_Date
::TIMESTAMP
));
676 $this->assertSame( 'n. Chr.', $date->get(Zend_Date
::ERA
));
677 $this->assertSame( 'n. Chr.', $date->get(Zend_Date
::ERA_NAME
));
678 $this->assertSame( '13.02.2009', $date->get(Zend_Date
::DATES
));
679 $this->assertSame( 'Freitag, 13. Februar 2009', $date->get(Zend_Date
::DATE_FULL
));
680 $this->assertSame( '13. Februar 2009', $date->get(Zend_Date
::DATE_LONG
));
681 $this->assertSame( '13.02.2009', $date->get(Zend_Date
::DATE_MEDIUM
));
682 $this->assertSame( '13.02.09', $date->get(Zend_Date
::DATE_SHORT
));
683 $this->assertSame( '23:31:30', $date->get(Zend_Date
::TIMES
));
684 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date
::TIME_FULL
));
685 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date
::TIME_LONG
));
686 $this->assertSame( '23:31:30', $date->get(Zend_Date
::TIME_MEDIUM
));
687 $this->assertSame( '23:31', $date->get(Zend_Date
::TIME_SHORT
));
688 $this->assertSame( '13.02.2009 23:31:30', $date->get(Zend_Date
::DATETIME
));
689 $this->assertSame('Freitag, 13. Februar 2009 23:31:30 UTC', $date->get(Zend_Date
::DATETIME_FULL
));
690 $this->assertSame( '13. Februar 2009 23:31:30 UTC', $date->get(Zend_Date
::DATETIME_LONG
));
691 $this->assertSame( '13.02.2009 23:31:30', $date->get(Zend_Date
::DATETIME_MEDIUM
));
692 $this->assertSame( '13.02.09 23:31', $date->get(Zend_Date
::DATETIME_SHORT
));
693 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::ATOM
));
694 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date
::COOKIE
));
695 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date
::RFC_822
));
696 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date
::RFC_850
));
697 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date
::RFC_1036
));
698 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date
::RFC_1123
));
699 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::RFC_3339
));
700 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date
::RSS
));
701 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
703 $this->assertSame( '13', $date->get(Zend_Date
::DAY
, 'es'));
704 $this->assertSame( 'vie', $date->get(Zend_Date
::WEEKDAY_SHORT
, 'es'));
705 $this->assertSame( '13', $date->get(Zend_Date
::DAY_SHORT
, 'es'));
706 $this->assertSame( 'viernes', $date->get(Zend_Date
::WEEKDAY
, 'es'));
707 $this->assertSame( '5', $date->get(Zend_Date
::WEEKDAY_8601
, 'es'));
708 $this->assertSame( 'th', $date->get(Zend_Date
::DAY_SUFFIX
, 'es'));
709 $this->assertSame( '5', $date->get(Zend_Date
::WEEKDAY_DIGIT
, 'es'));
710 $this->assertSame( '43', $date->get(Zend_Date
::DAY_OF_YEAR
, 'es'));
711 $this->assertSame( 'v', $date->get(Zend_Date
::WEEKDAY_NARROW
, 'es'));
712 $this->assertSame( 'vie', $date->get(Zend_Date
::WEEKDAY_NAME
, 'es'));
713 $this->assertSame( '07', $date->get(Zend_Date
::WEEK
, 'es'));
714 $this->assertSame( 'febrero', $date->get(Zend_Date
::MONTH_NAME
, 'es'));
715 $this->assertSame( '02', $date->get(Zend_Date
::MONTH
, 'es'));
716 $this->assertSame( 'feb', $date->get(Zend_Date
::MONTH_NAME_SHORT
, 'es'));
717 $this->assertSame( '2', $date->get(Zend_Date
::MONTH_SHORT
, 'es'));
718 $this->assertSame( '28', $date->get(Zend_Date
::MONTH_DAYS
, 'es'));
719 $this->assertSame( 'f', $date->get(Zend_Date
::MONTH_NAME_NARROW
, 'es'));
720 $this->assertSame( '0', $date->get(Zend_Date
::LEAPYEAR
, 'es'));
721 $this->assertSame( '2009', $date->get(Zend_Date
::YEAR_8601
, 'es'));
722 $this->assertSame( '2009', $date->get(Zend_Date
::YEAR
, 'es'));
723 $this->assertSame( '09', $date->get(Zend_Date
::YEAR_SHORT
, 'es'));
724 $this->assertSame( '09', $date->get(Zend_Date
::YEAR_SHORT_8601
, 'es'));
725 $this->assertSame( 'p.m.', $date->get(Zend_Date
::MERIDIEM
, 'es'));
726 $this->assertSame( '021', $date->get(Zend_Date
::SWATCH
, 'es'));
727 $this->assertSame( '11', $date->get(Zend_Date
::HOUR_SHORT_AM
, 'es'));
728 $this->assertSame( '23', $date->get(Zend_Date
::HOUR_SHORT
, 'es'));
729 $this->assertSame( '11', $date->get(Zend_Date
::HOUR_AM
, 'es'));
730 $this->assertSame( '23', $date->get(Zend_Date
::HOUR
, 'es'));
731 $this->assertSame( '31', $date->get(Zend_Date
::MINUTE
, 'es'));
732 $this->assertSame( '30', $date->get(Zend_Date
::SECOND
, 'es'));
733 $this->assertSame( '0', $date->get(Zend_Date
::MILLISECOND
, 'es'));
734 $this->assertSame( '31', $date->get(Zend_Date
::MINUTE_SHORT
, 'es'));
735 $this->assertSame( '30', $date->get(Zend_Date
::SECOND_SHORT
, 'es'));
736 $this->assertSame( 'UTC', $date->get(Zend_Date
::TIMEZONE_NAME
, 'es'));
737 $this->assertSame( '0', $date->get(Zend_Date
::DAYLIGHT
, 'es'));
738 $this->assertSame( '+0000', $date->get(Zend_Date
::GMT_DIFF
, 'es'));
739 $this->assertSame( '+00:00', $date->get(Zend_Date
::GMT_DIFF_SEP
, 'es'));
740 $this->assertSame( 'UTC', $date->get(Zend_Date
::TIMEZONE
, 'es'));
741 $this->assertSame( '0', $date->get(Zend_Date
::TIMEZONE_SECS
, 'es'));
742 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::ISO_8601
, 'es'));
743 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date
::RFC_2822
, 'es'));
744 $this->assertSame( '1234567890', $date->get(Zend_Date
::TIMESTAMP
, 'es'));
745 $this->assertSame( 'd.C.', $date->get(Zend_Date
::ERA
, 'es'));
746 $this->assertSame( 'anno Dómini', $date->get(Zend_Date
::ERA_NAME
, 'es'));
747 $this->assertSame( '13/02/2009', $date->get(Zend_Date
::DATES
, 'es'));
748 $this->assertSame( 'viernes 13 de febrero de 2009', $date->get(Zend_Date
::DATE_FULL
, 'es'));
749 $this->assertSame( '13 de febrero de 2009', $date->get(Zend_Date
::DATE_LONG
, 'es'));
750 $this->assertSame( '13/02/2009', $date->get(Zend_Date
::DATE_MEDIUM
, 'es'));
751 $this->assertSame( '13/02/09', $date->get(Zend_Date
::DATE_SHORT
, 'es'));
752 $this->assertSame( '23:31:30', $date->get(Zend_Date
::TIMES
, 'es'));
753 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date
::TIME_FULL
, 'es'));
754 $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date
::TIME_LONG
, 'es'));
755 $this->assertSame( '23:31:30', $date->get(Zend_Date
::TIME_MEDIUM
, 'es'));
756 $this->assertSame( '23:31', $date->get(Zend_Date
::TIME_SHORT
, 'es'));
757 $this->assertSame( '13/02/2009 23:31:30', $date->get(Zend_Date
::DATETIME
, 'es'));
758 $this->assertSame('viernes 13 de febrero de 2009 23:31:30 UTC', $date->get(Zend_Date
::DATETIME_FULL
, 'es'));
759 $this->assertSame('13 de febrero de 2009 23:31:30 UTC', $date->get(Zend_Date
::DATETIME_LONG
, 'es'));
760 $this->assertSame( '13/02/2009 23:31:30', $date->get(Zend_Date
::DATETIME_MEDIUM
, 'es'));
761 $this->assertSame( '13/02/09 23:31', $date->get(Zend_Date
::DATETIME_SHORT
, 'es'));
762 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::ATOM
, 'es'));
763 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date
::COOKIE
, 'es'));
764 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date
::RFC_822
, 'es'));
765 $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date
::RFC_850
, 'es'));
766 $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date
::RFC_1036
, 'es'));
767 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date
::RFC_1123
, 'es'));
768 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::RFC_3339
, 'es'));
769 $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date
::RSS
, 'es'));
770 $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
, 'es'));
772 $date->setTimezone('Indian/Maldives');
773 $this->assertSame( '1234567890', $date->get( ));
774 $this->assertSame( '14', $date->get(Zend_Date
::DAY
));
775 $this->assertSame( 'Sam', $date->get(Zend_Date
::WEEKDAY_SHORT
));
776 $this->assertSame( '14', $date->get(Zend_Date
::DAY_SHORT
));
777 $this->assertSame( 'Samstag', $date->get(Zend_Date
::WEEKDAY
));
778 $this->assertSame( '6', $date->get(Zend_Date
::WEEKDAY_8601
));
779 $this->assertSame( 'th', $date->get(Zend_Date
::DAY_SUFFIX
));
780 $this->assertSame( '6', $date->get(Zend_Date
::WEEKDAY_DIGIT
));
781 $this->assertSame( '44', $date->get(Zend_Date
::DAY_OF_YEAR
));
782 $this->assertSame( 'S', $date->get(Zend_Date
::WEEKDAY_NARROW
));
783 $this->assertSame( 'Sa.', $date->get(Zend_Date
::WEEKDAY_NAME
));
784 $this->assertSame( '07', $date->get(Zend_Date
::WEEK
));
785 $this->assertSame( 'Februar', $date->get(Zend_Date
::MONTH_NAME
));
786 $this->assertSame( '02', $date->get(Zend_Date
::MONTH
));
787 $this->assertSame( 'Feb', $date->get(Zend_Date
::MONTH_NAME_SHORT
));
788 $this->assertSame( '2', $date->get(Zend_Date
::MONTH_SHORT
));
789 $this->assertSame( '28', $date->get(Zend_Date
::MONTH_DAYS
));
790 $this->assertSame( 'F', $date->get(Zend_Date
::MONTH_NAME_NARROW
));
791 $this->assertSame( '0', $date->get(Zend_Date
::LEAPYEAR
));
792 $this->assertSame( '2009', $date->get(Zend_Date
::YEAR_8601
));
793 $this->assertSame( '2009', $date->get(Zend_Date
::YEAR
));
794 $this->assertSame( '09', $date->get(Zend_Date
::YEAR_SHORT
));
795 $this->assertSame( '09', $date->get(Zend_Date
::YEAR_SHORT_8601
));
796 $this->assertSame( 'vorm.', $date->get(Zend_Date
::MERIDIEM
));
797 $this->assertSame( '021', $date->get(Zend_Date
::SWATCH
));
798 $this->assertSame( '4', $date->get(Zend_Date
::HOUR_SHORT_AM
));
799 $this->assertSame( '4', $date->get(Zend_Date
::HOUR_SHORT
));
800 $this->assertSame( '04', $date->get(Zend_Date
::HOUR_AM
));
801 $this->assertSame( '04', $date->get(Zend_Date
::HOUR
));
802 $this->assertSame( '31', $date->get(Zend_Date
::MINUTE
));
803 $this->assertSame( '30', $date->get(Zend_Date
::SECOND
));
804 $this->assertSame( '0', $date->get(Zend_Date
::MILLISECOND
));
805 $this->assertSame( '31', $date->get(Zend_Date
::MINUTE_SHORT
));
806 $this->assertSame( '30', $date->get(Zend_Date
::SECOND_SHORT
));
807 $this->assertSame( 'Indian/Maldives', $date->get(Zend_Date
::TIMEZONE_NAME
));
808 $this->assertSame( '0', $date->get(Zend_Date
::DAYLIGHT
));
809 $this->assertSame( '+0500', $date->get(Zend_Date
::GMT_DIFF
));
810 $this->assertSame( '+05:00', $date->get(Zend_Date
::GMT_DIFF_SEP
));
811 $this->assertSame( 'MVT', $date->get(Zend_Date
::TIMEZONE
));
812 $this->assertSame( '18000', $date->get(Zend_Date
::TIMEZONE_SECS
));
813 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::ISO_8601
));
814 $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date
::RFC_2822
));
815 $this->assertSame( '1234567890', $date->get(Zend_Date
::TIMESTAMP
));
816 $this->assertSame( 'n. Chr.', $date->get(Zend_Date
::ERA
));
817 $this->assertSame( 'n. Chr.', $date->get(Zend_Date
::ERA_NAME
));
818 $this->assertSame( '14.02.2009', $date->get(Zend_Date
::DATES
));
819 $this->assertSame( 'Samstag, 14. Februar 2009', $date->get(Zend_Date
::DATE_FULL
));
820 $this->assertSame( '14. Februar 2009', $date->get(Zend_Date
::DATE_LONG
));
821 $this->assertSame( '14.02.2009', $date->get(Zend_Date
::DATE_MEDIUM
));
822 $this->assertSame( '14.02.09', $date->get(Zend_Date
::DATE_SHORT
));
823 $this->assertSame( '04:31:30', $date->get(Zend_Date
::TIMES
));
824 $this->assertSame( '04:31:30 Indian/Maldives', $date->get(Zend_Date
::TIME_FULL
));
825 $this->assertSame( '04:31:30 MVT', $date->get(Zend_Date
::TIME_LONG
));
826 $this->assertSame( '04:31:30', $date->get(Zend_Date
::TIME_MEDIUM
));
827 $this->assertSame( '04:31', $date->get(Zend_Date
::TIME_SHORT
));
828 $this->assertSame( '14.02.2009 04:31:30', $date->get(Zend_Date
::DATETIME
));
829 $this->assertSame('Samstag, 14. Februar 2009 04:31:30 Indian/Maldives', $date->get(Zend_Date
::DATETIME_FULL
));
830 $this->assertSame( '14. Februar 2009 04:31:30 MVT', $date->get(Zend_Date
::DATETIME_LONG
));
831 $this->assertSame( '14.02.2009 04:31:30', $date->get(Zend_Date
::DATETIME_MEDIUM
));
832 $this->assertSame( '14.02.09 04:31', $date->get(Zend_Date
::DATETIME_SHORT
));
833 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::ATOM
));
834 $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Zend_Date
::COOKIE
));
835 $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Zend_Date
::RFC_822
));
836 $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Zend_Date
::RFC_850
));
837 $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Zend_Date
::RFC_1036
));
838 $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date
::RFC_1123
));
839 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::RFC_3339
));
840 $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date
::RSS
));
841 $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
843 // when get() receives a format string it responses like toString();
844 $date->setTimezone('Indian/Maldives');
845 $this->assertSame('2009', $date->get('Y'));
851 public function testGet2()
853 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
854 $this->markTestSkipped('Extended I18N test skipped');
858 $locale = new Zend_Locale('de_AT');
859 $date = new Zend_Date(-62362925370,null,$locale);
860 $this->assertSame('v. Chr.', $date->get(Zend_Date
::ERA
));
861 $this->assertSame('v. Chr.', $date->get(Zend_Date
::ERA_NAME
));
867 public function testSet()
869 $locale = new Zend_Locale('de_AT');
870 $date = new Zend_Date(0,null,$locale);
871 $d2 = new Zend_Date(1010101010,null,$locale);
872 $date->setTimezone(date_default_timezone_get());
873 $d2->setTimezone(date_default_timezone_get());
875 $retour = $date->set(1234567890);
876 $this->assertSame('1234567890', $retour->getTimestamp());
877 $this->assertSame('1010101010', $date->set($d2)->getTimestamp());
878 $this->assertSame('1234567891', $date->set(1234567891)->getTimestamp());
881 $date->set('noday', Zend_Date
::DAY
);
882 $this->fail('exception expected');
883 } catch (Zend_Date_Exception
$e) {
887 $date->set($d2, Zend_Date
::DAY
);
888 $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
889 $date->set( 10, Zend_Date
::DAY
);
890 $this->assertSame('2009-02-10T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
891 $date->set( 40, Zend_Date
::DAY
);
892 $this->assertSame('2009-03-12T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
893 $date->set(-10, Zend_Date
::DAY
);
894 $this->assertSame('2009-02-18T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
895 $date->setTimezone('UTC');
896 $date->set( 10, Zend_Date
::DAY
);
897 $this->assertSame('2009-02-10T23:31:31+00:00', $date->get(Zend_Date
::W3C
));
898 $date->setTimezone('Indian/Maldives');
899 $date->set($d2, Zend_Date
::DAY
);
900 $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
901 $date->setTimezone('UTC');
902 $date->set( 10, Zend_Date
::DAY
, 'en_US');
903 $this->assertSame('2009-02-10T23:31:31+00:00', $date->get(Zend_Date
::W3C
));
904 $date->set($d2, Zend_Date
::DAY
, 'en_US');
905 $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
906 $date->setTimezone('Indian/Maldives');
907 $date->set(-20, Zend_Date
::DAY
, 'en_US');
908 $this->assertSame('2009-01-11T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
909 $date->set($d2, Zend_Date
::DAY
, 'en_US');
910 $this->assertSame('2009-01-04T04:31:31+05:00', $date->get(Zend_Date
::W3C
));
912 $date->set('10.April.2007', 'dd.MMMM.YYYY');
913 $this->assertSame('2007-04-10T00:00:00+05:00', $date->get(Zend_Date
::W3C
));
919 public function testSet2()
921 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
922 $this->markTestSkipped('Extended I18N test skipped');
926 $locale = new Zend_Locale('de_AT');
927 $date = new Zend_Date(0,null,$locale);
928 $d2 = new Zend_Date(1010101010,null,$locale);
930 $date->setTimezone(date_default_timezone_get());
931 $d2->setTimezone(date_default_timezone_get());
932 $date->set(1234567890);
934 $date->set('noday', Zend_Date
::WEEKDAY_SHORT
);
935 $this->fail('exception expected');
936 } catch (Zend_Date_Exception
$e) {
939 $date->set($d2, Zend_Date
::WEEKDAY_SHORT
);
940 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
941 $date->set('Son', Zend_Date
::WEEKDAY_SHORT
);
942 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
943 $date->set('Mon', Zend_Date
::WEEKDAY_SHORT
);
944 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
945 $date->setTimezone('UTC');
946 $date->set('Fre', Zend_Date
::WEEKDAY_SHORT
);
947 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
948 $date->set($d2, Zend_Date
::WEEKDAY_SHORT
);
949 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
950 $date->setTimezone('Indian/Maldives');
951 $date->set('Thu', Zend_Date
::WEEKDAY_SHORT
, 'en_US');
952 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
953 $date->set($d2, Zend_Date
::WEEKDAY_SHORT
, 'en_US');
954 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
955 $date->setTimezone('UTC');
956 $date->set('Wed', Zend_Date
::WEEKDAY_SHORT
, 'en_US');
957 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
958 $date->set($d2, Zend_Date
::WEEKDAY_SHORT
, 'en_US');
959 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
960 $date->setTimezone('Indian/Maldives');
962 $date->set(1234567890);
964 $date->set('xxx', Zend_Date
::DAY_SHORT
);
965 $this->fail('exception expected');
966 } catch (Zend_Date_Exception
$e) {
969 $date->set($d2, Zend_Date
::DAY_SHORT
);
970 $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
971 $date->set( 10, Zend_Date
::DAY_SHORT
);
972 $this->assertSame('2009-02-10T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
973 $date->set( 40, Zend_Date
::DAY_SHORT
);
974 $this->assertSame('2009-03-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
975 $date->set(-10, Zend_Date
::DAY_SHORT
);
976 $this->assertSame('2009-02-18T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
977 $date->setTimeZone('UTC');
978 $date->set( 10, Zend_Date
::DAY_SHORT
);
979 $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
980 $date->set($d2, Zend_Date
::DAY_SHORT
);
981 $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
982 $date->setTimezone('Indian/Maldives');
983 $date->set( 10, Zend_Date
::DAY_SHORT
, 'en_US');
984 $this->assertSame('2009-02-10T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
985 $date->set($d2, Zend_Date
::DAY_SHORT
, 'en_US');
986 $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
987 $date->setTimeZone('UTC');
988 $date->set(-20, Zend_Date
::DAY_SHORT
, 'en_US');
989 $this->assertSame('2009-01-11T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
990 $date->set($d2, Zend_Date
::DAY_SHORT
, 'en_US');
991 $this->assertSame('2009-01-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
992 $date->setTimezone('Indian/Maldives');
994 $date->set(1234567890);
996 $date->set('noday', Zend_Date
::WEEKDAY
);
997 $this->fail('exception expected');
998 } catch (Zend_Date_Exception
$e) {
1001 $date->set($d2, Zend_Date
::WEEKDAY
);
1002 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1003 $date->set('Sonntag', Zend_Date
::WEEKDAY
);
1004 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1005 $date->set('Montag', Zend_Date
::WEEKDAY
);
1006 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1007 $date->setTimeZone('UTC');
1008 $date->set('Freitag', Zend_Date
::WEEKDAY
);
1009 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1010 $date->set($d2, Zend_Date
::WEEKDAY
);
1011 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1012 $date->setTimezone('Indian/Maldives');
1013 $date->set('Wednesday', Zend_Date
::WEEKDAY
, 'en_US');
1014 $this->assertSame('2009-02-11T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1015 $date->set($d2, Zend_Date
::WEEKDAY
, 'en_US');
1016 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1017 $date->setTimeZone('UTC');
1018 $date->set('Thursday', Zend_Date
::WEEKDAY
, 'en_US');
1019 $this->assertSame('2009-02-12T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1020 $date->set($d2, Zend_Date
::WEEKDAY
, 'en_US');
1021 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1022 $date->setTimezone('Indian/Maldives');
1024 $date->set(1234567890);
1026 $date->set(0, Zend_Date
::WEEKDAY_8601
);
1027 $this->fail('exception expected');
1028 } catch (Zend_Date_Exception
$e) {
1032 $date->set('noday', Zend_Date
::WEEKDAY_8601
);
1033 $this->fail('exception expected');
1034 } catch (Zend_Date_Exception
$e) {
1037 $date->set($d2, Zend_Date
::WEEKDAY_8601
);
1038 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1039 $date->set(1, Zend_Date
::WEEKDAY_8601
);
1040 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1041 $date->set(5, Zend_Date
::WEEKDAY_8601
);
1042 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1043 $date->setTimeZone('UTC');
1044 $date->set(2, Zend_Date
::WEEKDAY_8601
);
1045 $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1046 $date->set($d2, Zend_Date
::WEEKDAY_8601
);
1047 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1048 $date->setTimezone('Indian/Maldives');
1049 $date->set(4, Zend_Date
::WEEKDAY_8601
, 'en_US');
1050 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1051 $date->set($d2, Zend_Date
::WEEKDAY_8601
, 'en_US');
1052 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1053 $date->setTimeZone('UTC');
1054 $date->set(3, Zend_Date
::WEEKDAY_8601
, 'en_US');
1055 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1056 $date->set($d2, Zend_Date
::WEEKDAY_8601
, 'en_US');
1057 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1058 $date->setTimezone('Indian/Maldives');
1060 $date->set(1234567890);
1062 $date->set($d2, Zend_Date
::DAY_SUFFIX
);
1063 $this->fail('exception expected');
1064 } catch (Zend_Date_Exception
$e) {
1068 $date->set(1234567890);
1070 $date->set(7, Zend_Date
::WEEKDAY_DIGIT
);
1072 } catch (Zend_Date_Exception
$e) {
1076 $date->set('noday', Zend_Date
::WEEKDAY_DIGIT
);
1078 } catch (Zend_Date_Exception
$e) {
1081 $date->set($d2, Zend_Date
::WEEKDAY_DIGIT
);
1082 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1083 $date->set(1, Zend_Date
::WEEKDAY_DIGIT
);
1084 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1085 $date->set(5, Zend_Date
::WEEKDAY_DIGIT
);
1086 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1087 $date->setTimeZone('UTC');
1088 $date->set(2, Zend_Date
::WEEKDAY_DIGIT
);
1089 $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1090 $date->set($d2, Zend_Date
::WEEKDAY_DIGIT
);
1091 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1092 $date->setTimezone('Indian/Maldives');
1093 $date->set(4, Zend_Date
::WEEKDAY_DIGIT
, 'en_US');
1094 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1095 $date->set($d2, Zend_Date
::WEEKDAY_DIGIT
, 'en_US');
1096 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1097 $date->setTimeZone('UTC');
1098 $date->set(3, Zend_Date
::WEEKDAY_DIGIT
, 'en_US');
1099 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1100 $date->set($d2, Zend_Date
::WEEKDAY_DIGIT
, 'en_US');
1101 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1102 $date->setTimezone('Indian/Maldives');
1104 $date->set(1234567890);
1106 $date->set('noday', Zend_Date
::DAY_OF_YEAR
);
1108 } catch (Zend_Date_Exception
$e) {
1111 $date->set($d2, Zend_Date
::DAY_OF_YEAR
);
1112 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1113 $date->set( 124, Zend_Date
::DAY_OF_YEAR
);
1114 $this->assertSame('2009-05-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1115 $date->set( 524, Zend_Date
::DAY_OF_YEAR
);
1116 $this->assertSame('2010-06-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1117 $date->set(-135, Zend_Date
::DAY_OF_YEAR
);
1118 $this->assertSame('2009-08-18T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1119 $date->setTimeZone('UTC');
1120 $date->set( 422, Zend_Date
::DAY_OF_YEAR
);
1121 $this->assertSame('2010-02-26T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1122 $date->set($d2, Zend_Date
::DAY_OF_YEAR
);
1123 $this->assertSame('2010-01-03T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1124 $date->setTimezone('Indian/Maldives');
1125 $date->set( 12, Zend_Date
::DAY_OF_YEAR
, 'en_US');
1126 $this->assertSame('2010-01-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1127 $date->set($d2, Zend_Date
::DAY_OF_YEAR
, 'en_US');
1128 $this->assertSame('2010-01-03T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1129 $date->setTimeZone('UTC');
1130 $date->set(-253, Zend_Date
::DAY_OF_YEAR
, 'en_US');
1131 $this->assertSame('2009-04-22T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1132 $date->set($d2, Zend_Date
::DAY_OF_YEAR
, 'en_US');
1133 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1134 $date->setTimezone('Indian/Maldives');
1136 $date->set(1234567890);
1138 $date->set('noday', Zend_Date
::WEEKDAY_NARROW
);
1139 $this->fail('exception expected');
1140 } catch (Zend_Date_Exception
$e) {
1143 $date->set($d2, Zend_Date
::WEEKDAY_NARROW
);
1144 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1145 $date->set('S', Zend_Date
::WEEKDAY_NARROW
);
1146 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1147 $date->set('M', Zend_Date
::WEEKDAY_NARROW
);
1148 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1149 $date->setTimeZone('UTC');
1150 $date->set('F', Zend_Date
::WEEKDAY_NARROW
);
1151 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1152 $date->set($d2, Zend_Date
::WEEKDAY_NARROW
);
1153 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1154 $date->setTimezone('Indian/Maldives');
1155 $date->set('W', Zend_Date
::WEEKDAY_NARROW
, 'en_US');
1156 $this->assertSame('2009-02-11T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1157 $date->set($d2, Zend_Date
::WEEKDAY_NARROW
, 'en_US');
1158 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1159 $date->setTimeZone('UTC');
1160 $date->set('W', Zend_Date
::WEEKDAY_NARROW
, 'en_US');
1161 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1162 $date->set($d2, Zend_Date
::WEEKDAY_NARROW
, 'en_US');
1163 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1164 $date->setTimezone('Indian/Maldives');
1166 $date->set(1234567890);
1168 $date->set('noday', Zend_Date
::WEEKDAY_NAME
);
1170 } catch (Zend_Date_Exception
$e) {
1173 $date->set($d2, Zend_Date
::WEEKDAY_NAME
);
1174 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1175 $date->set('So.', Zend_Date
::WEEKDAY_NAME
);
1176 $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1177 $date->set('Mo.', Zend_Date
::WEEKDAY_NAME
);
1178 $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1179 $date->setTimeZone('UTC');
1180 $date->set('Fr.', Zend_Date
::WEEKDAY_NAME
);
1181 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1182 $date->set($d2, Zend_Date
::WEEKDAY_NAME
);
1183 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1184 $date->setTimezone('Indian/Maldives');
1185 $date->set('Thu', Zend_Date
::WEEKDAY_NAME
, 'en_US');
1186 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1187 $date->set($d2, Zend_Date
::WEEKDAY_NAME
, 'en_US');
1188 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1189 $date->setTimeZone('UTC');
1190 $date->set('Wed', Zend_Date
::WEEKDAY_NAME
, 'en_US');
1191 $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1192 $date->set($d2, Zend_Date
::WEEKDAY_NAME
, 'en_US');
1193 $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1194 $date->setTimezone('Indian/Maldives');
1196 $date->set(1234567890);
1198 $date->set('noday', Zend_Date
::WEEK
);
1200 } catch (Zend_Date_Exception
$e) {
1203 $date->set($d2, Zend_Date
::WEEK
);
1204 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1205 $date->set( 1, Zend_Date
::WEEK
);
1206 $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1207 $date->set( 55, Zend_Date
::WEEK
);
1208 $this->assertSame('2010-01-16T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1209 $date->set(-57, Zend_Date
::WEEK
);
1210 $this->assertSame('2008-11-29T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1211 $date->setTimeZone('UTC');
1212 $date->set( 50, Zend_Date
::WEEK
);
1213 $this->assertSame('2008-12-12T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1214 $date->set($d2, Zend_Date
::WEEK
);
1215 $this->assertSame('2008-01-05T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1216 $date->setTimezone('Indian/Maldives');
1217 $date->set( 10, Zend_Date
::WEEK
, 'en_US');
1218 $this->assertSame('2008-03-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1219 $date->set($d2, Zend_Date
::WEEK
, 'en_US');
1220 $this->assertSame('2008-01-05T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1221 $date->setTimeZone('UTC');
1222 $date->set(-25, Zend_Date
::WEEK
, 'en_US');
1223 $this->assertSame('2007-07-06T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1224 $date->set($d2, Zend_Date
::WEEK
, 'en_US');
1225 $this->assertSame('2007-01-06T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1226 $date->setTimezone('Indian/Maldives');
1228 $date->set(1234567890);
1230 $date->set('noday', Zend_Date
::MONTH_NAME
);
1231 $this->fail('exception expected');
1232 } catch (Zend_Date_Exception
$e) {
1235 $date->set($d2, Zend_Date
::MONTH_NAME
);
1236 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1237 $date->set('März', Zend_Date
::MONTH_NAME
);
1238 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1239 $date->set('Dezember', Zend_Date
::MONTH_NAME
);
1240 $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1241 $date->setTimeZone('UTC');
1242 $date->set('August', Zend_Date
::MONTH_NAME
);
1243 $this->assertSame('2009-08-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1244 $date->set($d2, Zend_Date
::MONTH_NAME
);
1245 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1246 $date->setTimezone('Indian/Maldives');
1247 $date->set('April', Zend_Date
::MONTH_NAME
, 'en_US');
1248 $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1249 $date->set($d2, Zend_Date
::MONTH_NAME
, 'en_US');
1250 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1251 $date->setTimeZone('UTC');
1252 $date->set('July', Zend_Date
::MONTH_NAME
, 'en_US');
1253 $this->assertSame('2009-07-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1254 $date->set($d2, Zend_Date
::MONTH_NAME
, 'en_US');
1255 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1256 $date->setTimezone('Indian/Maldives');
1258 $date->set(1234567890);
1260 $date->set('noday', Zend_Date
::MONTH
);
1262 } catch (Zend_Date_Exception
$e) {
1265 $date->set($d2, Zend_Date
::MONTH
);
1266 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1267 $date->set('03', Zend_Date
::MONTH
);
1268 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1269 $date->set( 14, Zend_Date
::MONTH
);
1270 $this->assertSame('2010-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1271 $date->set(-6, Zend_Date
::MONTH
);
1272 $this->assertSame('2009-06-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1273 $date->setTimeZone('UTC');
1274 $date->set( 10, Zend_Date
::MONTH
);
1275 $this->assertSame('2009-10-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1276 $date->set($d2, Zend_Date
::MONTH
);
1277 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1278 $date->setTimezone('Indian/Maldives');
1279 $date->set( 9, Zend_Date
::MONTH
, 'en_US');
1280 $this->assertSame('2009-09-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1281 $date->set($d2, Zend_Date
::MONTH
, 'en_US');
1282 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1283 $date->setTimeZone('UTC');
1284 $date->set(-20, Zend_Date
::MONTH
, 'en_US');
1285 $this->assertSame('2007-04-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1286 $date->set($d2, Zend_Date
::MONTH
, 'en_US');
1287 $this->assertSame('2007-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1288 $date->setTimezone('Indian/Maldives');
1290 $date->set(1234567890);
1292 $date->set('noday', Zend_Date
::MONTH_NAME_SHORT
);
1293 $this->fail('exception expected');
1294 } catch (Zend_Date_Exception
$e) {
1297 $date->set($d2, Zend_Date
::MONTH_NAME_SHORT
);
1298 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1299 $date->set('Mär', Zend_Date
::MONTH_NAME_SHORT
);
1300 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1301 $date->set('Dez', Zend_Date
::MONTH_NAME_SHORT
);
1302 $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1303 $date->setTimeZone('UTC');
1304 $date->set('Aug', Zend_Date
::MONTH_NAME_SHORT
);
1305 $this->assertSame('2009-08-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1306 $date->set($d2, Zend_Date
::MONTH_NAME_SHORT
);
1307 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1308 $date->setTimezone('Indian/Maldives');
1309 $date->set('Apr', Zend_Date
::MONTH_NAME_SHORT
, 'en_US');
1310 $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1311 $date->set($d2, Zend_Date
::MONTH_NAME_SHORT
, 'en_US');
1312 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1313 $date->setTimeZone('UTC');
1314 $date->set('Jul', Zend_Date
::MONTH_NAME_SHORT
, 'en_US');
1315 $this->assertSame('2009-07-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1316 $date->set($d2, Zend_Date
::MONTH_NAME_SHORT
, 'en_US');
1317 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1318 $date->setTimezone('Indian/Maldives');
1320 $date->set(1234567890);
1322 $date->set('noday', Zend_Date
::MONTH_SHORT
);
1324 } catch (Zend_Date_Exception
$e) {
1327 $date->set($d2, Zend_Date
::MONTH_SHORT
);
1328 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1329 $date->set( 3, Zend_Date
::MONTH_SHORT
);
1330 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1331 $date->set( 14, Zend_Date
::MONTH_SHORT
);
1332 $this->assertSame('2010-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1333 $date->set(-6, Zend_Date
::MONTH_SHORT
);
1334 $this->assertSame('2009-06-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1335 $date->setTimeZone('UTC');
1336 $date->set( 10, Zend_Date
::MONTH_SHORT
);
1337 $this->assertSame('2009-10-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1338 $date->set($d2, Zend_Date
::MONTH_SHORT
);
1339 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1340 $date->setTimezone('Indian/Maldives');
1341 $date->set( 9, Zend_Date
::MONTH_SHORT
, 'en_US');
1342 $this->assertSame('2009-09-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1343 $date->set($d2, Zend_Date
::MONTH_SHORT
, 'en_US');
1344 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1345 $date->setTimeZone('UTC');
1346 $date->set(-20, Zend_Date
::MONTH_SHORT
, 'en_US');
1347 $this->assertSame('2007-04-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1348 $date->set($d2, Zend_Date
::MONTH_SHORT
, 'en_US');
1349 $this->assertSame('2007-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1350 $date->setTimezone('Indian/Maldives');
1352 $date->set(1234567890);
1354 $date->set($d2, Zend_Date
::MONTH_DAYS
);
1355 $this->fail('exception expected');
1356 } catch (Zend_Date_Exception
$e) {
1360 $date->set(1234567890);
1362 $date->set('xxday', Zend_Date
::MONTH_NAME_NARROW
);
1363 $this->fail('exception expected');
1364 } catch (Zend_Date_Exception
$e) {
1367 $date->set($d2, Zend_Date
::MONTH_NAME_NARROW
);
1368 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1369 $date->set('M', Zend_Date
::MONTH_NAME_NARROW
);
1370 $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1371 $date->set('D', Zend_Date
::MONTH_NAME_NARROW
);
1372 $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1373 $date->setTimeZone('UTC');
1374 $date->set('A', Zend_Date
::MONTH_NAME_NARROW
);
1375 $this->assertSame('2009-04-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1376 $date->set($d2, Zend_Date
::MONTH_NAME_NARROW
);
1377 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1378 $date->setTimezone('Indian/Maldives');
1379 $date->set('A', Zend_Date
::MONTH_NAME_NARROW
, 'en_US');
1380 $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1381 $date->set($d2, Zend_Date
::MONTH_NAME_NARROW
, 'en_US');
1382 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1383 $date->setTimeZone('UTC');
1384 $date->set('J', Zend_Date
::MONTH_NAME_NARROW
, 'en_US');
1385 $this->assertSame('2009-01-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1386 $date->set($d2, Zend_Date
::MONTH_NAME_NARROW
, 'en_US');
1387 $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1388 $date->setTimezone('Indian/Maldives');
1390 $date->set(1234567890);
1392 $date->set($d2, Zend_Date
::LEAPYEAR
);
1393 $this->fail('exception expected');
1394 } catch (Zend_Date_Exception
$e) {
1398 $date->set(1234567890);
1400 $date->set('noday', Zend_Date
::YEAR_8601
);
1402 } catch (Zend_Date_Exception
$e) {
1405 $date->set($d2, Zend_Date
::YEAR_8601
);
1406 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1407 $date->set(1970, Zend_Date
::YEAR_8601
);
1408 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1409 $date->set(2020, Zend_Date
::YEAR_8601
);
1410 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1411 $date->set(2040, Zend_Date
::YEAR_8601
);
1412 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1413 $date->setTimeZone('UTC');
1414 $date->set(1900, Zend_Date
::YEAR_8601
);
1415 $this->assertSame('1900-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1416 $date->set($d2, Zend_Date
::YEAR_8601
);
1417 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1418 $date->setTimezone('Indian/Maldives');
1419 $date->set(2500, Zend_Date
::YEAR_8601
, 'en_US');
1420 $this->assertSame('2500-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1421 $date->set($d2, Zend_Date
::YEAR_8601
, 'en_US');
1422 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1423 $date->setTimeZone('UTC');
1424 $date->set(-20, Zend_Date
::YEAR_8601
, 'en_US');
1425 $this->assertSame('-20-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1426 $date->set($d2, Zend_Date
::YEAR_8601
, 'en_US');
1427 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1428 $date->setTimezone('Indian/Maldives');
1430 $date->set(1234567890);
1432 $date->set('noday', Zend_Date
::YEAR
);
1434 } catch (Zend_Date_Exception
$e) {
1437 $date->set($d2, Zend_Date
::YEAR
);
1438 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1439 $date->set(1970, Zend_Date
::YEAR
);
1440 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1441 $date->set(2020, Zend_Date
::YEAR
);
1442 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1443 $date->set(2040, Zend_Date
::YEAR
);
1444 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1445 $date->setTimeZone('UTC');
1446 $date->set(1900, Zend_Date
::YEAR
);
1447 $this->assertSame('1900-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1448 $date->set($d2, Zend_Date
::YEAR
);
1449 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1450 $date->setTimezone('Indian/Maldives');
1451 $date->set(2500, Zend_Date
::YEAR
, 'en_US');
1452 $this->assertSame('2500-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1453 $date->set($d2, Zend_Date
::YEAR
, 'en_US');
1454 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1455 $date->setTimeZone('UTC');
1456 $date->set(-20, Zend_Date
::YEAR
, 'en_US');
1457 $this->assertSame('-20-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1458 $date->set($d2, Zend_Date
::YEAR
, 'en_US');
1459 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1460 $date->setTimezone('Indian/Maldives');
1462 $date->set(1234567890);
1464 $date->set('noday', Zend_Date
::YEAR_SHORT
);
1466 } catch (Zend_Date_Exception
$e) {
1469 $date->set($d2, Zend_Date
::YEAR_SHORT
);
1470 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1471 $date->set(70, Zend_Date
::YEAR_SHORT
);
1472 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1473 $date->set(20, Zend_Date
::YEAR_SHORT
);
1474 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1475 $date->set(40, Zend_Date
::YEAR_SHORT
);
1476 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1477 $date->setTimeZone('UTC');
1478 $date->set(0, Zend_Date
::YEAR_SHORT
);
1479 $this->assertSame('2000-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1480 $date->set($d2, Zend_Date
::YEAR_SHORT
);
1481 $date->setTimezone('Indian/Maldives');
1482 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1483 $date->set(30, Zend_Date
::YEAR_SHORT
, 'en_US');
1484 $this->assertSame('2030-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1485 $date->set($d2, Zend_Date
::YEAR_SHORT
, 'en_US');
1486 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1487 $date->setTimeZone('UTC');
1488 $date->set(-20, Zend_Date
::YEAR_SHORT
, 'en_US');
1489 $this->assertSame('-20-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1490 $date->set($d2, Zend_Date
::YEAR_SHORT
, 'en_US');
1491 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1492 $date->setTimezone('Indian/Maldives');
1494 $date->set(1234567890);
1496 $date->set('noday', Zend_Date
::YEAR_SHORT_8601
);
1498 } catch (Zend_Date_Exception
$e) {
1501 $date->set($d2, Zend_Date
::YEAR_SHORT_8601
);
1502 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1503 $date->set(70, Zend_Date
::YEAR_SHORT_8601
);
1504 $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1505 $date->set(20, Zend_Date
::YEAR_SHORT_8601
);
1506 $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1507 $date->set(40, Zend_Date
::YEAR_SHORT_8601
);
1508 $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1509 $date->setTimeZone('UTC');
1510 $date->set(0, Zend_Date
::YEAR_SHORT_8601
);
1511 $this->assertSame('2000-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1512 $date->set($d2, Zend_Date
::YEAR_SHORT_8601
);
1513 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1514 $date->setTimezone('Indian/Maldives');
1515 $date->set(30, Zend_Date
::YEAR_SHORT_8601
, 'en_US');
1516 $this->assertSame('2030-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1517 $date->set($d2, Zend_Date
::YEAR_SHORT_8601
, 'en_US');
1518 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1519 $date->setTimeZone('UTC');
1520 $date->set(-20, Zend_Date
::YEAR_SHORT_8601
, 'en_US');
1521 $this->assertSame('-20-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1522 $date->set($d2, Zend_Date
::YEAR_SHORT_8601
, 'en_US');
1523 $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1524 $date->setTimezone('Indian/Maldives');
1526 $date->set(1234567890);
1528 $date->set('noday', Zend_Date
::MERIDIEM
);
1530 } catch (Zend_Date_Exception
$e) {
1534 $date->set(1234567890);
1536 $date->set('noday', Zend_Date
::SWATCH
);
1538 } catch (Zend_Date_Exception
$e) {
1541 $date->set($d2, Zend_Date
::SWATCH
);
1542 $this->assertSame('2009-02-14T00:36:00+05:00', $date->get(Zend_Date
::W3C
));
1543 $date->set(0, Zend_Date
::SWATCH
);
1544 $this->assertSame('2009-02-14T00:00:00+05:00', $date->get(Zend_Date
::W3C
));
1545 $date->set(600, Zend_Date
::SWATCH
);
1546 $this->assertSame('2009-02-14T14:23:59+05:00', $date->get(Zend_Date
::W3C
));
1547 $date->set(1700, Zend_Date
::SWATCH
);
1548 $this->assertSame('2009-02-15T16:47:59+05:00', $date->get(Zend_Date
::W3C
));
1549 $date->setTimeZone('UTC');
1550 $date->set(1900, Zend_Date
::SWATCH
);
1551 $this->assertSame('2009-02-16T21:36:00+00:00', $date->get(Zend_Date
::W3C
));
1552 $date->set($d2, Zend_Date
::SWATCH
);
1553 $this->assertSame('2009-02-17T00:36:00+05:00', $date->get(Zend_Date
::W3C
));
1554 $date->setTimezone('Indian/Maldives');
1555 $date->set(3700, Zend_Date
::SWATCH
, 'en_US');
1556 $this->assertSame('2009-02-20T16:48:00+05:00', $date->get(Zend_Date
::W3C
));
1557 $date->set($d2, Zend_Date
::SWATCH
, 'en_US');
1558 $this->assertSame('2009-02-20T00:36:00+05:00', $date->get(Zend_Date
::W3C
));
1559 $date->setTimeZone('UTC');
1560 $date->set(-200, Zend_Date
::SWATCH
, 'en_US');
1561 $this->assertSame('2009-02-18T19:12:00+00:00', $date->get(Zend_Date
::W3C
));
1562 $date->set($d2, Zend_Date
::SWATCH
, 'en_US');
1563 $this->assertSame('2009-02-19T00:36:00+05:00', $date->get(Zend_Date
::W3C
));
1564 $date->setTimezone('Indian/Maldives');
1566 $date->set(1234567890);
1568 $date->set('noday', Zend_Date
::HOUR_SHORT_AM
);
1570 } catch (Zend_Date_Exception
$e) {
1573 $date->set($d2, Zend_Date
::HOUR_SHORT_AM
);
1574 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1575 $date->set( 3, Zend_Date
::HOUR_SHORT_AM
);
1576 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date
::W3C
));
1577 $date->set( 14, Zend_Date
::HOUR_SHORT_AM
);
1578 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date
::W3C
));
1579 $date->set(-6, Zend_Date
::HOUR_SHORT_AM
);
1580 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date
::W3C
));
1581 $date->setTimeZone('UTC');
1582 $date->set( 30, Zend_Date
::HOUR_SHORT_AM
);
1583 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date
::W3C
));
1584 $date->set($d2, Zend_Date
::HOUR_SHORT_AM
);
1585 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1586 $date->setTimezone('Indian/Maldives');
1587 $date->set( 9, Zend_Date
::HOUR_SHORT_AM
, 'en_US');
1588 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date
::W3C
));
1589 $date->set($d2, Zend_Date
::HOUR_SHORT_AM
, 'en_US');
1590 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1591 $date->setTimeZone('UTC');
1592 $date->set(-26, Zend_Date
::HOUR_SHORT_AM
, 'en_US');
1593 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date
::W3C
));
1594 $date->set($d2, Zend_Date
::HOUR_SHORT_AM
, 'en_US');
1595 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1596 $date->setTimezone('Indian/Maldives');
1598 $date->set(1234567890);
1600 $date->set('noday', Zend_Date
::HOUR_SHORT
);
1602 } catch (Zend_Date_Exception
$e) {
1605 $date->set($d2, Zend_Date
::HOUR_SHORT
);
1606 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1607 $date->set( 3, Zend_Date
::HOUR_SHORT
);
1608 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date
::W3C
));
1609 $date->set( 14, Zend_Date
::HOUR_SHORT
);
1610 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date
::W3C
));
1611 $date->set(-6, Zend_Date
::HOUR_SHORT
);
1612 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date
::W3C
));
1613 $date->setTimeZone('UTC');
1614 $date->set( 30, Zend_Date
::HOUR_SHORT
);
1615 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date
::W3C
));
1616 $date->set($d2, Zend_Date
::HOUR_SHORT
);
1617 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1618 $date->setTimezone('Indian/Maldives');
1619 $date->set( 9, Zend_Date
::HOUR_SHORT
, 'en_US');
1620 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date
::W3C
));
1621 $date->set($d2, Zend_Date
::HOUR_SHORT
, 'en_US');
1622 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1623 $date->setTimeZone('UTC');
1624 $date->set(-26, Zend_Date
::HOUR_SHORT
, 'en_US');
1625 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date
::W3C
));
1626 $date->set($d2, Zend_Date
::HOUR_SHORT
, 'en_US');
1627 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1628 $date->setTimezone('Indian/Maldives');
1630 $date->set(1234567890);
1632 $date->set('noday', Zend_Date
::HOUR_AM
);
1634 } catch (Zend_Date_Exception
$e) {
1637 $date->set($d2, Zend_Date
::HOUR_AM
);
1638 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1639 $date->set( 3, Zend_Date
::HOUR_AM
);
1640 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date
::W3C
));
1641 $date->set( 14, Zend_Date
::HOUR_AM
);
1642 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date
::W3C
));
1643 $date->set(-6, Zend_Date
::HOUR_AM
);
1644 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date
::W3C
));
1645 $date->setTimeZone('UTC');
1646 $date->set( 30, Zend_Date
::HOUR_AM
);
1647 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date
::W3C
));
1648 $date->set($d2, Zend_Date
::HOUR_AM
);
1649 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1650 $date->setTimezone('Indian/Maldives');
1651 $date->set( 9, Zend_Date
::HOUR_AM
, 'en_US');
1652 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date
::W3C
));
1653 $date->set($d2, Zend_Date
::HOUR_AM
, 'en_US');
1654 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1655 $date->setTimeZone('UTC');
1656 $date->set(-26, Zend_Date
::HOUR_AM
, 'en_US');
1657 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date
::W3C
));
1658 $date->set($d2, Zend_Date
::HOUR_AM
, 'en_US');
1659 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1660 $date->setTimezone('Indian/Maldives');
1662 $date->set(1234567890);
1664 $date->set('noday', Zend_Date
::HOUR
);
1666 } catch (Zend_Date_Exception
$e) {
1669 $date->set($d2, Zend_Date
::HOUR
);
1670 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1671 $date->set( 3, Zend_Date
::HOUR
);
1672 $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date
::W3C
));
1673 $date->set( 14, Zend_Date
::HOUR
);
1674 $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date
::W3C
));
1675 $date->set(-6, Zend_Date
::HOUR
);
1676 $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date
::W3C
));
1677 $date->setTimeZone('UTC');
1678 $date->set( 30, Zend_Date
::HOUR
);
1679 $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date
::W3C
));
1680 $date->set($d2, Zend_Date
::HOUR
);
1681 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1682 $date->setTimezone('Indian/Maldives');
1683 $date->set( 9, Zend_Date
::HOUR
, 'en_US');
1684 $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date
::W3C
));
1685 $date->set($d2, Zend_Date
::HOUR
, 'en_US');
1686 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1687 $date->setTimeZone('UTC');
1688 $date->set(-26, Zend_Date
::HOUR
, 'en_US');
1689 $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date
::W3C
));
1690 $date->set($d2, Zend_Date
::HOUR
, 'en_US');
1691 $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
1692 $date->setTimezone('Indian/Maldives');
1694 $date->set(1234567890);
1696 $date->set('noday', Zend_Date
::MINUTE
);
1698 } catch (Zend_Date_Exception
$e) {
1701 $date->set($d2, Zend_Date
::MINUTE
);
1702 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date
::W3C
));
1703 $date->set( 3, Zend_Date
::MINUTE
);
1704 $this->assertSame('2009-02-14T04:03:30+05:00', $date->get(Zend_Date
::W3C
));
1705 $date->set( 65, Zend_Date
::MINUTE
);
1706 $this->assertSame('2009-02-14T05:05:30+05:00', $date->get(Zend_Date
::W3C
));
1707 $date->set(-6, Zend_Date
::MINUTE
);
1708 $this->assertSame('2009-02-14T04:54:30+05:00', $date->get(Zend_Date
::W3C
));
1709 $date->setTimeZone('UTC');
1710 $date->set( 30, Zend_Date
::MINUTE
);
1711 $this->assertSame('2009-02-13T23:30:30+00:00', $date->get(Zend_Date
::W3C
));
1712 $date->set($d2, Zend_Date
::MINUTE
);
1713 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date
::W3C
));
1714 $date->setTimezone('Indian/Maldives');
1715 $date->set( 9, Zend_Date
::MINUTE
, 'en_US');
1716 $this->assertSame('2009-02-14T04:09:30+05:00', $date->get(Zend_Date
::W3C
));
1717 $date->set($d2, Zend_Date
::MINUTE
, 'en_US');
1718 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date
::W3C
));
1719 $date->setTimeZone('UTC');
1720 $date->set(-65, Zend_Date
::MINUTE
, 'en_US');
1721 $this->assertSame('2009-02-13T21:55:30+00:00', $date->get(Zend_Date
::W3C
));
1722 $date->set($d2, Zend_Date
::MINUTE
, 'en_US');
1723 $this->assertSame('2009-02-14T02:36:30+05:00', $date->get(Zend_Date
::W3C
));
1724 $date->setTimezone('Indian/Maldives');
1726 $date->set(1234567890);
1728 $date->set('noday', Zend_Date
::MINUTE_SHORT
);
1730 } catch (Zend_Date_Exception
$e) {
1733 $date->set($d2, Zend_Date
::MINUTE_SHORT
);
1734 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date
::W3C
));
1735 $date->set( 3, Zend_Date
::MINUTE_SHORT
);
1736 $this->assertSame('2009-02-14T04:03:30+05:00', $date->get(Zend_Date
::W3C
));
1737 $date->set( 65, Zend_Date
::MINUTE_SHORT
);
1738 $this->assertSame('2009-02-14T05:05:30+05:00', $date->get(Zend_Date
::W3C
));
1739 $date->set(-6, Zend_Date
::MINUTE_SHORT
);
1740 $this->assertSame('2009-02-14T04:54:30+05:00', $date->get(Zend_Date
::W3C
));
1741 $date->setTimeZone('UTC');
1742 $date->set( 30, Zend_Date
::MINUTE_SHORT
);
1743 $this->assertSame('2009-02-13T23:30:30+00:00', $date->get(Zend_Date
::W3C
));
1744 $date->set($d2, Zend_Date
::MINUTE_SHORT
);
1745 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date
::W3C
));
1746 $date->setTimezone('Indian/Maldives');
1747 $date->set( 9, Zend_Date
::MINUTE_SHORT
, 'en_US');
1748 $this->assertSame('2009-02-14T04:09:30+05:00', $date->get(Zend_Date
::W3C
));
1749 $date->set($d2, Zend_Date
::MINUTE_SHORT
, 'en_US');
1750 $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date
::W3C
));
1751 $date->setTimeZone('UTC');
1752 $date->set(-65, Zend_Date
::MINUTE_SHORT
, 'en_US');
1753 $this->assertSame('2009-02-13T21:55:30+00:00', $date->get(Zend_Date
::W3C
));
1754 $date->set($d2, Zend_Date
::MINUTE_SHORT
, 'en_US');
1755 $this->assertSame('2009-02-14T02:36:30+05:00', $date->get(Zend_Date
::W3C
));
1756 $date->setTimezone('Indian/Maldives');
1758 $date->set(1234567890);
1760 $date->set('noday', Zend_Date
::SECOND
);
1762 } catch (Zend_Date_Exception
$e) {
1765 $date->set($d2, Zend_Date
::SECOND
);
1766 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date
::W3C
));
1767 $date->set( 3, Zend_Date
::SECOND
);
1768 $this->assertSame('2009-02-14T04:31:03+05:00', $date->get(Zend_Date
::W3C
));
1769 $date->set( 65, Zend_Date
::SECOND
);
1770 $this->assertSame('2009-02-14T04:32:05+05:00', $date->get(Zend_Date
::W3C
));
1771 $date->set(-6, Zend_Date
::SECOND
);
1772 $this->assertSame('2009-02-14T04:31:54+05:00', $date->get(Zend_Date
::W3C
));
1773 $date->setTimeZone('UTC');
1774 $date->set( 30, Zend_Date
::SECOND
);
1775 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1776 $date->set($d2, Zend_Date
::SECOND
);
1777 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date
::W3C
));
1778 $date->setTimezone('Indian/Maldives');
1779 $date->set( 9, Zend_Date
::SECOND
, 'en_US');
1780 $this->assertSame('2009-02-14T04:31:09+05:00', $date->get(Zend_Date
::W3C
));
1781 $date->set($d2, Zend_Date
::SECOND
, 'en_US');
1782 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date
::W3C
));
1783 $date->setTimeZone('UTC');
1784 $date->set(-65, Zend_Date
::SECOND
, 'en_US');
1785 $this->assertSame('2009-02-13T23:29:55+00:00', $date->get(Zend_Date
::W3C
));
1786 $date->set($d2, Zend_Date
::SECOND
, 'en_US');
1787 $this->assertSame('2009-02-14T04:29:50+05:00', $date->get(Zend_Date
::W3C
));
1788 $date->setTimezone('Indian/Maldives');
1790 $date->set(1234567890);
1792 $date->set('noday', Zend_Date
::SECOND_SHORT
);
1794 } catch (Zend_Date_Exception
$e) {
1797 $date->set($d2, Zend_Date
::SECOND_SHORT
);
1798 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date
::W3C
));
1799 $date->set( 3, Zend_Date
::SECOND_SHORT
);
1800 $this->assertSame('2009-02-14T04:31:03+05:00', $date->get(Zend_Date
::W3C
));
1801 $date->set( 65, Zend_Date
::SECOND_SHORT
);
1802 $this->assertSame('2009-02-14T04:32:05+05:00', $date->get(Zend_Date
::W3C
));
1803 $date->set(-6, Zend_Date
::SECOND_SHORT
);
1804 $this->assertSame('2009-02-14T04:31:54+05:00', $date->get(Zend_Date
::W3C
));
1805 $date->setTimeZone('UTC');
1806 $date->set( 30, Zend_Date
::SECOND_SHORT
);
1807 $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date
::W3C
));
1808 $date->set($d2, Zend_Date
::SECOND_SHORT
);
1809 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date
::W3C
));
1810 $date->setTimezone('Indian/Maldives');
1811 $date->set( 9, Zend_Date
::SECOND_SHORT
, 'en_US');
1812 $this->assertSame('2009-02-14T04:31:09+05:00', $date->get(Zend_Date
::W3C
));
1813 $date->set($d2, Zend_Date
::SECOND_SHORT
, 'en_US');
1814 $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date
::W3C
));
1815 $date->setTimeZone('UTC');
1816 $date->set(-65, Zend_Date
::SECOND_SHORT
, 'en_US');
1817 $this->assertSame('2009-02-13T23:29:55+00:00', $date->get(Zend_Date
::W3C
));
1818 $date->set($d2, Zend_Date
::SECOND_SHORT
, 'en_US');
1819 $this->assertSame('2009-02-14T04:29:50+05:00', $date->get(Zend_Date
::W3C
));
1820 $date->setTimezone('Indian/Maldives');
1822 $date->set(1234567890);
1824 $date->set('noday', Zend_Date
::MILLISECOND
);
1826 } catch (Zend_Date_Exception
$e) {
1829 $date->set($d2, Zend_Date
::MILLISECOND
);
1830 $this->assertSame('000', $date->get(Zend_Date
::MILLISECOND
));
1831 $date->set( 3, Zend_Date
::MILLISECOND
);
1832 $this->assertSame('003', $date->get(Zend_Date
::MILLISECOND
));
1833 $date->set( 1065, Zend_Date
::MILLISECOND
);
1834 $this->assertSame('065', $date->get(Zend_Date
::MILLISECOND
));
1835 $date->set(-6, Zend_Date
::MILLISECOND
);
1836 $this->assertSame('994', $date->get(Zend_Date
::MILLISECOND
));
1837 $date->set( 30, Zend_Date
::MILLISECOND
, true);
1838 $this->assertSame('030', $date->get(Zend_Date
::MILLISECOND
));
1839 $date->set($d2, Zend_Date
::MILLISECOND
, true);
1840 $this->assertSame('000', $date->get(Zend_Date
::MILLISECOND
));
1841 $date->set( 9, Zend_Date
::MILLISECOND
, false, 'en_US');
1842 $this->assertSame('009', $date->get(Zend_Date
::MILLISECOND
));
1843 $date->set($d2, Zend_Date
::MILLISECOND
, false, 'en_US');
1844 $this->assertSame('000', $date->get(Zend_Date
::MILLISECOND
));
1845 $date->set(-65, Zend_Date
::MILLISECOND
, true , 'en_US');
1846 $this->assertSame('935', $date->get(Zend_Date
::MILLISECOND
));
1847 $date->set($d2, Zend_Date
::MILLISECOND
, true , 'en_US');
1848 $this->assertSame('000', $date->get(Zend_Date
::MILLISECOND
));
1850 $date->set(1234567890);
1852 $date->set('noday', Zend_Date
::TIMEZONE_NAME
);
1854 } catch (Zend_Date_Exception
$e) {
1858 $date->set(1234567890);
1860 $date->set('noday', Zend_Date
::DAYLIGHT
);
1862 } catch (Zend_Date_Exception
$e) {
1866 $date->set(1234567890);
1868 $date->set('noday', Zend_Date
::GMT_DIFF
);
1870 } catch (Zend_Date_Exception
$e) {
1874 $date->set(1234567890);
1876 $date->set('noday', Zend_Date
::GMT_DIFF_SEP
);
1878 } catch (Zend_Date_Exception
$e) {
1882 $date->set(1234567890);
1884 $date->set('noday', Zend_Date
::TIMEZONE
);
1886 } catch (Zend_Date_Exception
$e) {
1890 $date->set(1234567890);
1892 $date->set('noday', Zend_Date
::TIMEZONE_SECS
);
1894 } catch (Zend_Date_Exception
$e) {
1898 $date->set(1234567890);
1900 $date->set('noday', Zend_Date
::ISO_8601
);
1902 } catch (Zend_Date_Exception
$e) {
1905 $date->set($d2, Zend_Date
::ISO_8601
);
1906 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
1907 $date->set(1234567890);
1908 $date->set('2007-10-20 20:10:30', Zend_Date
::ISO_8601
);
1909 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1910 $date->set(1234567890);
1911 $date->set('2007-10-20 201030', Zend_Date
::ISO_8601
);
1912 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1913 $date->set(1234567890);
1914 $date->set('07-10-20 20:10:30', Zend_Date
::ISO_8601
);
1915 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1916 $date->set(1234567890);
1917 $date->set('80-10-20 20:10:30', Zend_Date
::ISO_8601
);
1918 $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1919 $date->set(1234567890);
1920 $date->set('-2007-10-20 20:10:30', Zend_Date
::ISO_8601
);
1921 $this->assertSame('-2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1922 $date->set(1234567890);
1923 $date->set('-07-10-20 20:10:30', Zend_Date
::ISO_8601
);
1924 $this->assertSame('-7-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1925 $date->set(1234567890);
1926 $date->set('2007-10-20T20:10:30', Zend_Date
::ISO_8601
);
1927 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1928 $date->set(1234567890);
1929 $date->set('2007-10-20T201030', Zend_Date
::ISO_8601
);
1930 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1931 $date->set(1234567890);
1932 $date->set('20-10-20T20:10:30', Zend_Date
::ISO_8601
);
1933 $this->assertSame('2020-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1934 $date->set(1234567890);
1935 $date->set('80-10-20T20:10:30', Zend_Date
::ISO_8601
);
1936 $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1937 $date->set(1234567890);
1938 $date->set('-2007-10-20T20:10:30', Zend_Date
::ISO_8601
);
1939 $this->assertSame('-2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1940 $date->set(1234567890);
1941 $date->set('-07-10-20T20:10:30', Zend_Date
::ISO_8601
);
1942 $this->assertSame('-7-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1943 $date->set(1234567890);
1944 $date->set('20071020 20:10:30', Zend_Date
::ISO_8601
);
1945 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1946 $date->set(1234567890);
1947 $date->set('201020 20:10:30', Zend_Date
::ISO_8601
);
1948 $this->assertSame('2020-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1949 $date->set(1234567890);
1950 $date->set('801020 20:10:30', Zend_Date
::ISO_8601
);
1951 $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1952 $date->set(1234567890);
1953 $date->set('-071020 20:10:30', Zend_Date
::ISO_8601
);
1954 $this->assertSame('-7-10-20T20:10:30-07:00', $date->get(Zend_Date
::W3C
));
1955 $date->set(1234567890);
1956 $date->set('-00071020 20:10:30', Zend_Date
::ISO_8601
);
1957 $this->assertSame('-7-10-20T20:10:30+00:00', $date->get(Zend_Date
::W3C
));
1958 $date->setTimezone('Indian/Maldives');
1959 $date->set(1234567890);
1960 $date->set('20071020T20:10:30', Zend_Date
::ISO_8601
);
1961 $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date
::W3C
));
1962 $date->set(1234567890);
1963 $date->set('-00071020T20:10:30', Zend_Date
::ISO_8601
);
1964 $this->assertSame('-7-10-20T20:10:30+00:00', $date->get(Zend_Date
::W3C
));
1965 $date->setTimezone('Indian/Maldives');
1966 $date->set(1234567890);
1967 $date->set('2007-10-20', Zend_Date
::ISO_8601
);
1968 $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date
::W3C
));
1969 $date->set(1234567890);
1970 $date->set('20071020', Zend_Date
::ISO_8601
);
1971 $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date
::W3C
));
1972 $date->set(1234567890);
1973 $date->set('20071020122030', Zend_Date
::ISO_8601
);
1974 $this->assertSame('2007-10-20T12:20:30+05:00', $date->get(Zend_Date
::W3C
));
1975 $date->set(1234567890);
1976 $date->set('071020', Zend_Date
::ISO_8601
);
1977 $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date
::W3C
));
1978 $date->set(1234567890);
1979 $date->set('07:10:20', Zend_Date
::ISO_8601
);
1980 $this->assertSame('1970-01-01T07:10:20+05:00', $date->get(Zend_Date
::W3C
));
1982 $date->set(1234567890);
1984 $date->set('noday', Zend_Date
::RFC_2822
);
1986 } catch (Zend_Date_Exception
$e) {
1989 $date->set($d2, Zend_Date
::RFC_2822
);
1990 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
1991 $date->set(1234567890);
1992 $date->set('Thu, 05 Jan 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
1993 $this->assertSame('2009-01-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
1994 $date->set(1234567890);
1995 $date->set('Thu, 05 Feb 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
1996 $this->assertSame('2009-02-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
1997 $date->set(1234567890);
1998 $date->set('Thu, 05 Mar 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
1999 $this->assertSame('2009-03-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2000 $date->set(1234567890);
2001 $date->set('Thu, 05 Apr 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2002 $this->assertSame('2009-04-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2003 $date->set(1234567890);
2004 $date->set('Thu, 05 May 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2005 $this->assertSame('2009-05-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2006 $date->set(1234567890);
2007 $date->set('Thu, 05 Jun 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2008 $this->assertSame('2009-06-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2009 $date->set(1234567890);
2010 $date->set('Thu, 05 Jul 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2011 $this->assertSame('2009-07-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2012 $date->set(1234567890);
2013 $date->set('Thu, 05 Aug 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2014 $this->assertSame('2009-08-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2015 $date->set(1234567890);
2016 $date->set('Thu, 05 Sep 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2017 $this->assertSame('2009-09-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2018 $date->set(1234567890);
2019 $date->set('Thu, 05 Oct 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2020 $this->assertSame('2009-10-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2021 $date->set(1234567890);
2022 $date->set('Thu, 05 Nov 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2023 $this->assertSame('2009-11-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2024 $date->set(1234567890);
2025 $date->set('Thu, 05 Dec 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2026 $this->assertSame('2009-12-05T01:31:30+05:00', $date->get(Zend_Date
::W3C
));
2027 $date->set(1234567890);
2029 $date->set('Thu, 05 Fxx 2009 01:31:30 +0500', Zend_Date
::RFC_2822
);
2031 } catch (Zend_Date_Exception
$e) {
2035 $date->set(1234567890);
2037 $date->set('noday', Zend_Date
::TIMESTAMP
);
2039 } catch (Zend_Date_Exception
$e) {
2042 $date->set($d2, Zend_Date
::TIMESTAMP
);
2043 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2044 $date->set(1234567890);
2045 $date->set('1010101099', Zend_Date
::TIMESTAMP
);
2046 $this->assertSame('2002-01-04T04:38:19+05:00', $date->get(Zend_Date
::W3C
));
2048 $date->set(1234567890);
2050 $date->set('noday', Zend_Date
::ERA
);
2052 } catch (Zend_Date_Exception
$e) {
2056 $date->set(1234567890);
2058 $date->set('noday', Zend_Date
::ERA_NAME
);
2060 } catch (Zend_Date_Exception
$e) {
2064 $date->set(1234567890);
2066 $date->set('noday', Zend_Date
::DATES
);
2068 } catch (Zend_Date_Exception
$e) {
2071 $date->set($d2, Zend_Date
::DATES
);
2072 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2073 $date->set(1234567890);
2074 $date->set('14.02.2009', Zend_Date
::DATES
);
2075 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2077 $date->set(1234567890);
2079 $date->set('noday', Zend_Date
::DATE_FULL
);
2081 } catch (Zend_Date_Exception
$e) {
2084 $date->set($d2, Zend_Date
::DATE_FULL
);
2085 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2086 $date->set(1234567890);
2087 $date->set('Samstag, 14. Februar 2009', Zend_Date
::DATE_FULL
);
2088 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2090 $date->set(1234567890);
2092 $date->set('noday', Zend_Date
::DATE_LONG
);
2094 } catch (Zend_Date_Exception
$e) {
2097 $date->set($d2, Zend_Date
::DATE_LONG
);
2098 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2099 $date->set(1234567890);
2100 $date->set('14. Februar 2009', Zend_Date
::DATE_LONG
);
2101 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2103 $date->set(1234567890);
2105 $date->set('noday', Zend_Date
::DATE_MEDIUM
);
2107 } catch (Zend_Date_Exception
$e) {
2110 $date->set($d2, Zend_Date
::DATE_MEDIUM
);
2111 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2112 $date->set(1234567890);
2113 $date->set('14.02.2009', Zend_Date
::DATE_MEDIUM
);
2114 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2116 $date->set(1234567890);
2118 $date->set('noday', Zend_Date
::DATE_SHORT
);
2120 } catch (Zend_Date_Exception
$e) {
2123 $date->set($d2, Zend_Date
::DATE_SHORT
);
2124 $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2125 $date->set(1234567890);
2126 $date->set('14.02.09', Zend_Date
::DATE_SHORT
);
2127 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
2129 $date->set(1234567890);
2131 $date->set('noday', Zend_Date
::TIMES
);
2133 } catch (Zend_Date_Exception
$e) {
2136 $date->set($d2, Zend_Date
::TIMES
);
2137 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2138 $date->set(1234567890);
2139 $date->set('15:26:40', Zend_Date
::TIMES
);
2140 $this->assertSame('2009-02-14T15:26:40+05:00', $date->get(Zend_Date
::W3C
));
2142 $date->set(1234567890);
2144 $date->set('noday', Zend_Date
::TIME_FULL
);
2146 } catch (Zend_Date_Exception
$e) {
2149 $date->set($d2, Zend_Date
::TIME_FULL
);
2150 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2151 $date->set(1234567890);
2152 $date->set('15:26 Uhr CET', Zend_Date
::TIME_FULL
);
2153 $this->assertSame('2009-02-14T15:26:00+01:00', $date->get(Zend_Date
::W3C
));
2155 $date->set(1234567890);
2157 $date->set('noday', Zend_Date
::TIME_LONG
);
2159 } catch (Zend_Date_Exception
$e) {
2162 $date->set($d2, Zend_Date
::TIME_LONG
);
2163 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2164 $date->set(1234567890);
2165 $date->set('15:26:40 CET', Zend_Date
::TIME_LONG
);
2166 $this->assertSame('2009-02-14T15:26:40+01:00', $date->get(Zend_Date
::W3C
));
2168 $date->setTimezone('Indian/Maldives');
2169 $date->set(1234567890);
2171 $date->set('noday', Zend_Date
::TIME_MEDIUM
);
2173 } catch (Zend_Date_Exception
$e) {
2176 $date->set($d2, Zend_Date
::TIME_MEDIUM
);
2177 $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2178 $date->set(1234567890);
2179 $date->set('15:26:40', Zend_Date
::TIME_MEDIUM
);
2180 $this->assertSame('2009-02-14T15:26:40+05:00', $date->get(Zend_Date
::W3C
));
2182 $date->set(1234567890);
2184 $date->set('noday', Zend_Date
::TIME_SHORT
);
2186 } catch (Zend_Date_Exception
$e) {
2189 $date->set($d2, Zend_Date
::TIME_SHORT
);
2190 $this->assertSame('2009-02-14T04:36:00+05:00', $date->get(Zend_Date
::W3C
));
2191 $date->set(1234567890);
2192 $date->set('15:26', Zend_Date
::TIME_SHORT
);
2193 $this->assertSame('2009-02-14T15:26:00+05:00', $date->get(Zend_Date
::W3C
));
2195 $date->set(1234567890);
2197 $date->set('noday', Zend_Date
::DATETIME
);
2199 } catch (Zend_Date_Exception
$e) {
2202 $date->set($d2, Zend_Date
::DATETIME
);
2203 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2204 $date->set(1234567890);
2205 $date->set('14.02.2009 15:26:03', Zend_Date
::DATETIME
);
2206 $this->assertSame('2009-02-14T15:26:03+05:00', $date->get(Zend_Date
::W3C
));
2208 $date->set(1234567890);
2210 $date->set('noday', Zend_Date
::DATETIME_FULL
);
2212 } catch (Zend_Date_Exception
$e) {
2215 $date->set($d2, Zend_Date
::DATETIME_FULL
);
2216 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2217 $date->set(1234567890);
2218 $date->set('Samstag, 14. Februar 2009 15:26 Uhr CET', Zend_Date
::DATETIME_FULL
);
2219 $this->assertSame('2009-02-14T15:26:00+01:00', $date->get(Zend_Date
::W3C
));
2221 $date->set(1234567890);
2223 $date->set('noday', Zend_Date
::DATETIME_LONG
);
2225 } catch (Zend_Date_Exception
$e) {
2228 $date->set($d2, Zend_Date
::DATETIME_LONG
);
2229 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2230 $date->set(1234567890);
2231 $date->set('14. Februar 2009 15:26:03 CET', Zend_Date
::DATETIME_LONG
);
2232 $this->assertSame('2009-02-14T15:26:03+01:00', $date->get(Zend_Date
::W3C
));
2234 $date->set(1234567890);
2236 $date->set('noday', Zend_Date
::DATETIME_MEDIUM
);
2238 } catch (Zend_Date_Exception
$e) {
2241 $date->set($d2, Zend_Date
::DATETIME_MEDIUM
);
2242 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2243 $date->set(1234567890);
2244 $date->set('14.02.2009 15:26:31', Zend_Date
::DATETIME_MEDIUM
);
2245 $this->assertSame('2009-02-14T15:26:31+05:00', $date->get(Zend_Date
::W3C
));
2247 $date->set(1234567890);
2249 $date->set('noday', Zend_Date
::DATETIME_SHORT
);
2251 } catch (Zend_Date_Exception
$e) {
2254 $date->set($d2, Zend_Date
::DATETIME_SHORT
);
2255 $this->assertSame('2002-01-04T04:36:00+05:00', $date->get(Zend_Date
::W3C
));
2256 $date->set(1234567890);
2257 $date->set('14.02.09 15:26', Zend_Date
::DATETIME_SHORT
);
2258 $this->assertSame('2009-02-14T15:26:00+05:00', $date->get(Zend_Date
::W3C
));
2260 $date->set(1234567890);
2262 $date->set('noday', Zend_Date
::ATOM
);
2264 } catch (Zend_Date_Exception
$e) {
2267 $date->set($d2, Zend_Date
::ATOM
);
2268 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2269 $date->set(1234567890);
2270 $date->set('2009-02-14T00:31:30+05:00', Zend_Date
::ATOM
);
2271 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2273 $date->set(1234567890);
2275 $date->set('noday', Zend_Date
::COOKIE
);
2277 } catch (Zend_Date_Exception
$e) {
2280 $date->set($d2, Zend_Date
::COOKIE
);
2281 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2282 $date->set(1234567890);
2283 $date->set('Saturday, 14-Feb-09 00:31:30 Europe/Vienna', Zend_Date
::COOKIE
);
2284 $this->assertSame('2009-02-14T00:31:30+01:00', $date->get(Zend_Date
::W3C
));
2286 $date->set(1234567890);
2288 $date->set('noday', Zend_Date
::RFC_822
);
2290 } catch (Zend_Date_Exception
$e) {
2293 $date->set($d2, Zend_Date
::RFC_822
);
2294 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2295 $date->set(1234567890);
2296 $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date
::RFC_822
);
2297 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2299 $date->set(1234567890);
2301 $date->set('noday', Zend_Date
::RFC_850
);
2303 } catch (Zend_Date_Exception
$e) {
2306 $date->set($d2, Zend_Date
::RFC_850
);
2307 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2308 $date->set(1234567890);
2309 $date->set('Saturday, 14-Feb-09 00:31:30 Europe/Vienna', Zend_Date
::RFC_850
);
2310 $this->assertSame('2009-02-14T00:31:30+01:00', $date->get(Zend_Date
::W3C
));
2312 $date->set(1234567890);
2314 $date->set('noday', Zend_Date
::RFC_1036
);
2316 } catch (Zend_Date_Exception
$e) {
2319 $date->set($d2, Zend_Date
::RFC_1036
);
2320 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2321 $date->set(1234567890);
2322 $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date
::RFC_1036
);
2323 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2325 $date->set(1234567890);
2327 $date->set('noday', Zend_Date
::RFC_1123
);
2329 } catch (Zend_Date_Exception
$e) {
2332 $date->set($d2, Zend_Date
::RFC_1123
);
2333 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2334 $date->set(1234567890);
2335 $date->set('Sat, 14 Feb 2009 00:31:30 +0500', Zend_Date
::RFC_1123
);
2336 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2338 $date->set(1234567890);
2340 $date->set('noday', Zend_Date
::RFC_3339
);
2342 } catch (Zend_Date_Exception
$e) {
2345 $date->set($d2, Zend_Date
::RFC_3339
);
2346 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2347 $date->set(1234567890);
2348 $date->set('2009-02-14T00:31:30+05:00', Zend_Date
::RFC_3339
);
2349 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2351 $date->set(1234567890);
2353 $date->set('noday', Zend_Date
::RSS
);
2355 } catch (Zend_Date_Exception
$e) {
2358 $date->set($d2, Zend_Date
::RSS
);
2359 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2360 $date->set(1234567890);
2361 $date->set('Sat, 14 Feb 2009 00:31:30 +0500', Zend_Date
::RSS
);
2362 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2363 $date->set('Sat, 14 Feb 2009 00:31:30 GMT', Zend_Date
::RSS
);
2364 $this->assertSame('2009-02-14T00:31:30+00:00', $date->get(Zend_Date
::W3C
));
2365 $date->set('Sat, 14 Feb 09 00:31:30 GMT', Zend_Date
::RSS
);
2366 $this->assertSame('2009-02-14T00:31:30+00:00', $date->get(Zend_Date
::W3C
));
2367 $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date
::RSS
);
2368 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2370 $date->set(1234567890);
2372 $date->set('noday', Zend_Date
::W3C
);
2374 } catch (Zend_Date_Exception
$e) {
2377 $date->set($d2, Zend_Date
::W3C
);
2378 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2379 $date->set(1234567890);
2380 $date->set('2009-02-14T00:31:30+05:00', Zend_Date
::W3C
);
2381 $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date
::W3C
));
2382 $date->set('2009-02-14T00:31:30-05:00', Zend_Date
::W3C
);
2383 $this->assertSame('2009-02-14T00:31:30-05:00', $date->get(Zend_Date
::W3C
));
2385 $date->setTimezone('Indian/Maldives');
2386 $date->set(1234567890);
2388 $date->set('noday', 'xx');
2390 } catch (Zend_Date_Exception
$e) {
2394 $date->set($d2, 'xx');
2396 } catch (Zend_Date_Exception
$e) {
2399 $date->set(1234567890);
2400 $date->set('1000', 'xx');
2401 $this->assertSame('1970-01-01T05:16:40+05:00', $date->get(Zend_Date
::W3C
));
2407 public function testAdd()
2409 $locale = new Zend_Locale('de_AT');
2410 $date = new Zend_Date(0,null,$locale);
2411 $d2 = new Zend_Date(1010101010,null,$locale);
2413 $retour = $date->set(1234567890);
2414 $this->assertSame($retour->getTimestamp(),'1234567890');
2415 $this->assertSame($date->add(10)->getTimestamp(),'1234567900');
2416 $this->assertSame($date->add(-10)->getTimestamp(),'1234567890');
2417 $this->assertSame($date->add(0)->getTimestamp(),'1234567890');
2420 $date->add(10, Zend_Date
::DAY
);
2421 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2422 $date->add(-10, Zend_Date
::DAY
);
2423 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2426 $date->add('Mon', Zend_Date
::WEEKDAY_SHORT
);
2427 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2430 $date->add(10, Zend_Date
::DAY_SHORT
);
2431 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2432 $date->add(-10, Zend_Date
::DAY_SHORT
);
2433 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2436 $date->add('Montag', Zend_Date
::WEEKDAY
);
2437 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2440 $date->add(1, Zend_Date
::WEEKDAY_8601
);
2441 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2445 $date->add($d2, Zend_Date
::DAY_SUFFIX
);
2446 $this->fail('exception expected');
2447 } catch (Zend_Date_Exception
$e) {
2456 public function testAdd2()
2458 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
2459 $this->markTestSkipped('Extended I18N test skipped');
2463 $locale = new Zend_Locale('de_AT');
2464 $date = new Zend_Date(0,null,$locale);
2465 $d2 = new Zend_Date(1010101010,null,$locale);
2468 $date->add(1, Zend_Date
::WEEKDAY_DIGIT
);
2469 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2472 $date->add(10, Zend_Date
::DAY_OF_YEAR
);
2473 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2474 $date->add(-10, Zend_Date
::DAY_OF_YEAR
);
2475 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2478 $date->add('M', Zend_Date
::WEEKDAY_NARROW
);
2479 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2482 $date->add('Mo.', Zend_Date
::WEEKDAY_NAME
);
2483 $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2486 $date->add(10, Zend_Date
::WEEK
);
2487 $this->assertSame('2002-03-15T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2488 $date->add(-10, Zend_Date
::WEEK
);
2489 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2492 $date->add('April', Zend_Date
::MONTH_NAME
);
2493 $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2496 $date->add(10, Zend_Date
::MONTH
);
2497 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2498 $date->add(-10, Zend_Date
::MONTH
);
2499 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2502 $date->add('Apr', Zend_Date
::MONTH_NAME_SHORT
);
2503 $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2506 $date->add(10, Zend_Date
::MONTH_SHORT
);
2507 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2508 $date->add(-10, Zend_Date
::MONTH_SHORT
);
2509 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2513 $date->add($d2, Zend_Date
::MONTH_DAYS
);
2514 $this->fail('exception expected');
2515 } catch (Zend_Date_Exception
$e) {
2520 $date->add('M', Zend_Date
::MONTH_NAME_NARROW
);
2521 $this->assertSame('2002-06-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2525 $date->add($d2, Zend_Date
::LEAPYEAR
);
2526 $this->fail('exception expected');
2527 } catch (Zend_Date_Exception
$e) {
2532 $date->add(10, Zend_Date
::YEAR_8601
);
2533 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2534 $date->add(-10, Zend_Date
::YEAR_8601
);
2535 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2538 $date->add(10, Zend_Date
::YEAR
);
2539 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2540 $date->add(-10, Zend_Date
::YEAR
);
2541 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2544 $date->add(10, Zend_Date
::YEAR_SHORT
);
2545 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2546 $date->add(-10, Zend_Date
::YEAR_SHORT
);
2547 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2550 $date->add(10, Zend_Date
::YEAR_SHORT_8601
);
2551 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2552 $date->add(-10, Zend_Date
::YEAR_SHORT_8601
);
2553 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2557 $date->add('noday', Zend_Date
::MERIDIEM
);
2559 } catch (Zend_Date_Exception
$e) {
2564 $date->add(10, Zend_Date
::SWATCH
);
2565 $this->assertSame('2002-01-04T04:51:14+05:00', $date->get(Zend_Date
::W3C
));
2566 $date->add(-10, Zend_Date
::SWATCH
);
2567 $this->assertSame('2002-01-04T04:36:49+05:00', $date->get(Zend_Date
::W3C
));
2570 $date->add(10, Zend_Date
::HOUR_SHORT_AM
);
2571 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2572 $date->add(-10, Zend_Date
::HOUR_SHORT_AM
);
2573 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2576 $date->add(10, Zend_Date
::HOUR_SHORT
);
2577 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2578 $date->add(-10, Zend_Date
::HOUR_SHORT
);
2579 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2582 $date->add(10, Zend_Date
::HOUR_AM
);
2583 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2584 $date->add(-10, Zend_Date
::HOUR_AM
);
2585 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2588 $date->add(10, Zend_Date
::HOUR
);
2589 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2590 $date->add(-10, Zend_Date
::HOUR
);
2591 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2594 $date->add(10, Zend_Date
::MINUTE
);
2595 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date
::W3C
));
2596 $date->add(-10, Zend_Date
::MINUTE
);
2597 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2600 $date->add(10, Zend_Date
::MINUTE_SHORT
);
2601 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date
::W3C
));
2602 $date->add(-10, Zend_Date
::MINUTE_SHORT
);
2603 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2606 $date->add(10, Zend_Date
::SECOND
);
2607 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
2608 $date->add(-10, Zend_Date
::SECOND
);
2609 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2612 $date->add(10, Zend_Date
::SECOND_SHORT
);
2613 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
2614 $date->add(-10, Zend_Date
::SECOND_SHORT
);
2615 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2618 $date->add(10, Zend_Date
::MILLISECOND
);
2619 $this->assertSame('010', $date->get(Zend_Date
::MILLISECOND
));
2620 $date->add(-10, Zend_Date
::MILLISECOND
);
2621 $this->assertSame( '000', $date->get(Zend_Date
::MILLISECOND
));
2625 $date->add('noday', Zend_Date
::TIMEZONE_NAME
);
2627 } catch (Zend_Date_Exception
$e) {
2633 $date->add('noday', Zend_Date
::DAYLIGHT
);
2635 } catch (Zend_Date_Exception
$e) {
2641 $date->add('noday', Zend_Date
::GMT_DIFF
);
2643 } catch (Zend_Date_Exception
$e) {
2649 $date->add('noday', Zend_Date
::GMT_DIFF_SEP
);
2651 } catch (Zend_Date_Exception
$e) {
2657 $date->add('noday', Zend_Date
::TIMEZONE
);
2659 } catch (Zend_Date_Exception
$e) {
2665 $date->add('noday', Zend_Date
::TIMEZONE_SECS
);
2667 } catch (Zend_Date_Exception
$e) {
2672 $date->add('1000-01-02 20:05:12', Zend_Date
::ISO_8601
);
2673 $this->assertSame('3002-02-07T19:42:02+05:00', $date->get(Zend_Date
::W3C
));
2676 $date->add('Thu, 02 Jan 1000 20:05:12 +0500', Zend_Date
::RFC_2822
);
2677 $this->assertSame('3002-02-07T19:42:02+05:00', $date->get(Zend_Date
::W3C
));
2680 $date->add(10, Zend_Date
::TIMESTAMP
);
2681 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
2685 $date->add('noday', Zend_Date
::ERA
);
2687 } catch (Zend_Date_Exception
$e) {
2693 $date->add('noday', Zend_Date
::ERA_NAME
);
2695 } catch (Zend_Date_Exception
$e) {
2700 $date->add('10.02.0005', Zend_Date
::DATES
);
2701 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2704 $date->add('Samstag, 10. Februar 0005', Zend_Date
::DATE_FULL
);
2705 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2708 $date->add('10. Februar 0005', Zend_Date
::DATE_LONG
);
2709 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2712 $date->add('10.02.0005', Zend_Date
::DATE_MEDIUM
);
2713 $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2716 $date->add('10.02.05', Zend_Date
::DATE_SHORT
);
2717 $this->assertSame('4007-03-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2720 $date->add('10:05:05', Zend_Date
::TIMES
);
2721 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
2724 $date->add('10:05 Uhr CET', Zend_Date
::TIME_FULL
);
2725 $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date
::W3C
));
2728 $date->add('10:05:05 CET', Zend_Date
::TIME_LONG
);
2729 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
2732 $date->add('10:05:05', Zend_Date
::TIME_MEDIUM
);
2733 $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
2736 $date->add('10:05', Zend_Date
::TIME_SHORT
);
2737 $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date
::W3C
));
2740 $date->add('10.02.0005 10:05:05', Zend_Date
::DATETIME
);
2741 $this->assertSame('2007-03-14T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
2744 $date->add('Samstag, 10. Februar 0005 10:05 Uhr CET', Zend_Date
::DATETIME_FULL
);
2745 $this->assertSame('2007-03-14T14:41:50+05:00', $date->get(Zend_Date
::W3C
));
2748 $date->add('10. Februar 0005 10:05:05 CET', Zend_Date
::DATETIME_LONG
);
2749 $this->assertSame('2007-03-14T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
2752 $date->add('10.02.0005 10:05:05', Zend_Date
::DATETIME_MEDIUM
);
2753 $this->assertSame('2007-03-14T14:41:55+05:00', $date->get(Zend_Date
::W3C
));
2756 $date->add('10.02.05 10:05', Zend_Date
::DATETIME_SHORT
);
2757 $this->assertSame('4007-03-14T14:41:50+05:00', $date->get(Zend_Date
::W3C
));
2760 $date->add('1000-01-02T20:05:12+05:00', Zend_Date
::ATOM
);
2761 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2764 $date->add('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date
::COOKIE
);
2765 $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2768 $date->add('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date
::RFC_822
);
2769 $this->assertSame('4002-02-06T19:42:02+05:00', $date->get(Zend_Date
::W3C
));
2772 $date->add('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date
::RFC_850
);
2773 $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2776 $date->add('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date
::RFC_1036
);
2777 $this->assertSame('4002-02-06T19:42:02+05:00', $date->get(Zend_Date
::W3C
));
2780 $date->add('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date
::RFC_1123
);
2781 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2784 $date->add('1000-01-02T20:05:12+05:00', Zend_Date
::RFC_3339
);
2785 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2788 $date->add('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date
::RSS
);
2789 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2792 $date->add('1000-01-02T20:05:12+05:00', Zend_Date
::W3C
);
2793 $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date
::W3C
));
2796 $date->add('1000', 'xx');
2797 $this->assertSame('2002-01-04T04:53:30+05:00', $date->get(Zend_Date
::W3C
));
2803 public function testSub()
2805 $locale = new Zend_Locale('de_AT');
2806 $date = new Zend_Date(0,null,$locale);
2807 $d2 = new Zend_Date(1010101010,null,$locale);
2809 $retour = $date->set(1234567890);
2810 $this->assertSame('1234567890', $retour->getTimestamp());
2811 $this->assertSame('1234567900', $date->sub(-10)->getTimestamp());
2812 $this->assertSame('1234567890', $date->sub( 10)->getTimestamp());
2813 $this->assertSame('1234567890', $date->sub( 0)->getTimestamp());
2816 $date->sub(-10, Zend_Date
::DAY
);
2817 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2818 $date->sub(10, Zend_Date
::DAY
);
2819 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2825 public function testSub2()
2827 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
2828 $this->markTestSkipped('Extended I18N test skipped');
2832 $locale = new Zend_Locale('de_AT');
2833 $date = new Zend_Date(0,null,$locale);
2834 $d2 = new Zend_Date(1010101010,null,$locale);
2837 $date->sub('Mon', Zend_Date
::WEEKDAY_SHORT
);
2838 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2841 $date->sub(-10, Zend_Date
::DAY_SHORT
);
2842 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2843 $date->sub(10, Zend_Date
::DAY_SHORT
);
2844 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2847 $date->sub('Montag', Zend_Date
::WEEKDAY
);
2848 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2851 $date->sub(1, Zend_Date
::WEEKDAY_8601
);
2852 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2856 $date->sub($d2, Zend_Date
::DAY_SUFFIX
);
2857 $this->fail('exception expected');
2858 } catch (Zend_Date_Exception
$e) {
2863 $date->sub(1, Zend_Date
::WEEKDAY_DIGIT
);
2864 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2867 $date->sub(-10, Zend_Date
::DAY_OF_YEAR
);
2868 $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2869 $date->sub(10, Zend_Date
::DAY_OF_YEAR
);
2870 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2873 $date->sub('M', Zend_Date
::WEEKDAY_NARROW
);
2874 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2877 $date->sub('Mo.', Zend_Date
::WEEKDAY_NAME
);
2878 $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2881 $date->sub(-10, Zend_Date
::WEEK
);
2882 $this->assertSame('2002-03-15T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2883 $date->sub(10, Zend_Date
::WEEK
);
2884 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2887 $date->sub('April', Zend_Date
::MONTH_NAME
);
2888 $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2891 $date->sub(-10, Zend_Date
::MONTH
);
2892 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2893 $date->sub(10, Zend_Date
::MONTH
);
2894 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2897 $date->sub('Apr', Zend_Date
::MONTH_NAME_SHORT
);
2898 $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2901 $date->sub(-10, Zend_Date
::MONTH_SHORT
);
2902 $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2903 $date->sub(10, Zend_Date
::MONTH_SHORT
);
2904 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2908 $date->sub($d2, Zend_Date
::MONTH_DAYS
);
2909 $this->fail('exception expected');
2910 } catch (Zend_Date_Exception
$e) {
2915 $date->sub('M', Zend_Date
::MONTH_NAME_NARROW
);
2916 $this->assertSame('2001-10-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2920 $date->sub($d2, Zend_Date
::LEAPYEAR
);
2921 $this->fail('exception expected');
2922 } catch (Zend_Date_Exception
$e) {
2927 $date->sub(-10, Zend_Date
::YEAR_8601
);
2928 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2929 $date->sub(10, Zend_Date
::YEAR_8601
);
2930 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2933 $date->sub(-10, Zend_Date
::YEAR
);
2934 $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2935 $date->sub(10, Zend_Date
::YEAR
);
2936 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2939 $date->sub(10, Zend_Date
::YEAR_SHORT
);
2940 $this->assertSame('1992-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2941 $date->sub(-10, Zend_Date
::YEAR_SHORT
);
2942 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2945 $date->sub(10, Zend_Date
::YEAR_SHORT_8601
);
2946 $this->assertSame('1992-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2947 $date->sub(-10, Zend_Date
::YEAR_SHORT_8601
);
2948 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2952 $date->sub('noday', Zend_Date
::MERIDIEM
);
2954 } catch (Zend_Date_Exception
$e) {
2959 $date->sub(-10, Zend_Date
::SWATCH
);
2960 $this->assertSame('2002-01-04T04:51:15+05:00', $date->get(Zend_Date
::W3C
));
2961 $date->sub(10, Zend_Date
::SWATCH
);
2962 $this->assertSame('2002-01-04T04:36:51+05:00', $date->get(Zend_Date
::W3C
));
2965 $date->sub(-10, Zend_Date
::HOUR_SHORT_AM
);
2966 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2967 $date->sub(10, Zend_Date
::HOUR_SHORT_AM
);
2968 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2971 $date->sub(-10, Zend_Date
::HOUR_SHORT
);
2972 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2973 $date->sub(10, Zend_Date
::HOUR_SHORT
);
2974 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2977 $date->sub(-10, Zend_Date
::HOUR_AM
);
2978 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2979 $date->sub(10, Zend_Date
::HOUR_AM
);
2980 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2983 $date->sub(-10, Zend_Date
::HOUR
);
2984 $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date
::W3C
));
2985 $date->sub(10, Zend_Date
::HOUR
);
2986 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2989 $date->sub(-10, Zend_Date
::MINUTE
);
2990 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date
::W3C
));
2991 $date->sub(10, Zend_Date
::MINUTE
);
2992 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
2995 $date->sub(-10, Zend_Date
::MINUTE_SHORT
);
2996 $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date
::W3C
));
2997 $date->sub(10, Zend_Date
::MINUTE_SHORT
);
2998 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3001 $date->sub(-10, Zend_Date
::SECOND
);
3002 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
3003 $date->sub(10, Zend_Date
::SECOND
);
3004 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3007 $date->sub(-10, Zend_Date
::SECOND_SHORT
);
3008 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
3009 $date->sub(10, Zend_Date
::SECOND_SHORT
);
3010 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3013 $date->sub(-10, Zend_Date
::MILLISECOND
);
3014 $this->assertSame('010', $date->get(Zend_Date
::MILLISECOND
));
3015 $date->sub(10, Zend_Date
::MILLISECOND
);
3016 $this->assertSame( '000', $date->get(Zend_Date
::MILLISECOND
));
3020 $date->sub('noday', Zend_Date
::TIMEZONE_NAME
);
3022 } catch (Zend_Date_Exception
$e) {
3028 $date->sub('noday', Zend_Date
::DAYLIGHT
);
3030 } catch (Zend_Date_Exception
$e) {
3036 $date->sub('noday', Zend_Date
::GMT_DIFF
);
3038 } catch (Zend_Date_Exception
$e) {
3044 $date->sub('noday', Zend_Date
::GMT_DIFF_SEP
);
3046 } catch (Zend_Date_Exception
$e) {
3052 $date->sub('noday', Zend_Date
::TIMEZONE
);
3054 } catch (Zend_Date_Exception
$e) {
3060 $date->sub('noday', Zend_Date
::TIMEZONE_SECS
);
3062 } catch (Zend_Date_Exception
$e) {
3067 $date->sub('1000-01-02 20:05:12', Zend_Date
::ISO_8601
);
3068 $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date
::W3C
));
3070 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date
::ISO_8601
);
3071 $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date
::W3C
));
3074 $date->sub('Thu, 02 Jan 1000 20:05:12 +0500', Zend_Date
::RFC_2822
);
3075 $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date
::W3C
));
3078 $date->sub(-10, Zend_Date
::TIMESTAMP
);
3079 $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date
::W3C
));
3083 $date->sub('noday', Zend_Date
::ERA
);
3085 } catch (Zend_Date_Exception
$e) {
3091 $date->sub('noday', Zend_Date
::ERA_NAME
);
3093 } catch (Zend_Date_Exception
$e) {
3098 $date->sub('10.02.0005', Zend_Date
::DATES
);
3099 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3102 $date->sub('Samstag, 10. Februar 0005', Zend_Date
::DATE_FULL
);
3103 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3106 $date->sub('10. Februar 0005', Zend_Date
::DATE_LONG
);
3107 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3110 $date->sub('10.02.0005', Zend_Date
::DATE_MEDIUM
);
3111 $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3114 $date->sub('10.02.05', Zend_Date
::DATE_SHORT
);
3115 $this->assertSame('-4-10-29T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3118 $date->sub('10:05:05', Zend_Date
::TIMES
);
3119 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
3122 $date->sub('10:05 Uhr CET', Zend_Date
::TIME_FULL
);
3123 $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date
::W3C
));
3126 $date->sub('10:05:05 CET', Zend_Date
::TIME_LONG
);
3127 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
3130 $date->sub('10:05:05', Zend_Date
::TIME_MEDIUM
);
3131 $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
3134 $date->sub('10:05', Zend_Date
::TIME_SHORT
);
3135 $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date
::W3C
));
3138 $date->sub('10.02.0005 10:05:05', Zend_Date
::DATETIME
);
3139 $this->assertSame('1996-10-26T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
3142 $date->sub('Samstag, 10. Februar 0005 10:05 Uhr CET', Zend_Date
::DATETIME_FULL
);
3143 $this->assertSame('1996-10-26T18:31:50+05:00', $date->get(Zend_Date
::W3C
));
3146 $date->sub('10. Februar 0005 10:05:05 CET', Zend_Date
::DATETIME_LONG
);
3147 $this->assertSame('1996-10-26T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
3150 $date->sub('10.02.0005 10:05:05', Zend_Date
::DATETIME_MEDIUM
);
3151 $this->assertSame('1996-10-26T18:31:45+05:00', $date->get(Zend_Date
::W3C
));
3154 $date->sub('10.02.05 10:05', Zend_Date
::DATETIME_SHORT
);
3155 $this->assertSame('-4-10-28T18:31:50+05:00', $date->get(Zend_Date
::W3C
));
3158 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date
::ATOM
);
3159 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date
::W3C
));
3162 $date->sub('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date
::COOKIE
);
3163 $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date
::W3C
) );
3166 $date->sub('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date
::RFC_822
);
3167 $this->assertSame('1-12-03T13:31:38+05:00', $date->get(Zend_Date
::W3C
));
3170 $date->sub('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date
::RFC_850
);
3171 $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date
::W3C
));
3174 $date->sub('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date
::RFC_1036
);
3175 $this->assertSame('1-12-03T13:31:38+05:00', $date->get(Zend_Date
::W3C
));
3178 $date->sub('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date
::RFC_1123
);
3179 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date
::W3C
));
3182 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date
::RFC_3339
);
3183 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date
::W3C
));
3186 $date->sub('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date
::RSS
);
3187 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date
::W3C
));
3190 $date->sub('1000-01-02T20:05:12+05:00', Zend_Date
::W3C
);
3191 $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date
::W3C
));
3194 $date->sub('1000', 'xx');
3195 $this->assertSame('2002-01-04T04:20:10+05:00', $date->get(Zend_Date
::W3C
));
3201 public function testCompare()
3203 $locale = new Zend_Locale('de_AT');
3204 $date = new Zend_Date(0,null,$locale);
3205 $d2 = new Zend_Date(1010101010,null,$locale);//03.01.2002 15:36:50
3207 $retour = $date->set(1234567890); //13.02.2009 15:31:30
3208 $this->assertSame('1234567890', $retour->getTimestamp());
3209 $this->assertSame( 0, $date->compare(1234567890));
3210 $this->assertSame( 1, $date->compare(1234567800));
3211 $this->assertSame(-1, $date->compare(1234567899));
3213 $date->set($d2);//03.01.2002 15:36:50
3214 $this->assertSame( 1, $date->compare(3,Zend_Date
::DAY
));
3215 $this->assertSame( 0, $date->compare(4,Zend_Date
::DAY
));
3216 $this->assertSame(-1, $date->compare(5,Zend_Date
::DAY
));
3218 $this->assertSame( 1, $date->compare('Mon',Zend_Date
::WEEKDAY_SHORT
));
3219 $this->assertSame(-1, $date->compare('Sam',Zend_Date
::WEEKDAY_SHORT
));
3221 $date->set($d2);//03.01.2002 15:36:50
3222 $this->assertSame(0, $date->compare(0,Zend_Date
::MILLISECOND
));
3228 public function testCopy()
3230 $locale = new Zend_Locale('de_AT');
3231 $date = new Zend_Date(0,null,$locale);
3232 $d2 = new Zend_Date(1010101010,null,$locale);
3234 $date->set(1234567890);
3235 $newdate = clone $date;
3236 $this->assertSame($date->get(),$newdate->get());
3239 $newdate = $date->copyPart(Zend_Date
::DAY
);
3240 $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date
::W3C
));
3241 $this->assertSame('1970-01-04T05:00:00+05:00', $newdate->get(Zend_Date
::W3C
));
3247 public function testEquals()
3249 $locale = new Zend_Locale('de_AT');
3250 $date = new Zend_Date(0,null,$locale);
3251 $d2 = new Zend_Date(1010101010,null,$locale);
3253 $retour = $date->set(1234567890);
3254 $this->assertSame('1234567890', $retour->getTimestamp());
3255 $this->assertTrue( $date->equals(1234567890));
3256 $this->assertFalse($date->equals(1234567800));
3259 $this->assertFalse($date->equals(3,Zend_Date
::DAY
));
3260 $this->assertTrue( $date->equals(4,Zend_Date
::DAY
));
3264 * Test for isEarlier
3266 public function testIsEarlier()
3268 $locale = new Zend_Locale('de_AT');
3269 $date = new Zend_Date(0,null,$locale);
3270 $d2 = new Zend_Date(1010101010,null,$locale);
3272 $retour = $date->set(1234567890);
3273 $this->assertSame('1234567890', $retour->getTimestamp());
3274 $this->assertFalse($date->isEarlier(1234567890));
3275 $this->assertFalse($date->isEarlier(1234567800));
3276 $this->assertTrue( $date->isEarlier(1234567899));
3279 $this->assertFalse($date->isEarlier(3,Zend_Date
::DAY
));
3280 $this->assertFalse($date->isEarlier(4,Zend_Date
::DAY
));
3281 $this->assertTrue( $date->isEarlier(5,Zend_Date
::DAY
));
3287 public function testIsLater()
3289 $locale = new Zend_Locale('de_AT');
3290 $date = new Zend_Date(0,null,$locale);
3291 $d2 = new Zend_Date(1010101010,null,$locale);
3293 $retour = $date->set(1234567890);
3294 $this->assertSame('1234567890', $retour->getTimestamp());
3295 $this->assertFalse($date->isLater(1234567890));
3296 $this->assertTrue( $date->isLater(1234567800));
3297 $this->assertFalse($date->isLater(1234567899));
3300 $this->assertTrue( $date->isLater(3,Zend_Date
::DAY
));
3301 $this->assertFalse($date->isLater(4,Zend_Date
::DAY
));
3302 $this->assertFalse($date->isLater(5,Zend_Date
::DAY
));
3308 public function testGetTime()
3310 $locale = new Zend_Locale('de_AT');
3311 $date = new Zend_Date(1010101010,null,$locale);
3312 $d2 = new Zend_Date(1010101010,null,$locale);
3314 $result = $date->getTime();
3315 $this->assertSame('1970-01-01T04:36:50+05:00', $result->get(Zend_Date
::W3C
));
3321 public function testSetTime()
3323 $locale = new Zend_Locale('de_AT');
3325 $date = new Zend_Date(1234567890,null,$locale);
3326 $d2 = new Zend_Date(1234567899,null,$locale);
3328 $result = $date->setTime(Zend_Date
::now());
3329 $this->assertTrue($result instanceof Zend_Date
);
3330 $result = $date->setTime('10:20:30');
3331 $this->assertSame('2009-02-14T10:20:30+05:00', $result->get(Zend_Date
::W3C
));
3332 $this->assertSame('2009-02-14T10:20:30+05:00', $date->get(Zend_Date
::W3C
));
3333 $date->setTime('30-20-10','ss:mm:HH');
3334 $this->assertSame('2009-02-14T10:20:30+05:00', $date->get(Zend_Date
::W3C
));
3335 $date->setTime($d2);
3336 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date
::W3C
));
3338 $date = new Zend_Date(Zend_Date
::now(), $locale);
3339 $t1 = $date->get(Zend_Date
::TIMESTAMP
);
3340 $date->setTime(Zend_Date
::now());
3341 $t2 = $date->get(Zend_Date
::TIMESTAMP
);
3342 $diff = abs($t2 - $t1);
3343 $this->assertTrue($diff < 2, "Instance of Zend_Date has a significantly different time than returned by setTime(): $diff seconds");
3349 public function testAddTime()
3351 $locale = new Zend_Locale('de_AT');
3352 $date = new Zend_Date(1234567890,null,$locale);
3353 $d2 = new Zend_Date(1234567899,null,$locale);
3355 $result = $date->addTime(Zend_Date
::now());
3356 $this->assertTrue($result instanceof Zend_Date
);
3358 $date = new Zend_Date(1234567890,null,$locale);
3359 $result = $date->addTime('10:20:30');
3360 $this->assertSame('2009-02-14T14:52:00+05:00', $result->get(Zend_Date
::W3C
));
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('30:20:10','ss:mm:HH');
3365 $this->assertSame('2009-02-14T14:52:00+05:00', $date->get(Zend_Date
::W3C
));
3367 $date = new Zend_Date(1234567890,null,$locale);
3368 $date->addTime($d2);
3369 $this->assertSame('2009-02-14T09:03:09+05:00', $date->get(Zend_Date
::W3C
));
3375 public function testSubTime()
3377 $locale = new Zend_Locale('de_AT');
3378 $date = new Zend_Date(1234567890,null,$locale);
3379 $d2 = new Zend_Date(1234567899,null,$locale);
3381 $result = $date->subTime(Zend_Date
::now());
3382 $this->assertTrue($result instanceof Zend_Date
);
3384 $date = new Zend_Date(1234567890,null,$locale);
3385 $result = $date->subTime('10:20:30');
3386 $this->assertSame('2009-02-13T18:11:00+05:00', $result->get(Zend_Date
::W3C
));
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('30-20-10','ss:mm:HH');
3391 $this->assertSame('2009-02-13T18:11:00+05:00', $date->get(Zend_Date
::W3C
));
3393 $date = new Zend_Date(1234567890,null,$locale);
3394 $date->subTime($d2);
3395 $this->assertSame('2009-02-13T23:59:51+05:00', $date->get(Zend_Date
::W3C
));
3399 * Test for compareTime
3401 public function testCompareTime()
3403 $locale = new Zend_Locale('de_AT');
3404 $date = new Zend_Date(1234567890,null,$locale);
3405 $d2 = new Zend_Date(1234567899,null,$locale);
3407 $date = new Zend_Date(1234567890,null,$locale);
3408 $this->assertSame(-1, $date->compareTime('10:20:30'));
3409 $this->assertSame( 0, $date->compareTime('04:31:30'));
3410 $this->assertSame( 1, $date->compareTime('04:00:30'));
3411 $this->assertSame(-1, $date->compareTime($d2 ));
3417 public function testSetHour()
3419 $locale = new Zend_Locale('de_AT');
3421 $date = new Zend_Date(1234567890,null,$locale);
3422 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3423 for($i=23; $i >= 0; $i--) {
3427 $hour = '0' . $hour;
3429 $this->assertSame("2009-02-14T$hour:31:30+05:00", $date->get(Zend_Date
::W3C
));
3436 public function testGetDate()
3438 $locale = new Zend_Locale('de_AT');
3439 $date = new Zend_Date(1010101010,null,$locale);
3440 $d2 = new Zend_Date(1010101010,null,$locale);
3442 $result = $date->getDate();
3443 $this->assertSame('2002-01-04T00:00:00+05:00', $result->get(Zend_Date
::W3C
));
3449 public function testSetDate()
3451 $locale = new Zend_Locale('de_AT');
3452 $date = new Zend_Date(1234567890,null,$locale);
3453 $d2 = new Zend_Date(1234567899,null,$locale);
3455 $result = $date->setDate(Zend_Date
::now());
3456 $this->assertTrue($result instanceof Zend_Date
);
3457 $result = $date->setDate('11.05.2008');
3458 // Hint: the hour changes from 0 to 1 because of DST...
3459 // An hour is added by winter->summertime change
3460 $this->assertSame('2008-05-11T04:31:30+05:00', $result->get(Zend_Date
::W3C
));
3461 $this->assertSame('2008-05-11T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3462 $date->setDate('2008-05-11','YYYY-MM-dd');
3463 $this->assertSame('2008-05-11T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3464 $date->setDate($d2);
3465 $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3471 public function testAddDate()
3473 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3474 $this->markTestSkipped('Extended I18N test skipped');
3478 $locale = new Zend_Locale('de_AT');
3479 $date = new Zend_Date(1234567890,null,$locale);
3480 $d2 = new Zend_Date(1234567899,null,$locale);
3482 $result = $date->addDate(Zend_Date
::now());
3483 $this->assertTrue($result instanceof Zend_Date
);
3485 $date = new Zend_Date(1234567890,null,$locale);
3486 $result = $date->addDate('02-03-05');
3487 $this->assertSame('4014-05-17T04:31:30+05:00', $result->get(Zend_Date
::W3C
));
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('05-03-02','YY-MM-dd');
3492 $this->assertSame('4014-05-17T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3494 $date = new Zend_Date(1234567890,null,$locale);
3495 $date->addDate($d2);
3496 $this->assertSame('4018-04-28T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3502 public function testSubDate()
3504 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3505 $this->markTestSkipped('Extended I18N test skipped');
3509 $locale = new Zend_Locale('de_AT');
3510 $date = new Zend_Date(1234567890,null,$locale);
3511 $d2 = new Zend_Date(1234567899,null,$locale);
3513 $result = $date->subDate(Zend_Date
::now());
3514 $this->assertTrue($result instanceof Zend_Date
);
3516 $date = new Zend_Date(1234567890,null,$locale);
3517 $result = $date->subDate('03-05-1001');
3518 $this->assertSame('1007-09-08T04:31:30+05:00', $result->get(Zend_Date
::W3C
));
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('1001-05-03','YYYY-MM-dd');
3523 $this->assertSame('1007-09-08T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3525 $date = new Zend_Date(1234567890,null,$locale);
3526 $date->subDate($d2);
3527 $this->assertSame('-1-12-06T04:31:30+05:00', $date->get(Zend_Date
::W3C
));
3531 * Test for compareDate
3533 public function testCompareDate()
3535 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3536 $this->markTestSkipped('Extended I18N test skipped');
3540 $locale = new Zend_Locale('de_AT');
3541 $date = new Zend_Date(1234567890,$locale);
3542 $d2 = new Zend_Date(1234567899,$locale);
3544 $date = new Zend_Date(1234567890,$locale);
3545 $this->assertSame( 1, $date->compareDate('10.01.2009'));
3546 $this->assertSame( 0, $date->compareDate('14.02.2009'));
3547 $this->assertSame(-1, $date->compareDate('15.02.2009'));
3548 $this->assertSame( 0, $date->compareDate($d2 ));
3554 public function testGetIso()
3556 $locale = new Zend_Locale('de_AT');
3557 $date = new Zend_Date(1010101010,null,$locale);
3558 $d2 = new Zend_Date(1010101010,null,$locale);
3560 $result = $date->getIso();
3561 $this->assertTrue(is_string($result));
3562 $this->assertSame('2002-01-04T04:36:50+05:00', $result);
3568 public function testSetIso()
3570 $locale = new Zend_Locale('de_AT');
3571 $date = new Zend_Date(1234567890,null,$locale);
3572 $d2 = new Zend_Date(1234567899,null,$locale);
3574 $result = $date->setIso(Zend_Date
::now());
3575 $this->assertTrue($result instanceof Zend_Date
);
3576 $result = $date->setIso('2002-01-04T00:00:00+0000');
3577 $this->assertSame('2002-01-04T00:00:00+00:00', $result->get(Zend_Date
::W3C
));
3578 $this->assertSame('2002-01-04T00:00:00+00:00', $date->get(Zend_Date
::W3C
));
3580 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date
::W3C
));
3586 public function testAddIso()
3588 $locale = new Zend_Locale('de_AT');
3589 $date = new Zend_Date(1234567890,$locale);
3590 $d2 = new Zend_Date(1234567899,$locale);
3592 $result = $date->addIso(Zend_Date
::now());
3593 $this->assertTrue($result instanceof Zend_Date
);
3599 public function testAddIso2()
3601 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3602 $this->markTestSkipped('Extended I18N test skipped');
3606 $locale = new Zend_Locale('de_AT');
3607 $date = new Zend_Date(1234567890,$locale);
3608 $d2 = new Zend_Date(1234567899,$locale);
3610 $result = $date->setIso('2002-01-04T01:00:00+0500');
3611 $result = $date->addIso('0000-00-00T01:00:00+0500');
3612 $this->assertSame('2002-01-03T21:00:00+05:00', $result->get(Zend_Date
::W3C
));
3613 $this->assertSame('2002-01-03T21:00:00+05:00', $date->get(Zend_Date
::W3C
));
3615 $date->addIso('0001-01-01T01:01:01+0500');
3616 $this->assertSame('2003-02-04T17:01:01+05:00', $date->get(Zend_Date
::W3C
));
3618 $date = new Zend_Date(1234567890,$locale);
3620 $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date
::W3C
));
3626 public function testSubIso()
3628 $locale = new Zend_Locale('de_AT');
3629 $date = new Zend_Date(1234567890,null,$locale);
3630 $d2 = new Zend_Date(1234567899,null,$locale);
3632 $result = $date->subIso(Zend_Date
::now());
3633 $this->assertTrue($result instanceof Zend_Date
);
3639 public function testSubIso2()
3641 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3642 $this->markTestSkipped('Extended I18N test skipped');
3646 $locale = new Zend_Locale('de_AT');
3647 $date = new Zend_Date(1234567890,null,$locale);
3648 $d2 = new Zend_Date(1234567899,null,$locale);
3649 $result = $date->subIso('0000-00-00T01:00:00+0500');
3650 $this->assertSame('2009-02-14T08:31:30+05:00', $result->get(Zend_Date
::W3C
));
3651 $this->assertSame('2009-02-14T08:31:30+05:00', $date->get(Zend_Date
::W3C
));
3653 $result = $date->subIso('0001-01-01T01:01:01+0500');
3654 $this->assertSame('2008-01-14T12:30:29+05:00', $date->get(Zend_Date
::W3C
));
3656 $date = new Zend_Date(1234567890,null,$locale);
3658 $this->assertSame('-1-12-06T04:59:51+05:00', $date->get(Zend_Date
::W3C
));
3662 * Test for compareIso
3664 public function testCompareIso()
3666 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3667 $this->markTestSkipped('Extended I18N test skipped');
3671 $locale = new Zend_Locale('de_AT');
3672 $date = new Zend_Date(1234567890,null,$locale);
3673 $d2 = new Zend_Date(1234567899,null,$locale);
3675 $date = new Zend_Date(1234567890,null,$locale);
3676 $this->assertSame( 1, $date->compareIso('2002-01-04T04:00:00+0500'));
3677 $this->assertSame( 0, $date->compareIso('2009-02-14T04:31:30+0500'));
3678 $this->assertSame(-1, $date->compareIso('2010-01-04T05:00:00+0500'));
3679 $this->assertSame(-1, $date->compareIso($d2 ));
3685 public function testGetArpa()
3687 $locale = new Zend_Locale('de_AT');
3688 $date = new Zend_Date(1010101010,null,$locale);
3690 $result = $date->getArpa();
3691 $this->assertTrue(is_string($result));
3692 $this->assertSame('Fri, 04 Jan 02 04:36:50 +0500', $result);
3698 public function testSetArpa()
3700 $locale = new Zend_Locale('de_AT');
3701 $date = new Zend_Date(1234567890,$locale);
3702 $d2 = new Zend_Date(1234567899,$locale);
3703 $date->setTimezone('Indian/Maldives');
3705 $result = $date->setArpa(Zend_Date
::now());
3706 $this->assertTrue($result instanceof Zend_Date
);
3707 $result = $date->setArpa('Sat, 03 May 01 00:00:00 +0500');
3708 $this->assertSame('Thu, 03 May 01 00:00:00 +0500', $result->get(Zend_Date
::RFC_822
));
3709 $this->assertSame('2001-05-03T00:00:00+05:00', $date->get(Zend_Date
::W3C
));
3710 $date->setArpa($d2);
3711 $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date
::W3C
));
3717 public function testAddArpa()
3719 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3720 $this->markTestSkipped('Extended I18N test skipped');
3724 $locale = new Zend_Locale('de_AT');
3725 $date = new Zend_Date(1234567890,$locale);
3726 $d2 = new Zend_Date(1234567899,$locale);
3728 $result = $date->addArpa(Zend_Date
::now());
3729 $this->assertTrue($result instanceof Zend_Date
);
3731 $date = new Zend_Date(1234567890,$locale);
3732 $result = $date->addArpa('Sat, 03 May 01 00:00:00 +0500');
3733 $this->assertSame('Sat, 17 Jul 10 23:31:30 +0500', $result->get(Zend_Date
::RFC_822
));
3734 $this->assertSame('4010-07-17T23:31:30+05:00', $date->get(Zend_Date
::W3C
));
3736 $date = new Zend_Date(1234567890,$locale);
3737 $date->addArpa($d2);
3738 $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date
::W3C
));
3740 $result = $date->setArpa('Fri, 05 Jan 07 03:35:53 +0500');
3741 $arpa = $result->getArpa();
3742 $this->assertSame('Fri, 05 Jan 07 03:35:53 +0500', $arpa);
3748 public function testSubArpa()
3750 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3751 $this->markTestSkipped('Extended I18N test skipped');
3755 $locale = new Zend_Locale('de_AT');
3756 $date = new Zend_Date(1234567890,$locale);
3757 $d2 = new Zend_Date(1234567899,$locale);
3759 $result = $date->subArpa(Zend_Date
::now());
3760 $this->assertTrue($result instanceof Zend_Date
);
3762 $date = new Zend_Date(1234567890,null,$locale);
3763 $result = $date->subArpa('Sat, 03 May 01 00:00:00 +0500');
3764 $this->assertSame('Wed, 16 Sep 7 09:31:30 +0500', $result->get(Zend_Date
::RFC_822
));
3765 $this->assertSame('7-09-16T09:31:30+05:00', $date->get(Zend_Date
::W3C
));
3767 $date = new Zend_Date(1234567890,$locale);
3768 $date->subArpa($d2);
3769 $this->assertSame('-1-12-06T04:59:51+05:00', $date->get(Zend_Date
::W3C
));
3773 * Test for compareArpa
3775 public function testCompareArpa()
3777 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
3778 $this->markTestSkipped('Extended I18N test skipped');
3782 $locale = new Zend_Locale('de_AT');
3783 $date = new Zend_Date(1234567890,$locale);
3784 $d2 = new Zend_Date(1234567899,$locale);
3786 $date = new Zend_Date(1234567890,$locale);
3787 $this->assertSame(-1, $date->compareArpa('Sat, 14 Feb 09 05:31:30 +0500'));
3788 $this->assertSame( 0, $date->compareArpa('Sat, 14 Feb 09 04:31:30 +0500'));
3789 $this->assertSame( 1, $date->compareArpa('Sat, 13 Feb 09 04:31:30 +0500'));
3790 $this->assertSame(-1, $date->compareArpa($d2 ));
3794 * Test for false locale setting
3796 public function testReducedParams()
3798 $locale = new Zend_Locale('de_AT');
3799 $date = new Zend_Date(1010101010,$locale);
3801 $date->setArpa('Sat, 03 May 01 00:00:00 +0500',$locale);
3802 $this->assertSame('Thu, 03 May 01 00:00:00 +0500', $date->get(Zend_Date
::RFC_822
));
3808 public function testSunFunc()
3810 $locale = new Zend_Locale('de_AT');
3811 $date = new Zend_Date(1010101010,$locale);
3812 $date->setTimezone(date_default_timezone_get());
3814 $result = Zend_Date_Cities
::City('vienna');
3815 $this->assertTrue(is_array($result));
3816 $result = $date->getSunset($result);
3817 $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date
::W3C
));
3820 $result = Zend_Date_Cities
::City('vienna', 'civil');
3821 $this->assertTrue(is_array($result));
3822 $result = $date->getSunset($result);
3823 $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date
::W3C
));
3826 $result = Zend_Date_Cities
::City('vienna', 'nautic');
3827 $this->assertTrue(is_array($result));
3828 $result = $date->getSunset($result);
3829 $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date
::W3C
));
3832 $result = Zend_Date_Cities
::City('vienna', 'astronomic');
3833 $this->assertTrue(is_array($result));
3834 $result = $date->getSunset($result);
3835 $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date
::W3C
));
3838 $result = Zend_Date_Cities
::City('BERLIN');
3839 $this->assertTrue(is_array($result));
3840 $result = $date->getSunrise($result);
3841 $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date
::W3C
));
3844 $result = Zend_Date_Cities
::City('London');
3845 $this->assertTrue(is_array($result));
3846 $result = $date->getSunInfo($result);
3847 $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date
::W3C
));
3848 $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date
::W3C
));
3849 $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date
::W3C
));
3850 $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date
::W3C
));
3851 $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date
::W3C
));
3852 $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date
::W3C
));
3853 $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date
::W3C
));
3854 $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date
::W3C
));
3857 $result = array('longitude' => 0);
3859 $result = $date->getSunrise($result);
3861 } catch (Zend_Date_Exception
$e) {
3866 $result = array('latitude' => 0);
3868 $result = $date->getSunrise($result);
3870 } catch (Zend_Date_Exception
$e) {
3875 $result = array('longitude' => 180.1, 'latitude' => 0);
3877 $result = $date->getSunrise($result);
3879 } catch (Zend_Date_Exception
$e) {
3884 $result = array('longitude' => -180.1, 'latitude' => 0);
3886 $result = $date->getSunrise($result);
3888 } catch (Zend_Date_Exception
$e) {
3893 $result = array('longitude' => 0, 'latitude' => 90.1);
3895 $result = $date->getSunrise($result);
3897 } catch (Zend_Date_Exception
$e) {
3902 $result = array('longitude' => 0, 'latitude' => -90.1);
3904 $result = $date->getSunrise($result);
3906 } catch (Zend_Date_Exception
$e) {
3911 $result = array('latitude' => 0, 'longitude' => 0);
3912 $result = $date->getSunInfo($result);
3913 $this->assertTrue(is_array($result));
3916 $result = array('latitude' => 0, 'longitude' => 0);
3917 $result = $date->getSunrise($result);
3918 $this->assertTrue($result instanceof Zend_Date
);
3924 public function testTimezone()
3926 $locale = new Zend_Locale('de_AT');
3927 $date = new Zend_Date(1010101010,$locale);
3928 $date->setTimezone(date_default_timezone_get());
3930 $result = $date->getTimezone();
3931 $this->assertSame('Indian/Maldives', $result);
3934 $result = $date->setTimezone('unknown');
3935 // if function timezone_identifiers_list is not available false should be returned
3936 $this->assertFalse($result);
3937 } catch (Zend_Date_Exception
$e) {
3940 $result = $date->getTimezone();
3941 $this->assertSame('Indian/Maldives', $result);
3943 $result = $date->setTimezone('America/Chicago');
3944 $this->assertTrue($result instanceof Zend_Date
);
3945 $result = $date->getTimezone();
3946 $this->assertSame('America/Chicago', $result);
3948 $date = new Zend_Date('01.01.2000T00:00:00Z',Zend_Date
::ISO_8601
);
3949 $result = $date->getTimezone();
3950 $this->assertSame('Etc/UTC', $result);
3956 public function testLeapYear()
3958 $locale = new Zend_Locale('de_AT');
3960 $date = new Zend_Date('01.01.2006', Zend_Date
::DATES
, $locale);
3961 $this->assertFalse($date->isLeapYear());
3964 $date = new Zend_Date('01.01.2004', Zend_Date
::DATES
, $locale);
3965 $this->assertTrue($date->isLeapYear());
3968 $result = Zend_Date
::checkLeapYear('noyear');
3969 $this->fail('exception expected');
3970 } catch (Zend_Date_Exception
$e) {
3978 public function testToday()
3980 $locale = new Zend_Locale('de_AT');
3982 $date = new Zend_Date(Zend_Date
::now());
3983 $d2 = new Zend_Date(1010101010,$locale);
3985 $this->assertFalse($d2->isToday());
3986 $this->assertTrue($date->isToday());
3990 * Test for Yesterday
3992 public function testYesterday()
3994 $locale = new Zend_Locale('de_AT');
3996 $date = new Zend_Date(Zend_Date
::now());
3997 $d2 = new Zend_Date(1010101010,$locale);
3999 $this->assertFalse($d2->isYesterday());
4000 $this->assertTrue($date->isYesterday());
4006 public function testTomorrow()
4008 $locale = new Zend_Locale('de_AT');
4010 $date = new Zend_Date(Zend_Date
::now());
4011 $d2 = new Zend_Date(1010101010,$locale);
4014 $this->assertFalse($d2->isTomorrow());
4015 $this->assertTrue($date->isTomorrow());
4019 * test isToday(), isTomorrow(), and isYesterday() for cases other than time() = "now"
4021 public function testIsDay()
4023 date_default_timezone_set('Europe/Vienna'); // should have DST
4024 $locale = new Zend_Locale('de_AT');
4025 $date = new Zend_Date_TestHelper('01.01.2006', Zend_Date
::DATES
, $locale);
4027 $date->_setTime($date->mktime(0, 0, 0, 1, 1, 2006));
4028 $this->assertTrue($date->isToday());
4029 $this->assertFalse($date->isTomorrow());
4030 $date->_setTime($date->mktime(0, 0, 0, 1, 1, 2006));
4031 $this->assertFalse($date->isYesterday());
4033 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2005));
4034 $this->assertTrue($date->isTomorrow());
4035 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2005));
4036 $this->assertFalse($date->isYesterday());
4038 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2006));
4039 $this->assertFalse($date->isTomorrow());
4040 $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2006));
4041 $this->assertFalse($date->isYesterday());
4043 $date->_setTime($date->mktime(0, 0, 0, 1, 0, 2006));
4044 $this->assertTrue($date->isTomorrow());
4045 $date->_setTime($date->mktime(0, 0, 0, 1, 0, 2006));
4046 $this->assertFalse($date->isYesterday());
4048 $date->_setTime($date->mktime(0, 0, 0, 1, 2, 2006));
4049 $this->assertFalse($date->isTomorrow());
4050 $date->_setTime($date->mktime(0, 0, 0, 1, 2, 2006));
4051 $this->assertTrue($date->isYesterday());
4057 public function testNow()
4059 $locale = new Zend_Locale('de_AT');
4061 $date = Zend_Date
::now();
4063 $reference = date('U');
4064 $this->assertTrue(($reference - $date->get(Zend_Date
::TIMESTAMP
)) < 2);
4070 public function testGetYear()
4072 $locale = new Zend_Locale('de_AT');
4074 $date = new Zend_Date(1234567890,$locale);
4075 $d2 = new Zend_Date(1610101010,$locale);
4076 $date->setTimeZone(date_default_timezone_get());
4077 $d2->setTimeZone(date_default_timezone_get());
4079 $result = $date->getYear();
4080 $this->assertTrue($result instanceof Zend_Date
);
4081 $this->assertSame('01.01.2009 05:00:00', $result->toString());
4082 $this->assertSame('01.01.2021 05:00:00', $d2->getYear()->toString());
4088 public function testSetYear()
4090 $locale = new Zend_Locale('de_AT');
4092 $date = new Zend_Date(1577833200,$locale);
4093 $date2 = new Zend_Date(2006, Zend_Date
::YEAR
);
4094 $date->setTimeZone(date_default_timezone_get());
4096 $date->setYear(2000);
4097 $this->assertSame('2000-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4099 $date->setYear(1800);
4100 $this->assertSame('1800-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4102 $date->setYear(2100);
4103 $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4105 $date->setYear($date2);
4106 $this->assertSame('2006-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4109 $date->setYear('noyear');
4111 } catch (Zend_Date_Exception
$e) {
4119 public function testAddYear()
4121 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
4122 $this->markTestSkipped('Extended I18N test skipped');
4126 $locale = new Zend_Locale('de_AT');
4128 $date = new Zend_Date(1577833200,$locale);
4129 $date->setTimeZone(date_default_timezone_get());
4132 $this->assertSame('2021-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4134 $this->assertSame('2022-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4136 $this->assertSame('2023-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4138 $this->assertSame('2024-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4140 $this->assertSame('2025-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4142 $date->setYear(1500);
4143 $this->assertSame('1500-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4145 $this->assertSame('1520-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4147 $date->setYear(2100);
4148 $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4150 $this->assertSame('2120-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4154 $date->setYear(2020);
4155 $this->assertSame('2020-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4157 $this->assertSame('2021-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4159 $this->assertSame('2022-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4161 $this->assertSame('2023-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4163 $this->assertSame('2024-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4165 $this->assertSame('2025-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4167 $date->setYear(1500);
4168 $this->assertSame('1500-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4170 $this->assertSame('1520-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4172 $date->setYear(2100);
4173 $this->assertSame('2100-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4175 $this->assertSame('2120-04-04T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4181 public function testSubYear()
4183 if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE
== false) {
4184 $this->markTestSkipped('Extended I18N test skipped');
4188 $locale = new Zend_Locale('de_AT');
4190 $date = new Zend_Date(1577833200,$locale);
4191 $date->setTimeZone(date_default_timezone_get());
4194 $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4196 $this->assertSame('2018-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4198 $this->assertSame('2017-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4200 $this->assertSame('2016-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4202 $this->assertSame('2015-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4204 $date->setYear(1500);
4205 $this->assertSame('1500-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4207 $this->assertSame('1480-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4209 $date->setYear(2100);
4210 $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4212 $this->assertSame('2080-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4216 * Test for compareYear
4218 public function testCompareYear()
4220 $locale = new Zend_Locale('de_AT');
4221 $date = new Zend_Date(1234567890,$locale);
4222 $d2 = new Zend_Date(1234567899,$locale);
4224 $date = new Zend_Date(1234567890,$locale);
4225 $this->assertSame(-1, $date->compareYear(2010));
4226 $this->assertSame( 0, $date->compareYear(2009));
4227 $this->assertSame( 1, $date->compareYear(2008));
4228 $this->assertSame( 0, $date->compareYear($d2 ));
4234 public function testGetMonth()
4236 $locale = new Zend_Locale('de_AT');
4238 $date = new Zend_Date(1234567890,$locale);
4239 $d2 = new Zend_Date(1610101010,$locale);
4240 $date->setTimeZone(date_default_timezone_get());
4241 $d2->setTimeZone(date_default_timezone_get());
4243 $result = $date->getMonth();
4244 $this->assertTrue($result instanceof Zend_Date
);
4245 $this->assertSame('01.02.1970 05:00:00', $result->toString( ));
4246 $this->assertSame('01.02.1970 05:00:00', $date->getMonth()->toString());
4252 public function testSetMonth()
4254 $locale = new Zend_Locale('de_AT');
4256 $date = new Zend_Date(1577833200,$locale);
4257 $date2 = new Zend_Date(2006, Zend_Date
::YEAR
);
4258 $date->setTimeZone(date_default_timezone_get());
4261 $this->assertSame('2020-03-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4263 $date->setMonth(-3);
4264 $this->assertSame('2019-09-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4266 $date->setMonth('March', 'en');
4267 $this->assertSame('2019-03-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4269 $date->setMonth($date2);
4270 $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4273 $date->setMonth('nomonth');
4275 } catch (Zend_Date_Exception
$e) {
4283 public function testAddMonth()
4285 date_default_timezone_set('Europe/Vienna');
4286 $locale = new Zend_Locale('de_AT');
4288 $date = new Zend_Date(1577833200,$locale);
4289 $date->setTimeZone(date_default_timezone_get());
4292 $this->assertSame('2020-02-01T00:00:00+01:00', $date->get(Zend_Date
::W3C
));
4294 $this->assertSame('2020-03-01T00:00:00+01:00', $date->get(Zend_Date
::W3C
));
4296 $this->assertSame('2020-04-01T00:00:00+02:00', $date->get(Zend_Date
::W3C
));
4298 $this->assertSame('2020-05-01T00:00:00+02:00', $date->get(Zend_Date
::W3C
));
4300 $this->assertSame('2020-06-01T00:00:00+02:00', $date->get(Zend_Date
::W3C
));
4302 $this->assertSame('2020-11-01T00:00:00+01:00', $date->get(Zend_Date
::W3C
));
4304 Zend_Date
::setOptions(array('fix_dst' => true));
4305 $date = new Zend_Date('2007-10-01 00:00:00', Zend_Date
::ISO_8601
);
4306 $this->assertSame('2007-10-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4308 $this->assertSame('2007-11-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4310 $date = new Zend_Date('2007-10-01 23:00:00', Zend_Date
::ISO_8601
);
4311 $this->assertSame('2007-10-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4313 $this->assertSame('2007-11-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4315 $date = new Zend_Date('2007-03-01 00:00:00', Zend_Date
::ISO_8601
);
4316 $this->assertSame('2007-03-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4318 $this->assertSame('2007-04-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4320 $date = new Zend_Date('2007-03-01 23:00:00', Zend_Date
::ISO_8601
);
4321 $this->assertSame('2007-03-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4323 $this->assertSame('2007-04-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4325 Zend_Date
::setOptions(array('fix_dst' => false));
4326 $date = new Zend_Date('2007-10-01 00:00:00', Zend_Date
::ISO_8601
);
4327 $this->assertSame('2007-10-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4329 $this->assertSame('2007-10-31 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4331 $date = new Zend_Date('2007-10-01 23:00:00', Zend_Date
::ISO_8601
);
4332 $this->assertSame('2007-10-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4334 $this->assertSame('2007-11-01 22:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4336 $date = new Zend_Date('2007-03-01 00:00:00', Zend_Date
::ISO_8601
);
4337 $this->assertSame('2007-03-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4339 $this->assertSame('2007-04-01 01:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4341 $date = new Zend_Date('2007-03-01 23:00:00', Zend_Date
::ISO_8601
);
4342 $this->assertSame('2007-03-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4344 $this->assertSame('2007-04-02 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4346 $date = new Zend_Date('2007-01-31 00:00:00', Zend_Date
::ISO_8601
);
4347 $this->assertSame('2007-01-31 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4349 $this->assertSame('2007-02-28 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4351 $date = new Zend_Date('2007-01-31 00:00:00', Zend_Date
::ISO_8601
);
4352 $this->assertSame('2007-01-31 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4353 Zend_Date
::setOptions(array('extend_month' => true));
4355 $this->assertSame('2007-03-03 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss'));
4357 date_default_timezone_set('America/Chicago');
4358 $date = new Zend_Date(1577858400,$locale);
4359 $date->setTimeZone(date_default_timezone_get());
4360 $this->assertSame('2020-01-01T00:00:00-06:00', $date->get(Zend_Date
::ISO_8601
));
4361 $date->addMonth(12);
4362 $this->assertSame('2021-01-01T00:00:00-06:00', $date->get(Zend_Date
::ISO_8601
));
4368 public function testSubMonth()
4370 $locale = new Zend_Locale('de_AT');
4372 $date = new Zend_Date(1577833200,$locale);
4373 $date->setTimeZone(date_default_timezone_get());
4376 $this->assertSame('2019-12-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4377 $date->subMonth(12);
4378 $this->assertSame('2018-12-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
4382 * Test for compareMonth
4384 public function testCompareMonth()
4386 $locale = new Zend_Locale('de_AT');
4387 $date = new Zend_Date(1234567890,$locale);
4388 $d2 = new Zend_Date(1234567899,$locale);
4390 $date = new Zend_Date(1234567890,$locale);
4391 $this->assertSame( 1, $date->compareMonth( 1));
4392 $this->assertSame( 0, $date->compareMonth( 2));
4393 $this->assertSame(-1, $date->compareMonth( 3));
4394 $this->assertSame( 0, $date->compareYear($d2));
4398 * Test accessors for _Locale member property of Zend_Date
4400 public function testLocale()
4402 $date = new Zend_Date(Zend_Date
::now());
4403 $locale = new Zend_Locale('en_US');
4404 $date->setLocale($locale);
4405 $this->assertSame('en_US', $date->getLocale());
4411 public function testGetWeek()
4413 $locale = new Zend_Locale('de_AT');
4414 $date = new Zend_Date(1168293600, $locale);
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());
4430 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4433 $date->addTime('05:30:00');
4434 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4438 $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString());
4441 // The right value for AM/PM has to be set in arabic letters
4442 $this->assertSame('08/01/1970 5:00:00 ص', $date->getWeek('ar_EG')->toString());
4443 $date->setTimeZone('UTC');
4444 $this->assertSame('08/01/1970 12:00:00 ص', $date->getWeek('ar_EG')->toString());
4445 $date->setTimeZone('Indian/Maldives');
4446 $this->assertSame('08/01/1970 5:00:00 ص', $date->getWeek('ar_EG')->toString());
4448 //Sunday [start of a new week as defined per ISO 8601]
4450 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4454 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4457 $date->addTime('15:45:00');
4458 $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString());
4462 * test setting dates to specify weekdays
4464 public function testDay()
4466 // all tests and calculations below are in GMT (that is intention for this test)
4467 $date = new Zend_Date(0, 'de_AT');
4468 $date->setTimeZone('UTC');
4469 $dw = $date->getDay();
4470 $this->assertSame('01.01.1970 00:00:00', $dw->toString());
4471 for($day = 1; $day < 31; $day++
) {
4472 $date->setDay($day);
4473 $dw = $date->getDay();
4474 $weekday = str_pad($day, 2, '0', STR_PAD_LEFT
);
4475 $this->assertSame("$weekday.01.1970 00:00:00", $dw->toString());
4482 public function testSetDayOnThirtyFirstGivesThirtyOne()
4484 $locale = new Zend_Locale('en_US');
4485 $date = new Zend_Date();
4486 $date->setYear(2009, $locale)
4487 ->setMonth(5, $locale)
4488 ->setDay(31, $locale);
4489 $this->assertSame('5/31/09', $date->get(Zend_Date
::DATE_SHORT
, $locale));
4495 public function testSetWeekday()
4497 $date = new Zend_Date('2006-01-01','YYYY-MM-dd', 'en');
4498 $date->setWeekday(1);
4499 $this->assertSame('2005-12-26T00:00:00+05:00', $date->getIso());
4501 $date->set('2006-01-02', 'YYYY-MM-dd');
4502 $date->setWeekday(1);
4503 $this->assertSame('2006-01-02T00:00:00+05:00', $date->getIso());
4507 * test setLocale/getLocale
4509 public function testSetLocale()
4511 $date = new Zend_Date(0, 'de');
4513 $this->assertSame('de', $date->getLocale());
4514 $date->setLocale('en');
4515 $this->assertSame('en', $date->getLocale());
4516 $date->setLocale('en_XX');
4517 $this->assertSame('en', $date->getLocale());
4518 $date->setLocale('de_AT');
4519 $this->assertSame('de_AT', $date->getLocale());
4520 $locale = new Zend_Locale('ar');
4521 $date->setLocale($locale);
4522 $this->assertSame('ar', $date->getLocale());
4525 $date->setLocale('xx_XX');
4527 } catch (Zend_Date_Exception
$e) {
4533 * test looseBehaviour
4535 public function testLoose()
4537 $date = new Zend_Date(0, 'de_DE');
4540 $date->set(null, Zend_Date
::YEAR
);
4542 } catch (Zend_Date_Exception
$e) {
4546 $date->set(10, 'de_DE');
4547 $this->assertEquals(10, $date->getTimestamp());
4550 $date->add(null, Zend_Date
::YEAR
);
4552 } catch (Zend_Date_Exception
$e) {
4556 $date->add(10, 'de_DE');
4557 $this->assertEquals(20, $date->getTimestamp());
4560 $date->sub(null, Zend_Date
::YEAR
);
4562 } catch (Zend_Date_Exception
$e) {
4566 $date->sub(10, 'de_DE');
4567 $this->assertEquals(10, $date->getTimestamp());
4570 $date->compare(null, Zend_Date
::YEAR
);
4572 } catch (Zend_Date_Exception
$e) {
4577 $date->equals(null, Zend_Date
::YEAR
);
4579 } catch (Zend_Date_Exception
$e) {
4584 $date->isEarlier(null, Zend_Date
::YEAR
);
4586 } catch (Zend_Date_Exception
$e) {
4591 $date->isLater(null, Zend_Date
::YEAR
);
4593 } catch (Zend_Date_Exception
$e) {
4598 $date->setTime(null);
4600 } catch (Zend_Date_Exception
$e) {
4605 $date->addTime(null);
4607 } catch (Zend_Date_Exception
$e) {
4612 $date->subTime(null);
4614 } catch (Zend_Date_Exception
$e) {
4619 $date->compareTime(null);
4621 } catch (Zend_Date_Exception
$e) {
4626 $date->setDate(null);
4628 } catch (Zend_Date_Exception
$e) {
4633 $date->addDate(null);
4635 } catch (Zend_Date_Exception
$e) {
4640 $date->subDate(null);
4642 } catch (Zend_Date_Exception
$e) {
4647 $date->compareDate(null);
4649 } catch (Zend_Date_Exception
$e) {
4654 $date->setIso(null);
4656 } catch (Zend_Date_Exception
$e) {
4661 $date->addIso(null);
4663 } catch (Zend_Date_Exception
$e) {
4668 $date->subIso(null);
4670 } catch (Zend_Date_Exception
$e) {
4675 $date->compareIso(null);
4677 } catch (Zend_Date_Exception
$e) {
4682 $date->setArpa(null);
4684 } catch (Zend_Date_Exception
$e) {
4689 $date->addArpa(null);
4691 } catch (Zend_Date_Exception
$e) {
4696 $date->subArpa(null);
4698 } catch (Zend_Date_Exception
$e) {
4703 $date->compareArpa(null);
4705 } catch (Zend_Date_Exception
$e) {
4710 $date->setYear(null);
4712 } catch (Zend_Date_Exception
$e) {
4717 $date->addYear(null);
4719 } catch (Zend_Date_Exception
$e) {
4724 $date->subYear(null);
4726 } catch (Zend_Date_Exception
$e) {
4731 $date->compareYear(null);
4733 } catch (Zend_Date_Exception
$e) {
4738 $date->setMonth(null);
4740 } catch (Zend_Date_Exception
$e) {
4745 $date->addMonth(null);
4747 } catch (Zend_Date_Exception
$e) {
4752 $date->subMonth(null);
4754 } catch (Zend_Date_Exception
$e) {
4759 $date->compareMonth(null);
4761 } catch (Zend_Date_Exception
$e) {
4766 $date->setDay(null);
4768 } catch (Zend_Date_Exception
$e) {
4773 $date->addDay(null);
4775 } catch (Zend_Date_Exception
$e) {
4780 $date->subDay(null);
4782 } catch (Zend_Date_Exception
$e) {
4787 $date->compareDay(null);
4789 } catch (Zend_Date_Exception
$e) {
4794 $date->setWeekday(null);
4796 } catch (Zend_Date_Exception
$e) {
4801 $date->addWeekday(null);
4803 } catch (Zend_Date_Exception
$e) {
4808 $date->subWeekday(null);
4810 } catch (Zend_Date_Exception
$e) {
4815 $date->compareWeekday(null);
4817 } catch (Zend_Date_Exception
$e) {
4822 $date->setDayOfYear(null);
4824 } catch (Zend_Date_Exception
$e) {
4829 $date->addDayOfYear(null);
4831 } catch (Zend_Date_Exception
$e) {
4836 $date->subDayOfYear(null);
4838 } catch (Zend_Date_Exception
$e) {
4843 $date->compareDayOfYear(null);
4845 } catch (Zend_Date_Exception
$e) {
4850 $date->setHour(null);
4852 } catch (Zend_Date_Exception
$e) {
4857 $date->addHour(null);
4859 } catch (Zend_Date_Exception
$e) {
4864 $date->subHour(null);
4866 } catch (Zend_Date_Exception
$e) {
4871 $date->compareHour(null);
4873 } catch (Zend_Date_Exception
$e) {
4878 $date->setMinute(null);
4880 } catch (Zend_Date_Exception
$e) {
4885 $date->addMinute(null);
4887 } catch (Zend_Date_Exception
$e) {
4892 $date->subMinute(null);
4894 } catch (Zend_Date_Exception
$e) {
4899 $date->compareMinute(null);
4901 } catch (Zend_Date_Exception
$e) {
4906 $date->setSecond(null);
4908 } catch (Zend_Date_Exception
$e) {
4913 $date->addSecond(null);
4915 } catch (Zend_Date_Exception
$e) {
4920 $date->subSecond(null);
4922 } catch (Zend_Date_Exception
$e) {
4927 $date->compareSecond(null);
4929 } catch (Zend_Date_Exception
$e) {
4934 $date->setWeek(null);
4936 } catch (Zend_Date_Exception
$e) {
4941 $date->addWeek(null);
4943 } catch (Zend_Date_Exception
$e) {
4948 $date->subWeek(null);
4950 } catch (Zend_Date_Exception
$e) {
4955 $date->compareWeek(null);
4957 } catch (Zend_Date_Exception
$e) {
4962 public function testTimesync()
4965 $server = new Zend_TimeSync('ntp://pool.ntp.org', 'alias');
4966 $date1 = $server->getDate();
4967 // need to use the proxy class to simulate time() returning wrong value
4968 $date2 = new Zend_Date_TestHelper(time());
4970 $info = $server->getInfo();
4972 if (($info['offset'] >= 1) ||
($info['offset'] <= -1)) {
4973 $this->assertFalse($date1->getTimestamp() == $date2->getTimestamp());
4975 $this->assertEquals($date1->getTimestamp(), $date2->getTimestamp());
4977 } catch (Zend_TimeSync_Exception
$e) {
4978 $this->markTestIncomplete('NTP timeserver not available.');
4982 public function testUsePhpDateFormat()
4984 Zend_Date
::setOptions(array('format_type' => 'iso'));
4986 // PHP date() format specifier tests
4987 $date1 = new Zend_Date('2006-01-02 23:58:59', Zend_Date
::ISO_8601
, 'en_US');
4988 $date2 = new Zend_Date('2006-01-02 23:58:59', 'YYYY-MM-dd HH:mm:ss', 'en_US');
4989 $this->assertSame($date1->getTimestamp(), $date2->getTimestamp());
4991 date_default_timezone_set('GMT');
4992 $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
4993 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'eee'));
4994 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'dd'));
4995 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString( 'EEE', 'en'));
4996 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'd'));
4997 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString( 'EEEE', 'en'));
4998 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'e'));
4999 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'SS'));
5000 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'D'));
5001 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'ww'));
5002 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString( 'MMMM', 'en'));
5003 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'MM'));
5004 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString( 'MMM', 'en'));
5005 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'M'));
5006 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 'ddd'));
5007 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'l'));
5008 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'YYYY'));
5009 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'yyyy'));
5010 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'yy'));
5011 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString( 'a', 'en')));
5012 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString( 'a', 'en')));
5013 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5014 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'h'));
5015 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'H'));
5016 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'hh'));
5017 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'HH'));
5018 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'mm'));
5019 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 'ss'));
5020 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'zzzz'));
5021 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5022 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'Z'));
5023 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'ZZZZ'));
5024 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'z'));
5025 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'X'));
5026 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString('yyyy-MM-ddTHH:mm:ssZZZZ'));
5027 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5028 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5030 // PHP date() format specifier tests
5031 $date1 = new Zend_Date('2006-01-02 23:58:59', Zend_Date
::ISO_8601
, 'en_US');
5032 Zend_Date
::setOptions(array('format_type' => 'php'));
5033 $date2 = new Zend_Date('2006-01-02 23:58:59', 'Y-m-d H:i:s', 'en_US');
5034 $this->assertSame($date1->getTimestamp(), $date2->getTimestamp());
5036 date_default_timezone_set('GMT');
5037 $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5038 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
5039 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
5040 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
5041 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j'));
5042 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en'));
5043 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N'));
5044 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S'));
5045 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z'));
5046 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W'));
5047 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en'));
5048 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm'));
5049 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en'));
5050 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n'));
5051 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't'));
5052 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L'));
5053 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o'));
5054 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y'));
5055 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y'));
5056 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5057 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5058 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5059 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g'));
5060 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G'));
5061 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h'));
5062 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H'));
5063 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i'));
5064 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's'));
5065 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e'));
5066 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5067 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O'));
5068 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P'));
5069 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T'));
5070 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z'));
5071 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c'));
5072 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5073 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5075 date_default_timezone_set('GMT');
5076 $date = new Zend_Date(mktime(20,10,0,10,10,2000)); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5077 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
5078 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
5079 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
5080 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j'));
5081 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en'));
5082 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N'));
5083 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S'));
5084 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z'));
5085 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W'));
5086 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en'));
5087 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm'));
5088 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en'));
5089 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n'));
5090 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't'));
5091 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L'));
5092 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o'));
5093 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y'));
5094 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y'));
5095 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5096 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5097 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5098 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g'));
5099 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G'));
5100 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h'));
5101 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H'));
5102 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i'));
5103 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's'));
5104 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e'));
5105 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5106 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O'));
5107 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P'));
5108 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T'));
5109 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z'));
5110 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c'));
5111 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5112 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5114 date_default_timezone_set('Indian/Maldives');
5115 $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5116 $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
5117 $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
5118 $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
5119 $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j'));
5120 $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en'));
5121 $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N'));
5122 $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S'));
5123 $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z'));
5124 $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W'));
5125 $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en'));
5126 $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm'));
5127 $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en'));
5128 $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n'));
5129 $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't'));
5130 $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L'));
5131 $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o'));
5132 $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y'));
5133 $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y'));
5134 $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5135 $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5136 $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B'));
5137 $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g'));
5138 $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G'));
5139 $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h'));
5140 $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H'));
5141 $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i'));
5142 $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's'));
5143 $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e'));
5144 $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I'));
5145 $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O'));
5146 $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P'));
5147 $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T'));
5148 $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z'));
5149 $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c'));
5150 $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r'));
5151 $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U'));
5153 date_default_timezone_set('Indian/Maldives');
5154 $date = new Zend_Date(mktime(20,10,0,10,10,2000)); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier)
5155 $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
5156 $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
5157 $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
5158 $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j'));
5159 $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en'));
5160 $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N'));
5161 $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S'));
5162 $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z'));
5163 $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W'));
5164 $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en'));
5165 $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm'));
5166 $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en'));
5167 $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n'));
5168 $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't'));
5169 $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L'));
5170 $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o'));
5171 $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y'));
5172 $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y'));
5173 $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5174 $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5175 $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B'));
5176 $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g'));
5177 $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G'));
5178 $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h'));
5179 $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H'));
5180 $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i'));
5181 $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's'));
5182 $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e'));
5183 $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I'));
5184 $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O'));
5185 $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P'));
5186 $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T'));
5187 $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z'));
5188 $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c'));
5189 $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r'));
5190 $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U'));
5191 Zend_Date
::setOptions(array('format_type' => 'iso'));
5194 public function testDaylightsaving()
5196 $date = new Zend_Date('2007.03.25', Zend_Date
::DATES
);
5197 $date->set('16:00:00', Zend_Date
::TIMES
);
5198 $this->assertEquals('2007-03-25T16:00:00+05:00', $date->get(Zend_Date
::W3C
));
5199 $date->set('01:00:00', Zend_Date
::TIMES
);
5200 $this->assertEquals('2007-03-25T01:00:00+05:00', $date->get(Zend_Date
::W3C
));
5203 public function testSetOptions()
5205 $options = Zend_Date
::setOptions();
5206 $this->assertTrue(is_array($options));
5207 $this->assertEquals('iso', $options['format_type']);
5209 Zend_Date
::setOptions(array('format_type' => 'php'));
5210 $options = Zend_Date
::setOptions();
5211 $this->assertEquals('php', $options['format_type']);
5214 Zend_Date
::setOptions(array('format_type' => 'non'));
5216 } catch (Zend_Date_Exception
$e) {
5221 Zend_Date
::setOptions(array('unknown' => 'non'));
5223 } catch (Zend_Date_Exception
$e) {
5227 Zend_Date
::setOptions(array('fix_dst' => 2));
5229 } catch (Zend_Date_Exception
$e) {
5234 Zend_Date
::setOptions(array('fix_dst' => 2));
5236 } catch (Zend_Date_Exception
$e) {
5240 require_once 'Zend/Cache.php';
5241 $cache = Zend_Cache
::factory('Core', 'File',
5242 array('lifetime' => 120, 'automatic_serialization' => true),
5243 array('cache_dir' => dirname(__FILE__
) . '/_files/'));
5244 Zend_Date
::setOptions(array('cache' => $cache));
5247 public function testIsDate()
5249 $this->assertTrue(Zend_Date
::isDate('25.03.2007', 'de_AT'));
5250 $this->assertTrue(Zend_Date
::isDate('2007.03.25', 'YYYY.MM.dd'));
5251 $this->assertTrue(Zend_Date
::isDate('25.Mai.2007', 'dd.MMMM.YYYY', 'de_AT'));
5252 $this->assertTrue(Zend_Date
::isDate('25.Mai.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT'));
5253 $this->assertFalse(Zend_Date
::isDate('32.Mai.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT'));
5254 $this->assertFalse(Zend_Date
::isDate('30.Februar.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT'));
5255 $this->assertFalse(Zend_Date
::isDate('30.Februar.2007 30:00:00', 'dd.MMMM.YYYY HH:mm:ss', 'de_AT'));
5256 $this->assertFalse(Zend_Date
::isDate(3.01));
5259 public function testToArray()
5261 $date = new Zend_Date('2006-01-02 23:58:59', Zend_Date
::ISO_8601
, 'en_US');
5262 $return = $date->toArray();
5263 $orig = array('day' => 02, 'month' => 01, 'year' => 2006, 'hour' => 23, 'minute' => 58,
5264 'second' => 59, 'timezone' => 'MVT', 'timestamp' => 1136228339, 'weekday' => 1,
5265 'dayofyear' => 1, 'week' => '01', 'gmtsecs' => 18000);
5266 $this->assertEquals($orig, $return);
5269 public function testFromArray()
5271 $date = new Zend_Date(array('day' => 04, 'month' => 12, 'year' => 2006, 'hour' => 10,
5272 'minute' => 56, 'second' => 30), 'en_US');
5273 $this->assertSame('2006-12-04T10:56:30+05:00', $date->getIso());
5276 public function testTimezoneArray()
5278 date_default_timezone_set('UTC');
5280 $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1,
5281 'hour' => 20, 'minute' => 45, 'second' => 37, 'en_US'));
5282 $this->assertSame('2007-01-01T20:45:37+00:00', $date->getIso());
5284 date_default_timezone_set('CET');
5285 $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1,
5286 'hour' => 1, 'minute' => 45, 'second' => 37, 'en_US'));
5287 $this->assertSame('2007-01-01T01:45:37+01:00', $date->getIso());
5289 $date = new Zend_Date(array('year' => 2006, 'month' => 4, 'day' => 18,
5290 'hour' => 12, 'minute' => 3, 'second' => 10, 'de_AT'));
5291 $this->assertSame('2006-04-18T12:03:10+02:00', $date->getIso());
5293 $date = new Zend_Date(array('year' => 2009, 'month' => 1, 'day' => 28,
5294 'hour' => 23, 'minute' => 30, 'second' => 00, 'de'));
5295 $this->assertSame('2009-01-28T23:30:00+01:00', $date->getIso());
5297 $date = new Zend_Date(array('year' => 2009, 'month' => 8, 'day' => 28,
5298 'hour' => 22, 'minute' => 00, 'second' => 00, 'de'));
5299 $this->assertSame('2009-08-28T22:00:00+02:00', $date->getIso());
5302 public function testExtendedDst()
5304 Zend_Date
::setOptions(array('format_type' => 'iso'));
5305 $date = new Zend_Date();
5306 $date->setTimezone('UTC');
5307 $date->set('25-05-2050 12:00:00');
5308 $this->assertSame('2050-05-25 12:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5309 $date->setTimezone('Europe/Warsaw');
5310 $this->assertSame('2050-05-25 14:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5312 $date->setTimezone('UTC');
5313 $date->set('25-05-2020 12:00:00');
5314 $this->assertSame('2020-05-25 12:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5315 $date->setTimezone('Europe/Warsaw');
5316 $this->assertSame('2020-05-25 14:00:00', $date->get('YYYY-MM-dd HH:mm:ss'));
5319 public function testGetFullYear()
5321 $this->assertSame(1970, Zend_Date
::getFullYear(70));
5322 $this->assertSame(1999, Zend_Date
::getFullYear(99));
5323 $this->assertSame(2000, Zend_Date
::getFullYear(0));
5324 $this->assertSame(2037, Zend_Date
::getFullYear(37));
5325 $this->assertSame(2069, Zend_Date
::getFullYear(69));
5326 $this->assertSame(-4, Zend_Date
::getFullYear(-4));
5327 $this->assertSame(100, Zend_Date
::getFullYear(100));
5333 public function testZF3677()
5335 $locale = new Zend_Locale('de_AT');
5336 require_once 'Zend/Registry.php';
5337 Zend_Registry
::set('Zend_Locale', $locale);
5339 $date = new Zend_Date('13',null,$locale);
5340 $this->assertSame($date->getLocale(), $locale->toString());
5346 public function testZF4867()
5348 date_default_timezone_set('America/New_York');
5349 $date1 = new Zend_Date('2006-01-01 01:00:00 Europe/Paris', Zend_Date
::ISO_8601
);
5350 $this->assertEquals('Europe/Paris', $date1->getTimezone());
5356 public function testMultiByteWeekdaysShouldNotBeTruncated()
5358 $date1 = new Zend_Date('pl');
5359 $date1->setWeekday(3);
5360 $this->assertEquals('ś', $date1->get(Zend_Date
::WEEKDAY_NARROW
));
5364 * Test for False Month Addition
5366 public function testAddingMonthWhenChangingTimezone()
5368 $date = new Zend_Date(mktime(22, 59, 59, 1, 10, 2009));
5369 $this->assertEquals(10, $date->toString('d'));
5370 $this->assertEquals( 1, $date->toString('M'));
5371 $date->setTimezone('Europe/Berlin');
5373 $this->assertEquals(10, $date->toString('d'));
5374 $this->assertEquals( 2, $date->toString('M'));
5378 * Test for False Month Addition
5380 public function testGmtOffsetValues()
5382 date_default_timezone_set('Pacific/Auckland');
5384 $date = new Zend_Date($time);
5385 $stamp = $date->getGmtOffset();
5387 $localtime = localtime($time, true);
5388 $offset = mktime($localtime['tm_hour'],
5389 $localtime['tm_min'],
5390 $localtime['tm_sec'],
5391 $localtime['tm_mon'] +
1,
5392 $localtime['tm_mday'],
5393 $localtime['tm_year'] +
1900)
5394 - gmmktime($localtime['tm_hour'],
5395 $localtime['tm_min'],
5396 $localtime['tm_sec'],
5397 $localtime['tm_mon'] +
1,
5398 $localtime['tm_mday'],
5399 $localtime['tm_year'] +
1900);
5401 $this->assertEquals($stamp, $offset);
5404 $stamp = $date->getGmtOffset();
5407 $localtime = localtime($time, true);
5408 $offset = mktime($localtime['tm_hour'],
5409 $localtime['tm_min'],
5410 $localtime['tm_sec'],
5411 $localtime['tm_mon'] +
7,
5412 $localtime['tm_mday'],
5413 $localtime['tm_year'] +
1900)
5414 - gmmktime($localtime['tm_hour'],
5415 $localtime['tm_min'],
5416 $localtime['tm_sec'],
5417 $localtime['tm_mon'] +
7,
5418 $localtime['tm_mday'],
5419 $localtime['tm_year'] +
1900);
5421 $this->assertEquals($stamp, $offset);
5424 public function testIsDateWithConstants()
5426 $this->assertTrue(Zend_Date
::isDate('2009-02-13T23:31:30+00:00', Zend_Date
::W3C
, 'de_AT'));
5428 $date = new Zend_Date();
5429 $string = $date->toString(Zend_Date
::DATES
);
5430 $this->assertTrue(Zend_Date
::isDate($string, Zend_Date
::DATES
));
5436 public function testZF7154()
5438 $locale = new Zend_Locale('de_AT');
5440 $date = new Zend_Date(1577833200,$locale);
5441 $date2 = new Zend_Date(2006, Zend_Date
::YEAR
);
5442 $date->setTimeZone(date_default_timezone_get());
5444 $date->setYear(2000);
5445 $date->setMonth('Apr');
5446 $this->assertSame('2000-04-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
5448 $date->setYear(2004);
5449 $date->setMonth('Februar');
5450 $this->assertSame('2004-02-01T04:00:00+05:00', $date->get(Zend_Date
::W3C
));
5456 public function testZF7202()
5458 $date = new Zend_Date();
5459 $timezone = $date->getTimezoneFromString('03:58:09 Jul 06, 2009 Indian/Reunion');
5460 $this->assertSame('Indian/Reunion', $timezone);
5466 public function testSetDateWithArray()
5468 $date = new Zend_Date(1234567890);
5469 $result = $date->setDate(array('year' => 2009, 'month' => 8, 'day' => 14));
5471 $this->assertSame('2009-08-14T04:31:30+05:00', $result->get(Zend_Date
::W3C
));
5477 public function testSetWithoutHourAtDSTChange()
5479 $this->assertTrue(Zend_Date
::isDate("23/05/2010", "dd/MM/yyyy", "it_IT"));
5480 $this->assertTrue(Zend_Date
::isDate("24/05/2010", "dd/MM/yyyy", "it_IT"));
5486 public function testSetArrayDateWithoutHour()
5488 $date = new Zend_Date(array(
5493 $this->assertEquals('2008-03-01T00:00:00+05:00', $date->getIso());
5500 public function testSetFirstDayOfLeapYear()
5502 $date = new Zend_Date(2008, Zend_Date
::YEAR
);
5503 $date->setDayOfYear(1);
5504 $this->assertEquals('2008-01-01T00:00:00+05:00', $date->getIso());
5506 $date->setDayOfYear(61);
5507 $this->assertEquals('2008-03-01T00:00:00+05:00', $date->getIso());
5509 $date->setDayOfYear(62);
5510 $this->assertEquals('2008-03-02T00:00:00+05:00', $date->getIso());
5516 public function testUsePhpNFormat()
5518 Zend_Date
::setOptions(array('format_type' => 'php'));
5520 date_default_timezone_set('GMT');
5521 $date = new Zend_Date(mktime(20,10,0,09,20,2009));
5522 $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
5523 $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
5524 $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
5525 $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j'));
5526 $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en'));
5527 $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N'));
5528 $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S'));
5529 $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z'));
5530 $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W'));
5531 $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en'));
5532 $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm'));
5533 $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en'));
5534 $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n'));
5535 $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't'));
5536 $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L'));
5537 $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o'));
5538 $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y'));
5539 $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y'));
5540 $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5541 $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5542 $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B'));
5543 $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g'));
5544 $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G'));
5545 $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h'));
5546 $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H'));
5547 $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i'));
5548 $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's'));
5549 $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e'));
5550 $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I'));
5551 $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O'));
5552 $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P'));
5553 $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T'));
5554 $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z'));
5555 $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c'));
5556 $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r'));
5557 $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));
5559 date_default_timezone_set('Indian/Maldives');
5560 $date = new Zend_Date(mktime(20,10,0,09,20,2009));
5561 $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
5562 $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
5563 $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
5564 $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j'));
5565 $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en'));
5566 $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N'));
5567 $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S'));
5568 $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z'));
5569 $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W'));
5570 $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en'));
5571 $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm'));
5572 $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en'));
5573 $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n'));
5574 $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't'));
5575 $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L'));
5576 $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o'));
5577 $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y'));
5578 $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y'));
5579 $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en')));
5580 $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en')));
5581 $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B'));
5582 $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g'));
5583 $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G'));
5584 $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h'));
5585 $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H'));
5586 $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i'));
5587 $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's'));
5588 $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e'));
5589 $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I'));
5590 $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O'));
5591 $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P'));
5592 $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T'));
5593 $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z'));
5594 $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c'));
5595 $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r'));
5596 $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U'));
5597 Zend_Date
::setOptions(array('format_type' => 'iso'));
5603 public function testPhpFormatWithIsEmpty()
5605 Zend_Date
::setOptions(array('format_type' => 'php'));
5606 $date1 = new Zend_Date();
5607 $date2 = clone $date1;
5608 $date2->add(1, 'd');
5610 $this->assertTrue($date1->isEarlier($date2, 'd.M.y'));
5611 $this->assertFalse($date2->isEarlier($date1, 'd.M.y'));
5612 $this->assertFalse($date1->isLater($date2, 'd.M.y'));
5613 $this->assertTrue($date2->isLater($date1, 'd.M.y'));
5616 public function testPhpFormatWithToString()
5618 Zend_Date
::setOptions(array('format_type' => 'php'));
5619 $date = new Zend_Date('10.10.2009 10:10:10');
5620 $this->assertEquals('10.10.2009 10:10:10', $date->toString("d.m.Y H:i:s"));
5621 $date->setTime("23:59:59");
5622 $this->assertEquals('10.10.2009 23:59:59', $date->toString("d.m.Y H:i:s"));
5628 public function testFractionalPrecision()
5630 $date = new Zend_Date();
5631 $date->set('012345', Zend_Date
::MILLISECOND
);
5633 $this->assertEquals(3, $date->getFractionalPrecision());
5634 $this->assertEquals('345', $date->toString('S'));
5636 $date->setFractionalPrecision(6);
5637 $this->assertEquals(6, $date->getFractionalPrecision());
5638 $this->assertEquals('345000', $date->toString('S'));
5640 $date->add(200, Zend_Date
::MILLISECOND
);
5641 $this->assertEquals(6, $date->getFractionalPrecision());
5642 $this->assertEquals('345200', $date->toString('S'));
5648 public function testGettingMonthWhenUsingGNU()
5650 Zend_Date
::setOptions(array('format_type' => 'php'));
5651 $date = new Zend_Date(array('day' => 1, 'month' => 4, 'year' => 2008));
5652 $date2 = $date->getMonth();
5653 $result = $date2->toArray();
5654 $this->assertEquals(1970, $result['year']);
5658 class Zend_Date_TestHelper
extends Zend_Date
5660 public function _setTime($timestamp)
5662 $this->_getTime($timestamp);
5665 protected function _getTime($timestamp = null)
5667 static $_timestamp = null;
5668 if ($timestamp !== null) {
5669 $_timestamp = $timestamp;
5671 if ($_timestamp !== null) {
5677 public function mktime($hour, $minute, $second, $month, $day, $year, $dst= -1, $gmt = false)
5679 return parent
::mktime($hour, $minute, $second, $month, $day, $year, $dst, $gmt);