Patch #20473

Respect the user's timezone when querying issues

Added by Holger Just about 2 years ago. Updated over 1 year ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Issues
Target version:-

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 of Date.today to get the correct reference day in the user's timezone

The patch was extracted from Planio.

0001-Use-dates-according-to-the-user-s-timezone-in-querie.patch Magnifier (3.87 KB) Holger Just, 2015-08-04 18:51


Related issues

Related to Redmine - Defect #19033: Filters that utilize date/time ignore user's UTC offset Closed
Duplicates Redmine - Patch #22320: Respect user's timezone when comparing / parsing Dates Closed

History

#2 Updated by Sebastian Paluch over 1 year ago

+1

The same issue exists on spent time queries.

#3 Updated by Toshi MARUYAMA over 1 year ago

  • Related to Defect #19033: Filters that utilize date/time ignore user's UTC offset added

#4 Updated by Jens Krämer over 1 year 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.

#5 Updated by Jan from Planio www.plan.io over 1 year ago

  • Status changed from New to Closed

Closing this in favor of #22320, since the patch proposed there includes this one.

#6 Updated by Jan from Planio www.plan.io over 1 year ago

  • Duplicates Patch #22320: Respect user's timezone when comparing / parsing Dates added

Also available in: Atom PDF