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

Fix broken conversion of microseconds less than 100000. #1381

Closed

Conversation

jpinner-lyft
Copy link
Contributor

Dates with microsecond values less than 100000 are not correctly converted to PHP objects.

When converting from MongoDate objects, the usec field returns an integer that is concatenated directly to a string formated date in craftDateTime. For example, the value 1.0001 gets split into 1 second and 100 microseconds, which then gets concatenated as "1.100".

When converting numeric values, the sub-seconds are broken into a string which is then padded to six values; however, it is casted to an int first. For example, 1.0001 gets split into a string "0001" which is cast to the integer 1 and padded to "100000", resulting in "1.100000".

In order to properly convert microseconds, they are string padded without converting to an integer.

@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2016

@jpinner-lyft Thanks for this! Since this bug affects current stable releases, do you mind re-opening this PR against the 1.0.x branch for inclusion into the 1.0 release?

@alcaeus alcaeus added the Bug label Mar 9, 2016
@jpinner-lyft
Copy link
Contributor Author

@alcaeus Sure thing! Opened #1382 with the same commit cherry-picked onto the 1.0.x branch.

@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2016

Thanks! I'll close this as the fix will be merged downstream along with 1.0.x.

@alcaeus alcaeus closed this Mar 9, 2016
@jpinner-lyft jpinner-lyft deleted the bugfix-date-time-microseconds branch March 9, 2016 17:24
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.

2 participants