Skip to content

Convert whereBetween values to UTCDateTime #953

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

Closed
wants to merge 4 commits into from

Conversation

ricardofontanelli
Copy link

Added a protected method (dateTimeConvertion) to convert DateTime objects to MongoDB\BSON\UTCDateTime and added a verification for DateTime objects in $where['values'] array to ensure that all DateTime values will be properly converted to MongoDB\BSON\UTCDateTime.

Added a protected method (dateTimeConvertion) to convert DateTime objects to MongoDB\BSON\UTCDateTime and added a verification for DateTime objects in $where['values'] array to ensure that all DateTime values will be properly converted to MongoDB\BSON\UTCDateTime.
Added a protected method (dateTimeConvertion) to convert DateTime objects to MongoDB\BSON\UTCDateTime and added a verification for DateTime objects in $where['values'] array to ensure that all DateTime values will be properly converted to MongoDB\BSON\UTCDateTime.
Assert if a MongoDB\BSON\UTCDateTime is created if you set a DateTime object as whereBetween parameter
CHANGE white space
protected function dateTimeConvertion($value)
{
if ($value instanceof DateTime) {
return new UTCDateTime($value->getTimestamp() * 1000);

Choose a reason for hiding this comment

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

Why UTCDateTime instead UTCDatetime?

Copy link
Author

Choose a reason for hiding this comment

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

According PHP documentation, the class name is UTCDateTime

Choose a reason for hiding this comment

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

Isn't the if conditional check redundant? You are already checking if the value is an instance of DateTime before calling the dateTimeConversion function.

@victor-yon
Copy link

This issue isn't fixed yet ?

@ricardofontanelli
Copy link
Author

It was merged at moloquent/moloquent, I don't know why nobody has merged this PR here!

@D-02022020
Copy link

already fixed by #1328

@divine
Copy link
Contributor

divine commented Jan 20, 2020

already fixed by #1328

Then this PR should be closed.

@Smolevich Smolevich closed this Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants