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

Fixes #2 - Long Timezones in Zend_Date constructor ignored with custom d... #315

Merged
merged 1 commit into from
Apr 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/Date.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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