Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Zend\I18n\View\Helper\DateFormat - Fallback to date.timezone instead of system timezone. #2273

Merged
merged 3 commits into from
Aug 31, 2012
Merged

Zend\I18n\View\Helper\DateFormat - Fallback to date.timezone instead of system timezone. #2273

merged 3 commits into from
Aug 31, 2012

Conversation

dmitrybelyakov
Copy link

Fallback to date.timezone instead of system timezone.

If we do not explicitly set timezone on DateFormat, it passes null value as timezone to IntlDateFormatter, that should fallback to date.timezone but doesn't. So we better do it ourselves.

Here's a test to demonstrate the bug:

//set timezone to UTC
ini_set('date.timezone', 'UTC');

$now = new \DateTime;
$now->setTimezone(new \DateTimeZone('UTC'));
$expected = $now->format('g:i A');

//format
$helper = $this->getLocator()->get('Zend\I18n\View\Helper\DateFormat');
$formatted = $helper->__invoke(
    $now,
    \IntlDateFormatter::NONE,
    \IntlDateFormatter::SHORT,
    'en_US'
);

$this->assertEquals($expected, $formatted);

@travisbot
Copy link

This pull request fails (merged 0444e61 into 89eaf41).

@travisbot
Copy link

This pull request fails (merged c09afbe into 89eaf41).

@@ -69,6 +69,10 @@ public function setTimezone($timezone)
*/
public function getTimezone()
{
if(!$this->timezone) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS: need a space between "if" and opening paren.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks :) Wonder if this could go into 2.0 because we really need that.

@travisbot
Copy link

This pull request passes (merged 7c5e5ab into 89eaf41).

@DASPRiD
Copy link
Member

DASPRiD commented Aug 31, 2012

Going to technically review it later today.

@dmitrybelyakov
Copy link
Author

Thanks Ben!

weierophinney added a commit that referenced this pull request Aug 31, 2012
- Noted fix to DateFormat helper
@weierophinney weierophinney merged commit 7c5e5ab into zendframework:master Aug 31, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants