summaryrefslogtreecommitdiffstats
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/redmine/export/pdf/issues_pdf_helper.rb4
-rw-r--r--lib/redmine/export/pdf/wiki_pdf_helper.rb4
-rw-r--r--lib/redmine/helpers/gantt.rb14
-rw-r--r--lib/redmine/helpers/time_report.rb4
4 files changed, 13 insertions, 13 deletions
diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index a9ee2300d..75f63d272 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -26,7 +26,7 @@ module Redmine
pdf = ITCPDF.new(current_language)
pdf.set_title("#{issue.project} - #{issue.tracker} ##{issue.id}")
pdf.alias_nb_pages
- pdf.footer_date = format_date(Date.today)
+ pdf.footer_date = format_date(User.current.today)
pdf.add_page
pdf.SetFontStyle('B',11)
buf = "#{issue.project} - #{issue.tracker} ##{issue.id}"
@@ -246,7 +246,7 @@ module Redmine
title = "#{project} - #{title}" if project
pdf.set_title(title)
pdf.alias_nb_pages
- pdf.footer_date = format_date(Date.today)
+ pdf.footer_date = format_date(User.current.today)
pdf.set_auto_page_break(false)
pdf.add_page("L")
diff --git a/lib/redmine/export/pdf/wiki_pdf_helper.rb b/lib/redmine/export/pdf/wiki_pdf_helper.rb
index 37dbc1d03..aea7b7e44 100644
--- a/lib/redmine/export/pdf/wiki_pdf_helper.rb
+++ b/lib/redmine/export/pdf/wiki_pdf_helper.rb
@@ -26,7 +26,7 @@ module Redmine
pdf = Redmine::Export::PDF::ITCPDF.new(current_language)
pdf.set_title(project.name)
pdf.alias_nb_pages
- pdf.footer_date = format_date(Date.today)
+ pdf.footer_date = format_date(User.current.today)
pdf.add_page
pdf.SetFontStyle('B',11)
pdf.RDMMultiCell(190,5, project.name)
@@ -43,7 +43,7 @@ module Redmine
pdf = ITCPDF.new(current_language)
pdf.set_title("#{project} - #{page.title}")
pdf.alias_nb_pages
- pdf.footer_date = format_date(Date.today)
+ pdf.footer_date = format_date(User.current.today)
pdf.add_page
pdf.SetFontStyle('B',11)
pdf.RDMMultiCell(190,5,
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb
index af78d9e60..683d201a5 100644
--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -59,8 +59,8 @@ module Redmine
@month_from = 1
end
else
- @month_from ||= Date.today.month
- @year_from ||= Date.today.year
+ @month_from ||= User.current.today.month
+ @year_from ||= User.current.today.year
end
zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
@zoom = (zoom > 0 && zoom < 5) ? zoom : 2
@@ -428,9 +428,9 @@ module Redmine
lines(:image => gc, :top => top, :zoom => zoom,
:subject_width => subject_width, :format => :image)
# today red line
- if Date.today >= @date_from and Date.today <= date_to
+ if User.current.today >= @date_from and User.current.today <= date_to
gc.stroke('red')
- x = (Date.today - @date_from + 1) * zoom + subject_width
+ x = (User.current.today - @date_from + 1) * zoom + subject_width
gc.line(x, headers_height, x, headers_height + g_height - 1)
end
gc.draw(imgl)
@@ -442,7 +442,7 @@ module Redmine
pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
pdf.SetTitle("#{l(:label_gantt)} #{project}")
pdf.alias_nb_pages
- pdf.footer_date = format_date(Date.today)
+ pdf.footer_date = format_date(User.current.today)
pdf.AddPage("L")
pdf.SetFontStyle('B', 12)
pdf.SetX(15)
@@ -592,8 +592,8 @@ module Redmine
coords[:bar_progress_end] = self.date_to - self.date_from + 1
end
end
- if progress_date < Date.today
- late_date = [Date.today, end_date].min
+ if progress_date < User.current.today
+ late_date = [User.current.today, end_date].min
if late_date > self.date_from && late_date > start_date
if late_date < self.date_to
coords[:bar_late_end] = late_date - self.date_from + 1
diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb
index 884d00c68..c9ce70ebe 100644
--- a/lib/redmine/helpers/time_report.rb
+++ b/lib/redmine/helpers/time_report.rb
@@ -70,10 +70,10 @@ module Redmine
end
min = @hours.collect {|row| row['spent_on']}.min
- @from = min ? min.to_date : Date.today
+ @from = min ? min.to_date : User.current.today
max = @hours.collect {|row| row['spent_on']}.max
- @to = max ? max.to_date : Date.today
+ @to = max ? max.to_date : User.current.today
@total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f}