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

Wrong end of month at Reports for Europe/Berlin time zone if month contains 31 day #15940

Closed
Stepa4man opened this issue Jun 7, 2018 · 4 comments
Labels
Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@Stepa4man
Copy link
Contributor

Stepa4man commented Jun 7, 2018

Preconditions

  1. Set Timezone "Central European Standard Time (Europe/Berlin)" at the STORE->CONFIGURATION->GENERAL->General->Local options-> Timezone and save configuration
  2. Create orders at 31-st day of a month which has this date (May will be used for example)

Steps to reproduce

  1. Go to the Reports adminhtml menu "Products">"Ordered" grid
  2. Select "From" - 01.05.2018
  3. Select "To" - 31.05.2018
  4. Select "Show by" - Month
  5. Hit refresh

Expected result

  1. Orders that were created at 31.05.2018 are in the grid

Actual result

  1. Orders that were created at 31.05.2018 are NOT in the grid

Comment:
MAGE_ROOT/vendor/magento/module-reports/Model/ResourceModel/Report/Collection.php:218
$interval['end'] filled with 30.05.2018 instead of 31.05.2018

My solution:
Replace: $dateStart->format('Y-m-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59')
with:
$dateStart->format('Y-m-' . cal_days_in_month(CAL_GREGORIAN, $dateStart->format('m'), $dateStart->format('Y')) . ' 23:59:59')

System:
Ububntu16.04/MySQL5.7/PHP7.0

@michaelwylde
Copy link
Contributor

If PHP is compiled without calendar support the proposed solution will not work. Another solution would be to replace it with:
$dateStart->format('Y-m-' . date('t', \DateTime::createFromFormat('d-m-Y g:i:s', $dateStart->format('d-m-Y 00:00:00'))->getTimestamp()) . ' 23:59:59')

This will essentially remove the timezone element when getting the UTC timestamp allowing the correct month to be used.

I have created a PR for this: #16492

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jul 5, 2018
@magento-engcom-team
Copy link
Contributor

Hi @Stepa4man. Thank you for your report.
The issue has been fixed in #16492 by @michaelwylde in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@sidolov
Copy link
Contributor

sidolov commented Jul 12, 2018

Hi @Stepa4man. Thank you for your report.
The issue has been fixed in #16585 by @mageprince in 2.1-develop branch
Related commit(s):

The fix will be available with the upcoming 2.1.15 release.

@sidolov sidolov added the Fixed in 2.1.x The issue has been fixed in 2.1 release line label Jul 12, 2018
@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jul 13, 2018
@magento-engcom-team
Copy link
Contributor

Hi @Stepa4man. Thank you for your report.
The issue has been fixed in #16584 by @mageprince in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.6 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

4 participants