Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ensure that DateTimeFormatter doesn't format an empty string #4394

Closed
wants to merge 1 commit into from

3 participants

@akrabat
Collaborator

This fixes #4393 and maintains BC.

@weierophinney weierophinney was assigned
@weierophinney weierophinney closed this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4394'
Close #4394
Fixes #4393
dd12afa
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4394' into develop
Forward port #4394
ee0cae5
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4394'
Close #4394
Fixes #4393
17604ed
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4394' into develop
Forward port #4394
d4278d8
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge pull request zendframework/zf2#4394 from akrabat/hotfix/4393
Ensure that DateTimeFormatter doesn't format an empty string
5354884
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge branch 'hotfix/4394' c140dfc
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge branch 'hotfix/4394' into develop c7fb429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 2, 2013
  1. @akrabat

    Ensure that DateTimeFormatter doesn't format an empty string

    akrabat authored
    This fixes #4393 and maintains BC.
This page is out of date. Refresh to see the latest.
View
4 library/Zend/Filter/DateTimeFormatter.php
@@ -71,7 +71,9 @@ public function filter($value)
*/
protected function normalizeDateTime($value)
{
- if (is_int($value)) {
+ if (empty($value)) {
+ return $value;
+ } elseif (is_int($value)) {
$dateTime = new DateTime('@' . $value);
} elseif (!$value instanceof DateTime) {
$dateTime = new DateTime($value);
View
9 tests/ZendTest/Filter/DateTimeFormatterTest.php
@@ -33,6 +33,15 @@ public function tearDown()
date_default_timezone_set($this->defaultTimezone);
}
+ public function testFormatterDoesNotFormatAnEmptyString()
+ {
+ date_default_timezone_set('UTC');
+
+ $filter = new DateTimeFormatter();
+ $result = $filter->filter('');
+ $this->assertEquals('', $result);
+ }
+
public function testDateTimeFormatted()
{
date_default_timezone_set('UTC');
Something went wrong with that request. Please try again.