From 77294ba789d1ea3a695f80580d2e89ee175687cf Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 27 Oct 2015 23:30:05 -0400 Subject: [PATCH] Start adding the Date wrapper. Add the I18n\Date class which adds the same i18n features to Dates that we offer on Time instances. The timeAgoInWords() method has not been implemented yet. --- src/I18n/Date.php | 62 +++++++++++++++++++++++++ tests/TestCase/I18n/DateTest.php | 79 ++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/I18n/Date.php create mode 100644 tests/TestCase/I18n/DateTest.php diff --git a/src/I18n/Date.php b/src/I18n/Date.php new file mode 100644 index 00000000000..2e4ffd275b0 --- /dev/null +++ b/src/I18n/Date.php @@ -0,0 +1,62 @@ +i18nFormat(); + $expected = '1/14/10'; + $this->assertEquals($expected, $result); + + $result = $time->i18nFormat(\IntlDateFormatter::FULL, null, 'es-ES'); + $expected = 'jueves, 14 de enero de 2010, 0:00:00 (GMT)'; + $this->assertEquals($expected, $result); + + $format = [\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT]; + $result = $time->i18nFormat($format); + $expected = '12:00 AM'; + $this->assertEquals($expected, $result); + + $result = $time->i18nFormat('HH:mm:ss', 'Australia/Sydney'); + $expected = '00:00:00'; + $this->assertEquals($expected, $result); + + Date::$defaultLocale = 'fr-FR'; + $result = $time->i18nFormat(\IntlDateFormatter::FULL); + $expected = 'jeudi 14 janvier 2010 00:00:00 UTC'; + $this->assertEquals($expected, $result); + + $result = $time->i18nFormat(\IntlDateFormatter::FULL, null, 'es-ES'); + $expected = 'jueves, 14 de enero de 2010, 0:00:00 (GMT)'; + $this->assertEquals($expected, $result, 'Default locale should not be used'); + } + + public function testToString() + { + $this->markTestIncomplete(); + } + + public function testJsonSerialize() + { + $this->markTestIncomplete(); + } + + public function testParseDate() + { + $this->markTestIncomplete(); + } + + public function testParseDateTime() + { + $this->markTestIncomplete(); + } +}