-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Fix denormalizing date intervals having both weeks and days #52626
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 “Sig 8000 n 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
[Serializer] Fix denormalizing date intervals having both weeks and days #52626
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, to make it work, we need to update the format.
Maybe it could be great to create as well a PR targeting 7.1 to update the format const value, WDYT?
src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once comments are fixed.
src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php
Outdated
Show resolved
Hide resolved
7744b34
to
c88d49e
Compare
Thank you @oneNevan. |
@mtarld Regarding this, I agree it does make sense, but there is one thing to consider - adding So, it looks like if we want to support weeks out of the box, we would have to split FORMAT_KEY constant, into two constants: one for normalizer (without At this point I wanted to fix the regular expression at least, so that devs could use custom format if they deal with periods having weeks (as I do), but I'm not sure if it worth changing the current default format to support it out of the box, do you think it makes sense? |
Indeed, it sounds like an edge case finally. I think that we might keep it like that, thank you for that feedback 🙂 |
Added support for date periods having both W and D period designators combined together (which is valid duration for ISO 8601-2). Starting from PHP 8 this is supported by \DateTimeInterval, see https://bugs.php.net/bug.php?id=61366 for reference