diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-09-20 14:07:52 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-09-20 14:07:52 +0000 |
commit | 6854827f1a1b98a60b6b1e91dd424277d72606db (patch) | |
tree | b03840da4028db1cde91b520c3cc7939d2abf3f5 /app | |
parent | 5452fd2f5a14bf18ef3a66f7fb453912fe1c574b (diff) | |
download | redmine-6854827f1a1b98a60b6b1e91dd424277d72606db.tar.gz redmine-6854827f1a1b98a60b6b1e91dd424277d72606db.zip |
Fixed: Roadmap crashes when a version has a due date > 2037.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1887 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 13 | ||||
-rw-r--r-- | app/views/versions/_overview.rhtml | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cc26127d6..c3701b377 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -100,6 +100,19 @@ module ApplicationHelper @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format) include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) end + + def distance_of_date_in_words(from_date, to_date = 0) + from_date = from_date.to_date if from_date.respond_to?(:to_date) + to_date = to_date.to_date if to_date.respond_to?(:to_date) + distance_in_days = (to_date - from_date).abs + lwr(:actionview_datehelper_time_in_words_day, distance_in_days) + end + + 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)) + end + end # Truncates and returns the string as a single line def truncate_single_line(string, *args) diff --git a/app/views/versions/_overview.rhtml b/app/views/versions/_overview.rhtml index d3aa6b18f..377e9178b 100644 --- a/app/views/versions/_overview.rhtml +++ b/app/views/versions/_overview.rhtml @@ -1,9 +1,7 @@ <% if version.completed? %> <p><%= format_date(version.effective_date) %></p> -<% elsif version.overdue? %> - <p><strong><%= l(:label_roadmap_overdue, distance_of_time_in_words(Time.now, version.effective_date)) %> (<%= format_date(version.effective_date) %>)</strong></p> <% elsif version.effective_date %> - <p><strong><%=l(:label_roadmap_due_in)%> <%= distance_of_time_in_words Time.now, version.effective_date %> (<%= format_date(version.effective_date) %>)</strong></p> + <p><strong><%= due_date_distance_in_words(version.effective_date) %></strong> (<%= format_date(version.effective_date) %>)</p> <% end %> <p><%=h version.description %></p> |