Fixed changeset time inconsistencies
[rails.git] / app / helpers / changeset_helper.rb
1 module ChangesetHelper
2   def changeset_details(changeset)
3     out = ''
4     created_at = distance_of_time_in_words_to_now(changeset.created_at)
5     closed_at = distance_of_time_in_words_to_now(changeset.closed_at)
6     date = ''
7     if changeset.closed_at > DateTime.now
8       date << t('browse.changeset_details.created_at') + ' '
9       date << content_tag(:abbr, t('browse.changeset_details.ago', :ago => created_at), title: l(changeset.created_at))
10     else
11       date << t('browse.changeset_details.closed_at') + ' '
12       both_times = t('browse.changeset_details.created_at') + ': ' + l(changeset.created_at)
13       both_times << '&#10;'
14       both_times << t('browse.changeset_details.closed_at') + ': ' + l(changeset.closed_at)
15       date << content_tag(:abbr, t('browse.changeset_details.ago', :ago => created_at), title: both_times.html_safe)
16     end
17     out << content_tag(:span, date.html_safe, class: 'date')
18     unless params.key?(:display_name)
19       userspan = ''
20       if changeset.user.data_public?
21         userspan << ' ' + t('browse.changeset_details.by') + ' '
22         if changeset.user.data_public?
23           user = link_to changeset.user.display_name, user_path(changeset.user.display_name)
24         else
25           user = t('changeset.changeset.anonymous')
26         end
27         userspan << content_tag(:span, user, class: 'user')
28       end
29       out << content_tag(:span, userspan.html_safe, class: 'user')
30     end
31     return out.html_safe
32   end
33 end