[Yaml] support to parse and dump DateTime objects#17836
Merged
Conversation
Member
xabbuh
commented
Feb 17, 2016
| Q | A |
|---|---|
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #6275, #8580, #11838, #14420 |
| License | MIT |
| Doc PR | symfony/symfony-docs#6226 |
This was referenced Feb 17, 2016
3c35bdf to
2f02c57
Compare
| * Added support for parsing timestamps as `\DateTime` objects: | ||
|
|
||
| ```php | ||
| Yaml::parse('2001-12-15 21:59:43.10 -5', Yaml::Parse_DATETIME); |
Contributor
There was a problem hiding this comment.
Should be capitalized: Yaml::PARSE_DATETIME.
dbd6af3 to
fabf9ae
Compare
| case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): | ||
| return (float) str_replace(',', '', $scalar); | ||
| case preg_match(self::getTimestampRegex(), $scalar) && Yaml::PARSE_DATETIME & $flags: | ||
| return new \DateTime($scalar,new \DateTimeZone('UTC')); |
Member
There was a problem hiding this comment.
Can we move this into the next case to avoid matching twice?
Member
Author
There was a problem hiding this comment.
Sure, makes sense. Did that.
1c6ca6f to
975eddf
Compare
Member
|
👍 |
Member
|
Thank you @xabbuh. |
fabpot
added a commit
that referenced
this pull request
Feb 18, 2016
…buh) This PR was merged into the 3.1-dev branch. Discussion ---------- [Yaml] support to parse and dump DateTime objects | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6275, #8580, #11838, #14420 | License | MIT | Doc PR | TODO Commits ------- 7e1c6c4 [Yaml] support to parse and dump DateTime objects
7 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.