Patch #20473
closedRespect the user's timezone when querying issues
0%
Description
When querying issues and using date-based filters like "today" or "3 days ago" or "last month", Redmine uses the current date according to the server's local time as a reference. This might however not be the day in the user's timezone if they use a different one as the server. These queries can then show unexpected issues that do not match the filter according to the user's timezone.
Furthermore, even if the date is correct, the exact cut-off time still needs to be done in the user's timezone. Suppose the server is set to GMT and the user has configured Europe/Berlin (GMT+2:00 right now) as their time zone. When querying for all issues updated yesterday, the result should include all issues updated between 2015-08-03 02:00:00 GMT and 2015-08-04 01:59:59 GMT. Right now, it would however only include issues updated between 2015-08-03 00:00:00 GMT and 2015-08-03 23:59:59 GMT.
The attached patch against the current trunk fixes both of these issues by applying the following changes to the query model:
- It calculates the cut-of time based on the current user timezone instead of assuming midnight at server-local time
- it uses
User.current.today
instead ofDate.today
to get the correct reference day in the user's timezone
The patch was extracted from Planio.
Files
Related issues
Updated by Toshi MARUYAMA almost 9 years ago
Could you add tests?
https://www.google.com/search?q=rails+stub+timezone
Updated by Sebastian Paluch over 8 years ago
+1
The same issue exists on spent time queries.
Updated by Toshi MARUYAMA over 8 years ago
- Related to Defect #19033: Filters that utilize date/time ignore user's UTC offset added
Updated by Jens Krämer over 8 years ago
In #22320 there's a patch which includes the changes we proposed here, plus some tests and a global replacement of Date.today
with User.current.today
.
Updated by Jan from Planio www.plan.io over 8 years ago
- Status changed from New to Closed
Closing this in favor of #22320, since the patch proposed there includes this one.
Updated by Jan from Planio www.plan.io over 8 years ago
- Is duplicate of Patch #22320: Respect user's timezone when comparing / parsing Dates added