Patch #22320

Respect user's timezone when comparing / parsing Dates

Added by Jens Krämer over 2 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:I18n
Target version:3.3.0

Description

This patch replaces all occurrences of Date.today with User.current.today.

Date.today always returns the date according to the server's local time zone, leading to all sorts of edge cases that occur more or less often depending on how large the offset between a user's timezone and the server timezone is. A test case illustrating the problem using Issue#overdue? as an example is included.

The patch was extracted from Planio and also includes the changes proposed earlier by Holger Just in #20473, with the addition of two test cases to cover the date manipulation changes in Query#date_clause.

0001-Replace-Date.today-with-User.current.today.patch Magnifier (21.8 KB) Jens Krämer, 2016-03-26 09:14

0002-Fixes-Query-date_clause-timezone-handling.patch Magnifier (3.74 KB) Jens Krämer, 2016-03-26 09:22

0003-simplify-User-today.patch Magnifier (639 Bytes) Jens Krämer, 2016-03-27 06:07


Related issues

Related to Redmine - Defect #16482: Wrong search query for timelog, when timezone not UTC New
Related to Redmine - Defect #23189: Spent time by filter, offset by one day New
Duplicated by Redmine - Patch #20473: Respect the user's timezone when querying issues Closed
Duplicated by Redmine - Defect #19033: Filters that utilize date/time ignore user's UTC offset Closed

Associated revisions

Revision 15379
Added by Jean-Philippe Lang over 2 years ago

Replace Date.today with User.current.today (#22320).

Depending on the offset between a user's configured timezone and the server
timezone, Date.today may be more or less often wrong from the user's
perspective, leading to things like issues marked as overdue too early or too
late, or yesterday / tomorrow being displayed / selected where 'today' is
intended.

A test case illustrating the problem with Issue#overdue? is included

Patch by Jens Kraemer.

Revision 15381
Added by Jean-Philippe Lang over 2 years ago

Fixes Query#date_clause timezone handling (#22320).

When querying time fields based on date values these should be interpreted
in the user's time zone, since that's what a user usually expects.

Patch by Jens Kraemer.

Revision 15383
Added by Jean-Philippe Lang over 2 years ago

Simplify User#today (#22320).

Patch by Jens Kraemer.

Revision 15392
Added by Jean-Philippe Lang over 2 years ago

Test failure with SQLServer (#22320).

Revision 16938
Added by Toshi MARUYAMA about 1 year ago

try IssueTest#test_overdue failing on CI server at Japanese daytime (#22320)

Revision 16951
Added by Toshi MARUYAMA about 1 year ago

Merged r16938 from trunk to 3.4-stable (#22320)

try IssueTest#test_overdue failing on CI server at Japanese daytime.

Revision 16952
Added by Toshi MARUYAMA about 1 year ago

Merged r16938 from trunk to 3.3-stable (#22320)

try IssueTest#test_overdue failing on CI server at Japanese daytime.

History

#1 Updated by Jan from Planio www.plan.io over 2 years ago

  • Target version set to Candidate for next minor release

#2 Updated by Jan from Planio www.plan.io over 2 years ago

  • Duplicated by Patch #20473: Respect the user's timezone when querying issues added

#3 Updated by Jan from Planio www.plan.io over 2 years ago

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

#4 Updated by Jens Krämer over 2 years ago

TimeZone actually has a today method, this patch changes User#today to use it.

#5 Updated by Jan from Planio www.plan.io over 2 years ago

  • Related to Defect #16482: Wrong search query for timelog, when timezone not UTC added

#6 Updated by Toshi MARUYAMA over 2 years ago

  • Target version changed from Candidate for next minor release to 3.3.0

#7 Updated by Jean-Philippe Lang over 2 years ago

  • Category set to I18n
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Committed, thanks.

#8 Updated by Jean-Philippe Lang about 2 years ago

  • Related to Defect #23189: Spent time by filter, offset by one day added

Also available in: Atom PDF