-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Conversation
DateTime::ISO8601 doesn't properly handle fractions of a second. This patch fixes that problem.
$format = 'Y-m-d\TH:i:s.uO'; | ||
} else { | ||
$format = DateTime::ISO8601; | ||
} |
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.
I'd change the logic to this:
$format = DateTime::ISO8601;
if ($dateCreated[19] === '.') {
$format = 'Y-m-d\TH:i:s.uO';
}
This eliminates the else
condition, which is the default and expected condition.
@dkidd Could you add a test for this, by any chance? |
Added logic to detect and properly handle ISO8601 date strings that contain fractions of a second.
@weierophinney I'd be happy to write tests for getDateCreated() and getDateModified(). |
@@ -203,7 +207,11 @@ public function getDateModified() | |||
} | |||
|
|||
if ($dateModified) { | |||
$date = DateTime::createFromFormat(DateTime::ISO8601, $dateModified); | |||
$format = DateTime::ISO8601; | |||
if ($dateCreated[19] === '.') { |
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.
should be dateModified :)
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.
Eep!
@weierophinney See my latest commit for a proposed solution to this issue. I figured that, since |
…eTime::createFromISO8601, updated documentation
Does anyone know why the Travis build keeps failing? |
@dkidd (trailing_spaces, braces, eof_ending) run your code through php-cs-fixer |
@@ -0,0 +1 @@ |
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.
This file should not be included in the Git history
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.
Indeed. Very annoying. I'm not sure of the best way to remove it, though. Suggestions?
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.
Nevermind. Figured it out. Thanks for the suggestion.
Thank you |
…tfix/iso8601-factrion-of-seconds'
…tfix/iso8601-factrion-of-seconds'
DateTime::ISO8601 doesn't properly handle fractions of a second. This patch fixes that problem.