From 001853ef7951b866089015a7d22e07c787e541a8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 20 Jun 2019 06:23:48 +0000 Subject: Groups are incorrect when grouping by date without user timezone set. git-svn-id: http://svn.redmine.org/redmine/trunk@18264 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index 933ac7869..096adc4a9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -544,10 +544,14 @@ class User < Principal # Returns the day of +time+ according to user's time zone def time_to_date(time) - if time_zone.nil? - time.to_date + self.convert_time_to_user_timezone(time).to_date + end + + def convert_time_to_user_timezone(time) + if self.time_zone + time.in_time_zone(self.time_zone) else - time.in_time_zone(time_zone).to_date + time.utc? ? time.localtime : time end end -- cgit v1.2.3