summaryrefslogtreecommitdiffstats
path: root/app/helpers
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/helpers
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/helpers')
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/my_helper.rb2
-rw-r--r--app/helpers/settings_helper.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a145a72ac..3e857e3d9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -252,7 +252,7 @@ module ApplicationHelper
def due_date_distance_in_words(date)
if date
- l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
+ l((date < User.current.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(User.current.today, date))
end
end
diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb
index 6a0542234..83cc1e305 100644
--- a/app/helpers/my_helper.rb
+++ b/app/helpers/my_helper.rb
@@ -65,7 +65,7 @@ module MyHelper
def timelog_items
TimeEntry.
- where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today).
+ where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, User.current.today - 6, User.current.today).
joins(:activity, :project).
references(:issue => [:tracker, :status]).
includes(:issue => [:tracker, :status]).
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 43b2c70b0..2c657f0df 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -182,7 +182,7 @@ module SettingsHelper
# Returns the options for the date_format setting
def date_format_setting_options(locale)
Setting::DATE_FORMATS.map do |f|
- today = ::I18n.l(Date.today, :locale => locale, :format => f)
+ today = ::I18n.l(User.current.today, :locale => locale, :format => f)
format = f.gsub('%', '').gsub(/[dmY]/) do
{'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]
end