Browse Source

Fix time format in Time helper

mscherer 4 years ago
parent
commit
cf9edc22e0
2 changed files with 5 additions and 4 deletions
  1. 2 2
      src/View/Helper/TimeHelper.php
  2. 3 2
      tests/TestCase/View/Helper/TimeHelperTest.php

+ 2 - 2
src/View/Helper/TimeHelper.php

@@ -158,13 +158,13 @@ class TimeHelper extends CakeTimeHelper {
 
 		//$y = $this->isThisYear($date) ? '' : ' Y';
 
-		$format = (!empty($options['format']) ? $options['format'] : FORMAT_NICE_YMD);
+		$format = (!empty($options['format']) ? $options['format'] : 'dd.MM.YYYY');
 
 		// Hack
 		// //TODO: get this to work with datetime - somehow cleaner
 		$timeAttachment = '';
 		if (isset($options['niceDateTime'])) {
-			$timeAttachment = ', ' . $this->nice($date, $options['niceDateTime']);
+			$timeAttachment = ', ' . $this->format($date, $options['niceDateTime']);
 			$whenOverride = true;
 		}
 

+ 3 - 2
tests/TestCase/View/Helper/TimeHelperTest.php

@@ -82,11 +82,12 @@ class TimeHelperTest extends TestCase {
 		$result = $this->Time->published((new FrozenTime(date(FORMAT_DB_DATETIME)))->subDays(2));
 		$expected = 'class="published already';
 		$this->assertStringContainsString($expected, $result);
+
+		$result = $this->Time->published(new FrozenTime('2012-02-03 14:12:10'));
+		$this->assertStringContainsString('03.02.2012', $result);
 	}
 
 	/**
-	 * DatetimeHelperTest::testTimezones()
-	 *
 	 * @return void
 	 */
 	public function testTimezones() {