Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit d036788

Browse files
committed
Fixes zendframework#561 - Zend_Date not expected year
1 parent 715222a commit d036788

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

library/Zend/Date/DateObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ protected function date($format, $timestamp = null, $gmt = false)
318318
// standard). However, this is not desired, so replacing
319319
// all occurrences of "o" not preceded by a backslash
320320
// with "Y"
321-
$format = preg_replace('/(?<!\\\\)o\b/', 'Y', $format);
321+
$format = preg_replace('/(?<!\\\\)o/', 'Y', $format);
322322
$result = ($gmt) ? @gmdate($format, $timestamp) : @date($format, $timestamp);
323323
date_default_timezone_set($oldzone);
324324
return $result;

tests/Zend/DateTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5725,6 +5725,18 @@ public function testGetTimezoneFromStringForTimezonesWithUnderscore()
57255725
$date->getTimezoneFromString('America/New_York')
57265726
);
57275727
}
5728+
5729+
/**
5730+
* @group GH-561
5731+
*/
5732+
public function testGetYearAndMonthWithoutDot()
5733+
{
5734+
$date = new Zend_Date('2014.12.29');
5735+
5736+
$this->assertEquals('29.12.2014', $date->get(Zend_Date::DATE_MEDIUM));
5737+
$this->assertEquals('2014.12', $date->get('Y.M'));
5738+
$this->assertEquals('201412', $date->get('YM'));
5739+
}
57285740
}
57295741

57305742
class Zend_Date_TestHelper extends Zend_Date

0 commit comments

Comments
 (0)