From 198b6db507c8dc3106c0f9075500b8887bdfefd1 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 12 Apr 2017 22:48:09 -0500 Subject: [PATCH] /bans: replace Expires column with Duration. --- app/helpers/application_helper.rb | 8 ++++++++ app/views/bans/index.html.erb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2283393a0..379c46a38 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -81,6 +81,14 @@ module ApplicationHelper content_tag(:time, content || datetime, :datetime => datetime, :title => time.to_formatted_s) end + def humanized_duration(from, to) + duration = distance_of_time_in_words(from, to) + datetime = from.iso8601 + "/" + to.iso8601 + title = "#{from.strftime("%Y-%m-%d %H:%M")} to #{to.strftime("%Y-%m-%d %H:%M")}" + + raw content_tag(:time, duration, datetime: datetime, title: title) + end + def time_ago_in_words_tagged(time) raw time_tag(time_ago_in_words(time) + " ago", time) end diff --git a/app/views/bans/index.html.erb b/app/views/bans/index.html.erb index 3c5f981c8..89139c237 100644 --- a/app/views/bans/index.html.erb +++ b/app/views/bans/index.html.erb @@ -8,7 +8,7 @@ User Banner Banned - Expires + Duration Reason @@ -19,7 +19,7 @@ <%= link_to_user(ban.user) %> <%= link_to_user(ban.banner) %> <%= time_ago_in_words_tagged(ban.created_at) %> - <%= ban.expires_at %> + <%= humanized_duration(ban.created_at, ban.expires_at) %> <%= format_text ban.reason, :ragel => true %> <% if CurrentUser.is_moderator? %>