Defect #30288

Group name and group count are incorrect when grouping by date (TimeWithZone)

Added by Mizuki ISHIKAWA 4 months ago. Updated 2 months ago.

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


Category:Issues filter
Target version:4.1.0
Resolution: Affected version:


The following problems may occur when grouping by date (TimeWithZone).
  1. group count is not displayed
  2. The displayed created_on and group name date are different
  1. Use PostgreSQL or MySQL
  2. Database time zone is JST (It is not just JST)
  3. User's time zone is unset (User.current.time_zone is nil)

pry(main)> Issue.find(3).created_on
Wed, 19 Jul 2006 19:07:27 UTC +00:00

pry(main)> Issue.find(2).created_on
Wed, 19 Jul 2006 19:04:21 UTC +00:00
pry(main)> Issue.find(2).created_on.localtime.to_date # JST
Thu, 20 Jul 2006

pry(main)> Issue.find(2).created_on.to_date # UTC
Wed, 19 Jul 2006

In environments where the above conditions apply, the test of "IssuesControllerTest#test_index_grouped_by_created_on [test/functional/issues_controller_test.rb:365]" fails.

related: #13803

grouping_issues.png (73.4 KB) Mizuki ISHIKAWA, 2018-12-28 07:21

fix-30288-v1.patch Magnifier (4.15 KB) Mizuki ISHIKAWA, 2019-01-04 07:35

Related issues

Related to Redmine - Feature #13803: Implement grouping issues by date (start, due, creation, ... Reopened


#1 Updated by Go MAEDA 4 months ago

  • Related to Feature #13803: Implement grouping issues by date (start, due, creation, update, closing dates) added

#2 Updated by Marius BALTEANU 4 months ago

  • Description updated (diff)

#3 Updated by Marius BALTEANU 4 months ago

Do you think that it can have any connection with the issue from #16482?

#4 Updated by Mizuki ISHIKAWA 3 months ago

Marius BALTEANU wrote:

Do you think that it can have any connection with the issue from #16482?

I think that this problem is a different problem from #16482.

source:/trunk/app/helpers/queries_helper.rb#L139 returned nil when the test failed.
At that time, result_count_by_group was {Thu, 20 Jul 2006=>2} and group was "Wed, 19 Jul 2006".
Issue 's created_on was converted to different time zones, JST and UTC, so they were on different dates.

I think that time zones when converting time to date should be unified, but the default time zone when changing Redmine's time to date is not unified.
method name time zone source
i18n#format_time localtime (Database time zone) source:/trunk/lib/redmine/i18n.rb#L81
User#time_to_date UTC source:/trunk/app/models/user.rb#L543

I attached a patch with the default timezone of User#time_to_date change to localtime (Database time zone).
In my environment, applying this patch solves the problem.

#5 Updated by Marius BALTEANU 3 months ago

  • Assignee set to Jean-Philippe Lang
  • Target version set to 4.1.0

#6 Updated by Go MAEDA 2 months ago

  • Category set to Issues filter

Also available in: Atom PDF