From f2a4b1e9599e5e7d4493d8368f20af815e4566f3 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 6 Feb 2011 15:51:28 -0200 Subject: [PATCH] Supporting %e in windows. Fixes #1510. --- cake/libs/view/helpers/time.php | 9 +++++++++ cake/tests/cases/libs/view/helpers/time.test.php | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 1f4d0be1c..27c690b5a 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -79,6 +79,15 @@ class TimeHelper extends AppHelper { return sprintf("%02d", date('Y', $this->__time) / 100); case 'D': return '%m/%d/%y'; + case 'e': + if (DS === '/') { + return '%e'; + } + $day = date('j', $this->__time); + if ($day < 10) { + $day = ' ' . $day; + } + return $day; case 'eS' : return date('jS', $this->__time); case 'b': diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index bfdbb9ccd..cbe42d2a1 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -731,6 +731,14 @@ class TimeHelperTest extends CakeTestCase { $expected = 4; $this->assertEqual($result, $expected); + $result = $this->Time->convertSpecifiers('%e', $time); + $expected = '14'; + $this->assertEqual($result, $expected); + + $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); + $expected = ' 1'; + $this->assertEqual($result, $expected); + $result = $this->Time->convertSpecifiers('%x', $time); $expected = '%d/%m/%y'; $this->assertEqual($result, $expected);