Adding 'v' formatting to DateTime::format(), and adding constant DateTime::RFC3339_EXTENDED#1103
Merged
php-pulls merged 2 commits intophp:masterfrom Feb 23, 2015
Merged
Conversation
…Time::RFC3339_EXTENDED to output datetime using the RFC3339 extended format (aka ISO8601 extended format)
Member
There was a problem hiding this comment.
This should have the PHP bug ID. Not sure why it says RFC?
Contributor
Author
There was a problem hiding this comment.
Left over. Ill fix it
On Feb 20, 2015 11:08 AM, "Derick Rethans" [email protected] wrote:
In ext/date/tests/rfc-datetime_rfc3339_extended.phpt
#1103 (comment):@@ -0,0 +1,17 @@
+--TEST--
+RFC: DateTime RFC3339 ExtendedThis should have the PHP bug ID. Not sure why it says RFC?
—
Reply to this email directly or view it on GitHub
https://github.com/php/php-src/pull/1103/files#r25070967.
Contributor
Author
|
@derickr just renamed the test to match the bug # |
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.
This is an implementation of https://bugs.php.net/bug.php?id=69089
Currently there's no built in format for outputting DateTime using RFC 3339 extended, which is used in several APIs. An output using such format would look like:
2009-09-28T09:45:31.918-03:00
While PHP does have built in support for fraction of seconds in DateTime (provided the DateTime was constructed with it) through its %u format modifier, this modifier cannot be used for RFC 3339 extended as it is a 6 digit version of the fraction. Instead, a new format modifier is needed (proposed %v, because of its proximity with %u) to output the 3-digit version of the fraction. To see the difference, for the fraction 918312 here's what would be output by both modifiers:
%u: 918312
%v: 918
A new constant should be added to DateTime (such as RFC3339_EXTENDED) that would output strings in the RFC 3339 extended format, using this new %v modifier.