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

Fix timezone issue when using magic date keywords #17144

Merged
merged 3 commits into from Jan 27, 2021
Merged

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Jan 25, 2021

Description:

fixes #17095

Review

  • Functional review done
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Jan 25, 2021
@sgiehl sgiehl added this to the 4.2.0 milestone Jan 25, 2021
core/Period/Factory.php Outdated Show resolved Hide resolved
@sgiehl sgiehl requested a review from diosmosis January 26, 2021 08:23
$date = Date::factory(Date::factory($date)->setTime(date('H:i:s', Date::getNowTimestamp()))->getTimestamp(), $timezone)->getDatetime();
// most magic keywords will automatically set the time to 00:00:00
// we need to set the time manually, so the timezone can be applied correctly
$timestampWithCurrentTime = Date::factory($date)->setTime(date('H:i:s', Date::getNowTimestamp()))->getTimestamp();
Copy link
Member

Choose a reason for hiding this comment

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

Now that I think about it, I think this is what the Date::factoryInTimezone method is meant to achieve. Can you check if this can be used instead? It's meant to retain the time of day before converting to the timezone. If it works, then the code will be simpler and we won't need to do something like this everywhere. Otherwise, feel free to merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good hint. Seems I missed that method for some reason. Using it does the trick as well. At least the tests are still passing.

@diosmosis diosmosis merged commit 43c920c into 4.x-dev Jan 27, 2021
@diosmosis diosmosis deleted the magicdateparams branch January 27, 2021 23:09
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 not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Widget is showing wrong data from yesterday instead of today
2 participants