Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow to specify custom pattern for date #2411

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

bakura10 commented Sep 24, 2012

This PR allows to set a specific pattern for date, useful when pre-defined pattern are not enough.

@weierophinney weierophinney and 1 other commented on an outdated diff Sep 25, 2012

library/Zend/I18n/View/Helper/DateFormat.php
*/
public function __invoke(
$date,
$dateType = IntlDateFormatter::NONE,
$timeType = IntlDateFormatter::NONE,
+ $pattern = null,
$locale = null
@weierophinney

weierophinney Sep 25, 2012

Owner

This changes the API, as it introduces an argument between existing arguments. The pattern needs to be the last argument.

@bakura10

bakura10 Sep 25, 2012

Contributor

Done.

Owner

weierophinney commented Oct 1, 2012

Merged to develop branch; will release with 2.1.

Contributor

chrvadala commented Oct 16, 2012

I think there is a bug that is not showed in test case, but that you can see if you put two pattern in a same view.

If you put this in a view

<?php $date = new \DateTime();
echo $this->dateFormat($date,null,null,null,'EEEE');
echo $this->dateFormat($date,null,null,null,'dMMMYYYY');?>

you can see that the second pattern is ignored and the second print is same to the first.

I think that the problem is here:
https://github.com/zendframework/zf2/blob/develop/library/Zend/I18n/View/Helper/DateFormat.php#L127

Contributor

chrvadala commented Oct 16, 2012

This can solve the problem:

$formatterId = md5($dateType . "\0" . $timeType . "\0" . $locale . "\0" . $pattern);
Member

Bittarman commented Oct 16, 2012

ThisIsTheWeb, this would be better opened as an issue, this pull request was closed some time ago now.

@weierophinney weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015

@weierophinney weierophinney Merge branch 'feature/2411' into develop a89b734
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment