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

[Yaml] support to parse and dump DateTime objects #17836

Merged
merged 1 commit into from Feb 18, 2016

Conversation

Projects
None yet
5 participants
@xabbuh
Copy link
Member

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
* Added support for parsing timestamps as `\DateTime` objects:

```php
Yaml::parse('2001-12-15 21:59:43.10 -5', Yaml::Parse_DATETIME);

This comment has been minimized.

Copy link
@mpajunen

mpajunen Feb 17, 2016

Contributor

Should be capitalized: Yaml::PARSE_DATETIME.

This comment has been minimized.

Copy link
@xabbuh

xabbuh Feb 17, 2016

Author Member

Good catch. :) Thanks!

@xabbuh xabbuh force-pushed the xabbuh:issue-11838 branch 2 times, most recently from dbd6af3 to fabf9ae Feb 17, 2016

@@ -568,8 +574,15 @@ private static function evaluateScalar($scalar, $references = array())
return log(0);
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'));

This comment has been minimized.

Copy link
@fabpot

fabpot Feb 18, 2016

Member

Can we move this into the next case to avoid matching twice?

This comment has been minimized.

Copy link
@xabbuh

xabbuh Feb 18, 2016

Author Member

Sure, makes sense. Did that.

@xabbuh xabbuh force-pushed the xabbuh:issue-11838 branch 2 times, most recently from 1c6ca6f to 975eddf Feb 18, 2016

@xabbuh xabbuh force-pushed the xabbuh:issue-11838 branch from 975eddf to 7e1c6c4 Feb 18, 2016

@stof

This comment has been minimized.

Copy link
Member

commented Feb 18, 2016

👍

@fabpot

This comment has been minimized.

Copy link
Member

commented Feb 18, 2016

Thank you @xabbuh.

@fabpot fabpot merged commit 7e1c6c4 into symfony:master Feb 18, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Feb 18, 2016

feature #17836 [Yaml] support to parse and dump DateTime objects (xab…
…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

@xabbuh xabbuh deleted the xabbuh:issue-11838 branch Feb 18, 2016

@xabbuh xabbuh referenced this pull request Mar 1, 2016

Closed

YAML dumper flags #6226

7 of 7 tasks complete

@fabpot fabpot referenced this pull request May 13, 2016

Merged

Release v3.1.0-BETA1 #18776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.