Skip to content

Added support for dates with milliseconds #1063

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

Merged
merged 1 commit into from
Mar 28, 2015
Merged

Added support for dates with milliseconds #1063

merged 1 commit into from
Mar 28, 2015

Conversation

lavoiesl
Copy link
Member

Fixes #1061

Affects #1060 : now will overflow and the loaded date will be in 2036. Note that problem only appears when saving to and loading from Mongo, not when simply converting values.

Duplicate of #1028 (sorry, didn’t see).

Microseconds passed as MongoDate, DateTime, float or DateTime string ('2000-01-01 00:00:00.123') are all handled.

* @param mixed $value \DateTime|\MongoDate|int|float
* @return \DateTime
*/
public static function getDateTime($value)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DateTime conversion is getting too heavy to nice fit in the "closures" and there would be too much code duplication otherwise, hence the public static function. I am open to alternatives.

@lavoiesl
Copy link
Member Author

The Travis issues are related to truncation, I would need to address them.

@lavoiesl
Copy link
Member Author

I decided to remove tests for truncation because Mongo is not consistent across its version.

I could have enforce the truncation in PHP, but it would significantly slow the process and I don’t think it’s worth it, microseconds should not matter to end user anyway since Mongo doesn’t support it.

@lavoiesl
Copy link
Member Author

Travis errors now unrelated, good to merge.

@jwage jwage added this to the 1.0.0-BETA13 milestone Mar 28, 2015
@jwage
Copy link
Member

jwage commented Mar 28, 2015

thumbs_walter

jwage added a commit that referenced this pull request Mar 28, 2015
Added support for dates with milliseconds
@jwage jwage merged commit 8969dc7 into doctrine:master Mar 28, 2015
@lavoiesl lavoiesl deleted the datetype-millisecond branch March 28, 2015 17:29
@Bilge
Copy link
Contributor

Bilge commented Mar 28, 2015

Are you Jesus?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateType should support and preserve millisecond precision
4 participants