Skip to content

Fix wrong DateTransformer timezone param for non-UTC configuration #12911

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

Merged
merged 1 commit into from
Dec 29, 2014

Conversation

soullivaneuh
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? N/A
Fixed tickets #12808
License MIT
Doc PR none

This PR is a fix of a little mistake on PR #12404.

Thanks @mvrhov for the clue! 👍

Pass 'UTC' param cause issue on single_text date type, null should be passed to get the default php timezone.

Don't know how to add test for #12808 issue, do someone know how to "change" properly timezone during tests? Where can I do this?

Thanks.

@xabbuh
Copy link
Member

xabbuh commented Dec 9, 2014

@soullivaneuh You could probably base your fix on the tests from #12843.

@soullivaneuh
Copy link
Contributor Author

@xabbuh ok I will rebase my commit and run this test when it will be merged.

@wouterj
Copy link
Member

wouterj commented Dec 14, 2014

The options that were used need to be readded too, as it's now a bc break (throwing an option does not exist exception)

@soullivaneuh
Copy link
Contributor Author

@wouterj I understand. I made this PR in priority to fix a critical error for most applications.

Don't know how @fabpot and symfony team want to manage this BC break.

@sstok
Copy link
Contributor

sstok commented Dec 16, 2014

Using Timezone for time doesn't make sense and leads to problems with DST (which was the original issue). So for that we can use UTC as timezone and Jan 1st, 1970 as the date (for BC).

The problem with the Date and timezone was that you could get the wrong date (for the same reason).
#7187 (comment)

Doctrine also warns for storing an timezone specific DateTime in the DB and advises to use UTC as timezone instead.

So for Date(Time) we should be able to use the timezone of the user (view) and convert it to UTC in the model.

Time is simply something we can't fix without a Date, so using UTC for BC seems like the best compromise.

@lucagtc
Copy link

lucagtc commented Dec 16, 2014

Why not implement a single option to determine the timezone to use. It can be set default to null or UTC or date_default_timezone_get().

@sstok
Copy link
Contributor

sstok commented Dec 16, 2014

If you set the timezone to null it will use the default date_default_timezone_get().

@lucagtc
Copy link

lucagtc commented Dec 18, 2014

I sugest this solution (lucagtc@0b3062f).
Use only model_timezone.

Doctrine (Propel I don't know, but it should be the same) by default create DateTime for date and time field with default timezone, so I'm suggest to leave model_timezone = null.

Luca

@fabpot
Copy link
Member

fabpot commented Dec 20, 2014

ping @webmozart

@acasademont
Copy link
Contributor

The problem is that Doctrine creates DateTime objects with the default timezone in the "time" type but the Form Component assumes UTC in the model, so there's a nice break here.

Even I agree that timezones make no sense in time types this is not a subtle change, it should have been done in 3.0 with some coordination with the Doctrine team.

+1 for the quick fix!

@fabpot
Copy link
Member

fabpot commented Dec 29, 2014

Thank you @soullivaneuh.

@fabpot fabpot merged commit 0104f15 into symfony:2.6 Dec 29, 2014
fabpot added a commit that referenced this pull request Dec 29, 2014
…guration (Soullivaneuh)

This PR was merged into the 2.6 branch.

Discussion
----------

Fix wrong DateTransformer timezone param for non-UTC configuration

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | N/A
| Fixed tickets | #12808
| License       | MIT
| Doc PR        | none

This PR is a fix of a little mistake on PR #12404.

Thanks @mvrhov for the clue! 👍

Pass 'UTC' param cause issue on single_text date type, `null` should be passed to get the default php timezone.

Don't know how to add test for #12808 issue, do someone know how to "change" properly timezone during tests? Where can I do this?

Thanks.

Commits
-------

0104f15 Fix wrong DateTransformer timezone param for non-UTC configuration. #12808
@soullivaneuh soullivaneuh deleted the 2.6 branch December 29, 2014 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants