Browse Source

Add strftime() support to CakeTime::timeAgoInWords()

When an absolute date is generated CakeTime will automatically use
strftime() if the format string contains %. This allows for simpler
localization.

Refs #4550
mstra001 11 years ago
parent
commit
244acc724d
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lib/Cake/Utility/CakeTime.php

+ 5 - 1
lib/Cake/Utility/CakeTime.php

@@ -796,7 +796,11 @@ class CakeTime {
 		}
 
 		if ($diff > abs($now - self::fromString($end))) {
-			return sprintf($absoluteString, date($format, $inSeconds));
+			return sprintf($absoluteString,
+					(strpos($format, '%') === false) ?
+						date($format, $inSeconds) :
+						self::_strftime($format, $inSeconds)
+			);
 		}
 
 		// If more than a week, then take into account the length of months