summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-05-07 10:42:22 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-05-07 10:42:22 +0000
commited50d42210eaf7ca216e9cd3a043b36aa68eb51d (patch)
treefbc801683ee622f43e790ec6cf2785fd8f94a43c /app/controllers
parent40c9c3e922e15ab7d88b5d06c60e51ed1ba40a7f (diff)
downloadredmine-ed50d42210eaf7ca216e9cd3a043b36aa68eb51d.tar.gz
redmine-ed50d42210eaf7ca216e9cd3a043b36aa68eb51d.zip
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. git-svn-id: http://svn.redmine.org/redmine/trunk@15379 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/activities_controller.rb2
-rw-r--r--app/controllers/calendars_controller.rb4
-rw-r--r--app/controllers/issues_controller.rb2
-rw-r--r--app/controllers/repositories_controller.rb5
4 files changed, 7 insertions, 6 deletions
diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb
index ce3f600ae..32df00f97 100644
--- a/app/controllers/activities_controller.rb
+++ b/app/controllers/activities_controller.rb
@@ -27,7 +27,7 @@ class ActivitiesController < ApplicationController
begin; @date_to = params[:from].to_date + 1; rescue; end
end
- @date_to ||= Date.today + 1
+ @date_to ||= User.current.today + 1
@date_from = @date_to - @days
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
if params[:user_id].present?
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index 756d62b44..276d7988d 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -35,8 +35,8 @@ class CalendarsController < ApplicationController
@month = params[:month].to_i
end
end
- @year ||= Date.today.year
- @month ||= Date.today.month
+ @year ||= User.current.today.year
+ @month ||= User.current.today.month
@calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
retrieve_query
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 21b810c8c..7c10769aa 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -441,7 +441,7 @@ class IssuesController < ApplicationController
@issue.project ||= @issue.allowed_target_projects.first
end
@issue.author ||= User.current
- @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
+ @issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
attrs = (params[:issue] || {}).deep_dup
if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 734b43983..8f34c0034 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -352,7 +352,7 @@ class RepositoriesController < ApplicationController
end
def graph_commits_per_month(repository)
- @date_to = Date.today
+ @date_to = User.current.today
@date_from = @date_to << 11
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
commits_by_day = Changeset.
@@ -371,7 +371,8 @@ class RepositoriesController < ApplicationController
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
fields = []
- 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
+ today = User.current.today
+ 12.times {|m| fields << month_name(((today.month - 1 - m) % 12) + 1)}
graph = SVG::Graph::Bar.new(
:height => 300,