Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Serializer] Allow custom timezone inDateTimeNormalizer
during denormalization#60153
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Add PRESERVE_CONTEXT_TIMEZONE_KEY and adjust DateTime object during denormalization
Update changelog.md
carsonbot commentedApr 5, 2025
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Updated codequality failures
Possibility of lowering complexity: There are currently 2 similar blocks of code for I was hesistant to do this immediately because i have no idea why there is different error handling for the context $dateTimeFormat. |
DateTimeNormalizer
during denormalizationUh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Add `withPreserveContextTimezone` to `DateTimeNormalizerContextBuilder`
Uh oh!
There was an error while loading.Please reload this page.
By default the
DateTimeNormalizer
will denormalize timestamps and date strings that include a timezone toDateTime
objects with respective timezone UTC or the timezone from the date string. Even with the context keyTIMEZONE_KEY
set, the timezone from the input superceeds the context timezone.This PR allows to set
PRESERVE_CONTEXT_TIMEZONE_KEY
context totrue
(default:false
), which in combination withTIMEZONE_KEY
will set the Timezone of the denormalized DateTimes to the given timezone. The timezone from the input will be overwritten.Documentation
symfony/symfony-docs#20860