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

Always set hours to 0 for periods.getToday #13373

merged 1 commit into from Aug 31, 2018

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Aug 31, 2018

fixes #13369

@sgiehl sgiehl added the Needs Review PRs that need a code review label Aug 31, 2018
@sgiehl sgiehl added this to the 3.7.0 milestone Aug 31, 2018
@@ -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!

@diosmosis diosmosis merged commit 63e2726 into 3.x-dev Aug 31, 2018
@diosmosis diosmosis deleted the fixjstoday branch August 31, 2018 23:14
@mattab mattab modified the milestones: 3.7.0, 3.6.1 Sep 1, 2018
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.6.0 period=day&date=today no longer highlights current date
3 participants