コード例 #1
0
ファイル: function.dateTest.php プロジェクト: cargomedia/cm
 public function testRender()
 {
     $time = strtotime('2003-02-01 12:34');
     foreach ([['params' => ['time' => $time], 'expected' => '2/1/03'], ['params' => ['time' => $time, 'showTime' => true], 'expected' => CMTest_TH::getVersionICU() < 50 ? '2/1/03 12:34 PM' : '2/1/03, 12:34 PM'], ['params' => ['time' => $time, 'showTime' => true, 'timeZone' => new DateTimeZone('US/Eastern')], 'expected' => CMTest_TH::getVersionICU() < 50 ? '2/1/03 7:34 AM' : '2/1/03, 7:34 AM'], ['params' => ['time' => $time, 'showTime' => true, 'timeZone' => 'US/Eastern'], 'expected' => CMTest_TH::getVersionICU() < 50 ? '2/1/03 7:34 AM' : '2/1/03, 7:34 AM'], ['params' => ['time' => $time, 'showWeekday' => true], 'expected' => 'Sat 2/1/03']] as $testData) {
         $this->_assertSame($testData['expected'], $testData['params']);
     }
 }
コード例 #2
0
ファイル: RenderTest.php プロジェクト: cargomedia/cm
 public function testGetFormatterDateNumericalOverrideTimeZone()
 {
     $time = new DateTime('2016-05-21 00:00:00', new DateTimeZone('UTC'));
     $timeZone = DateTime::createFromFormat('O', '+02:00')->getTimezone();
     $timeZoneOverride = DateTime::createFromFormat('O', '+03:00')->getTimezone();
     $render = new CM_Frontend_Render(new CM_Frontend_Environment(null, null, null, $timeZone));
     $formatter = $render->getFormatterDate(IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, null, $timeZoneOverride);
     if (CMTest_TH::getVersionICU() < 50) {
         $this->assertSame('5/21/16 3:00 AM', $formatter->format($time));
     } else {
         $this->assertSame('5/21/16, 3:00 AM', $formatter->format($time));
     }
 }