@Starker3 opened this Issue on January 13th 2021

When selecting a time period of "Month" and selecting to compare to "Previous period" for some months causes Matomo to compare to the same month.

Have tested and so far it occurs when selecting the 31st of the month for December, October, July, May, March 2020 e.g.:
image

Link where we can see an example: https://demo.matomo.cloud/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday#?idSite=1&period=month&date=2020-12-31&segment=&category=Dashboard_Dashboard&subcategory=1&comparePeriods%5B%5D=month&compareDates%5B%5D=2020-12-01

image

@tsteur commented on January 18th 2021 Member

@Starker3 I think this one might be fixed now? (you'd need to select it again correctly in date picker, not use the URL above)

@Starker3 commented on January 19th 2021

This one is still occurring on demo.matomo.cloud when viewing a "Month" report and selecting the 31st of the month for e.g. December 2020 its comparing with December 2020

@tsteur commented on January 19th 2021 Member

could be maybe fixed with https://github.com/matomo-org/matomo/issues/17095 then

@sgiehl commented on January 25th 2021 Member

@tsteur that actually is another problem. The calculation in javascript simply doesn't return the correct date.
https://github.com/matomo-org/matomo/blob/7cde69f763f2cbf2b9a27c8a7dcf7bcaa950c3bd/plugins/CoreHome/angularjs/common/services/periods.js#L198-L217

When period is month is tries to update the month only. For e.g. 2020-12-31 that would result in 2020-11-31, but as there is no 31th in November it's automatically converted to 2020-12-01.
We could maybe as a solution always set the day to 1 if a period > day is chosen in the date selector?
ping @diosmosis

@flamisz commented on March 2nd 2021 Contributor

Reference from Date.prototype.setMonth()

The current day of month will have an impact on the behavior of this method. Conceptually it will add the number of days given by the current day of the month to the 1st day of the new month specified as the parameter, to return the new date. For example, if the current value is 31st August 2016, calling setMonth with a value of 1 will return 2nd March 2016. This is because in 2016 February had 29 days.

This Issue was closed on March 11th 2021
Powered by GitHub Issue Mirror