Permalink
Browse files

Supporting %e in windows. Fixes #1510.

  • Loading branch information...
1 parent 8d5e68d commit f2a4b1e9599e5e7d4493d8368f20af815e4566f3 @jrbasso jrbasso committed Feb 6, 2011
Showing with 17 additions and 0 deletions.
  1. +9 −0 cake/libs/view/helpers/time.php
  2. +8 −0 cake/tests/cases/libs/view/helpers/time.test.php
@@ -79,6 +79,15 @@ function __translateSpecifier($specifier) {
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':
@@ -731,6 +731,14 @@ function testConvertSpecifiers() {
$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);

0 comments on commit f2a4b1e

Please sign in to comment.