Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed DateTimeZone support in date filter. #736

Merged
merged 1 commit into from
May 29, 2012
Merged

Fixed DateTimeZone support in date filter. #736

merged 1 commit into from
May 29, 2012

Conversation

blaugueux
Copy link
Contributor

Now $date converted to a DateTime has a DateTimeZone in every case.

if (!$timezone instanceof DateTimeZone) {
$timezone = new DateTimeZone($timezone);
if ($timezone instanceof DateTimeZone) {
$date->setTimezone($timezone);
Copy link
Member

Choose a reason for hiding this comment

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

This will have a side-effect when passing an existing DateTime object as it will change the timezone of the existing objects. Unfortunately, PHP DateTime objects are not immutable. In case of a DateTime object passed by the user (the case which was returning early previously), you need to clone the object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right. I've fixed this below.

@fabpot
Copy link
Contributor

fabpot commented May 28, 2012

Can you add some unit tests to avoid regression to happen later? Thanks.

@blaugueux
Copy link
Contributor Author

@fabpot Here they are.

@fabpot
Copy link
Contributor

fabpot commented May 29, 2012

Great! Can you add a note in the CHANGELOG file and then squash your commit before I merge? Thanks.

@blaugueux
Copy link
Contributor Author

Changelog added. First squash of my life, i cannot say if it's good :(

@stof
Copy link
Member

stof commented May 29, 2012

it is not. you merged your remote branch instead of forcing the push

Prevents the DateTime object to be updated when changing the DateTimeZone.

Unit tests added.

Updated changelog.
@blaugueux
Copy link
Contributor Author

Ok @stof, thanks for your help. I think it's good now.

@fabpot Is it ok for you ?

fabpot added a commit that referenced this pull request May 29, 2012
Commits
-------

c53a02d Fixed DateTimeZone support in date filter.

Discussion
----------

Fixed DateTimeZone support in date filter.

Now $date converted to a DateTime has a DateTimeZone in every case.

---------------------------------------------------------------------------

by fabpot at 2012-05-28T19:20:47Z

Can you add some unit tests to avoid regression to happen later? Thanks.

---------------------------------------------------------------------------

by blaugueux at 2012-05-29T07:52:58Z

@fabpot Here they are.

---------------------------------------------------------------------------

by fabpot at 2012-05-29T10:29:28Z

Great! Can you add a note in the CHANGELOG file and then squash your commit before I merge? Thanks.

---------------------------------------------------------------------------

by blaugueux at 2012-05-29T12:52:22Z

Changelog added. First squash of my life, i cannot say if it's good :(

---------------------------------------------------------------------------

by stof at 2012-05-29T12:55:26Z

it is not. you merged your remote branch instead of forcing the push

---------------------------------------------------------------------------

by blaugueux at 2012-05-29T17:12:05Z

Ok @stof, thanks for your help. I think it's good now.

@fabpot Is it ok for you ?
@fabpot fabpot merged commit c53a02d into twigphp:master May 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants