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

Always set hours to 0 for periods.getToday #13373

Merged
merged 1 commit into from Aug 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/CoreHome/angularjs/common/services/periods.js
Expand Up @@ -348,7 +348,8 @@
// apply piwik site timezone (if it exists)
date.setHours((piwik.timezoneOffset || 0) / 3600);

// get rid of minutes/seconds/etc.
// get rid of hours/minutes/seconds/etc.
date.setHours(0);
Copy link
Member Author

Choose a reason for hiding this comment

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

By default all dates returned for a single day have the time set to 0. But for today the timezone adjustments may end up on the day (before or after) at a specific hour. The current day isn't highlighted for today later, as comparing doesn't match (https://github.com/matomo-org/matomo/blob/3.x-dev/plugins/CoreHome/angularjs/date-picker/date-picker.directive.js#L312-L313) Setting the hour to 0 always should fix that

Copy link
Member

Choose a reason for hiding this comment

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

This undoes the setHours() call above, maybe it can be removed? I added it to match the way periods were created server side, but I suppose client side it's just about selecting dates not determining when its needed to aggregate from...

Copy link
Member Author

@sgiehl sgiehl Aug 31, 2018

Choose a reason for hiding this comment

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

Actually it does not really "undo" the setHours. If the timezone offset is negativ the first setHours might move the date to the day before and the setHours(0) will then set the hours to 0 on that day. eg:
image

Copy link
Member

Choose a reason for hiding this comment

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

Oh I understand now. Looks good, will merge!

date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
Expand Down