Merge pull request #4360 from owncloud/format-date-numeric-strings
Do not pass numeric strings to strtotime() when formatting dates.
This commit is contained in:
commit
4128561f22
|
@ -386,8 +386,7 @@ class OC_L10N {
|
|||
case 'time':
|
||||
if($data instanceof DateTime) {
|
||||
return $data->format($this->localizations[$type]);
|
||||
}
|
||||
elseif(is_string($data)) {
|
||||
} elseif(is_string($data) && !is_numeric($data)) {
|
||||
$data = strtotime($data);
|
||||
}
|
||||
$locales = array(self::findLanguage());
|
||||
|
|
|
@ -52,4 +52,16 @@ class Test_L10n extends PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals('5 oken', (string)$l->n('%n window', '%n windows', 5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue #4360: Do not call strtotime() on numeric strings.
|
||||
*/
|
||||
public function testNumericStringToDateTime() {
|
||||
$l = new OC_L10N('test');
|
||||
$this->assertSame('February 13, 2009 23:31', $l->l('datetime', '1234567890'));
|
||||
}
|
||||
|
||||
public function testNumericToDateTime() {
|
||||
$l = new OC_L10N('test');
|
||||
$this->assertSame('February 13, 2009 23:31', $l->l('datetime', 1234567890));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue