Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #315 from froschdesign/hotfix/2
Browse files Browse the repository at this point in the history
Fixes #2 - Long Timezones in Zend_Date constructor ignored with custom d...
  • Loading branch information
akrabat committed Apr 1, 2014
2 parents 810ac28 + a40d412 commit 4afa824
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Date.php
Expand Up @@ -1208,7 +1208,7 @@ public function getTimezoneFromString($zone)
return $zone;
}

preg_match('/([[:alpha:]\/]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);
preg_match('/([[:alpha:]\/_]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);
try {
if (!empty($match) and (!is_int($match[count($match) - 1]))) {
$oldzone = $this->getTimezone();
Expand Down
18 changes: 18 additions & 0 deletions tests/Zend/DateTest.php
Expand Up @@ -5698,6 +5698,24 @@ public function testDateShouldMatchOnFirstDayOfYear()
$out = $date->toString('Y-MM-dd');
$this->assertEquals('2012-01-01', $out);
}

/**
* @group GH-2
*/
public function testGetTimezoneFromStringForTimezonesWithUnderscore()
{
$date = new Zend_Date();

$this->assertEquals(
'America/Los_Angeles',
$date->getTimezoneFromString('America/Los_Angeles')
);

$this->assertEquals(
'America/New_York',
$date->getTimezoneFromString('America/New_York')
);
}
}

class Zend_Date_TestHelper extends Zend_Date
Expand Down

0 comments on commit 4afa824

Please sign in to comment.