From 4bf08111363f42fb1ba90be5f80a99083044a888 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Sun, 17 Jan 2021 14:48:51 -0500 Subject: [PATCH] Times are now rendered using the browsers time zone (#2438) --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/assets/javascripts/application.js | 1 + app/helpers/admins_helper.rb | 7 ------- app/helpers/application_helper.rb | 6 ++++++ app/helpers/recordings_helper.rb | 5 ----- app/views/admins/components/_invited_users_table.html.erb | 2 +- app/views/admins/components/_manage_users_table.html.erb | 2 +- app/views/admins/components/_server_recording_row.html.erb | 2 +- app/views/admins/components/_server_room_row.html.erb | 6 +++--- app/views/rooms/components/_room_block.html.erb | 2 +- app/views/shared/components/_public_recording_row.html.erb | 2 +- app/views/shared/components/_recording_row.html.erb | 2 +- spec/helpers/recordings_helper_spec.rb | 7 ------- 14 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index eb85a08a..1fe7ac8c 100644 --- a/Gemfile +++ b/Gemfile @@ -83,6 +83,8 @@ gem 'google-cloud-storage', '~> 1.26' gem 'pluck_to_hash', '~> 1.0.2' +gem 'local_time', '~> 2.1.0' + group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' diff --git a/Gemfile.lock b/Gemfile.lock index 7c95ffa7..d0c5d412 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,6 +202,7 @@ GEM listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) + local_time (2.1.0) lograge (0.11.2) actionpack (>= 4) activesupport (>= 4) @@ -479,6 +480,7 @@ DEPENDENCIES jquery-rails (~> 4.4) jquery-ui-rails listen (~> 3.0.5) + local_time (~> 2.1.0) lograge net-ldap omniauth diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 72c83bb7..dd678843 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -35,4 +35,5 @@ //= require jquery-ui/widgets/sortable //= require pickr.min.js //= require bootstrap-select.min.js +//= require local-time //= require_tree . diff --git a/app/helpers/admins_helper.rb b/app/helpers/admins_helper.rb index b3058ce0..91f3a2e7 100644 --- a/app/helpers/admins_helper.rb +++ b/app/helpers/admins_helper.rb @@ -31,13 +31,6 @@ module AdminsHelper @running_room_bbb_ids.include?(id) end - # Returns a more friendly/readable date time object - def friendly_time(date) - return "" if date.nil? # Handle invalid dates - - I18n.l date, format: "%B %d, %Y %H:%M UTC" - end - # Site Settings def admin_invite_registration diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 61abfded..cbbc8637 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -135,4 +135,10 @@ module ApplicationHelper def show_signin !@hide_signin.present? end + + # Returns a more friendly/readable date time object + def view_date(date) + return "" if date.nil? # Handle invalid dates + local_time(date) + end end diff --git a/app/helpers/recordings_helper.rb b/app/helpers/recordings_helper.rb index 2cc2dc82..30784485 100644 --- a/app/helpers/recordings_helper.rb +++ b/app/helpers/recordings_helper.rb @@ -17,11 +17,6 @@ # with BigBlueButton; if not, see . module RecordingsHelper - # Helper for converting BigBlueButton dates into the desired format. - def recording_date(date) - I18n.l date, format: "%B %d, %Y" - end - # Helper for converting BigBlueButton dates into a nice length string. def recording_length(playbacks) # Looping through playbacks array and returning first non-zero length value diff --git a/app/views/admins/components/_invited_users_table.html.erb b/app/views/admins/components/_invited_users_table.html.erb index dc0b2671..bb2ecd32 100644 --- a/app/views/admins/components/_invited_users_table.html.erb +++ b/app/views/admins/components/_invited_users_table.html.erb @@ -24,7 +24,7 @@
<%= user.email %>
-
<%= friendly_time(user.updated_at) %>
+
<%= view_date(user.updated_at) %>
diff --git a/app/views/admins/components/_manage_users_table.html.erb b/app/views/admins/components/_manage_users_table.html.erb index 1fbfc3ca..77947c78 100644 --- a/app/views/admins/components/_manage_users_table.html.erb +++ b/app/views/admins/components/_manage_users_table.html.erb @@ -48,7 +48,7 @@
<%= user.name %>
-
<%= [t("administrator.users.table.created"), ": ", user.created_at].join %>
+
<%= [t("administrator.users.table.created"), ": ", view_date(user.created_at)].join.html_safe %>
<%= user.email && user.email != "" ? user.email : user.username%> <%= user.provider %> diff --git a/app/views/admins/components/_server_recording_row.html.erb b/app/views/admins/components/_server_recording_row.html.erb index 47632ce1..5f82cfbf 100644 --- a/app/views/admins/components/_server_recording_row.html.erb +++ b/app/views/admins/components/_server_recording_row.html.erb @@ -26,7 +26,7 @@
- <%= t("recording.recorded_on", date: recording_date(recording[:startTime])) %> + <%= t("recording.recorded_on", date: view_date(recording[:startTime])).html_safe %>
<%= recording_owner_email(recording[:meetingID]) %> diff --git a/app/views/admins/components/_server_room_row.html.erb b/app/views/admins/components/_server_room_row.html.erb index 6aece4c8..683313c1 100644 --- a/app/views/admins/components/_server_room_row.html.erb +++ b/app/views/admins/components/_server_room_row.html.erb @@ -26,11 +26,11 @@
<% running = room_is_running(room.bbb_id) %> <% if running %> - <%= t("administrator.rooms.table.started", session: friendly_time(room.last_session)) %> + <%= t("administrator.rooms.table.started", session: view_date(room.last_session)).html_safe %> <% elsif room.last_session.present? %> - <%= t("administrator.rooms.table.ended", session: friendly_time(room.last_session)) %> + <%= t("administrator.rooms.table.ended", session: view_date(room.last_session)).html_safe %> <% else %> - <%= [t("administrator.users.table.created"), ": ", friendly_time(room.created_at)].join %> + <%= [t("administrator.users.table.created"), ": ", view_date(room.created_at)].join.html_safe %> <% end %>
diff --git a/app/views/rooms/components/_room_block.html.erb b/app/views/rooms/components/_room_block.html.erb index 7e140585..3de5fcad 100644 --- a/app/views/rooms/components/_room_block.html.erb +++ b/app/views/rooms/components/_room_block.html.erb @@ -35,7 +35,7 @@
<% if room.sessions > 0 %> - <%= t("room.last_session", session: recording_date(room.last_session)) %> + <%= t("room.last_session", session: view_date(room.last_session)).html_safe %> <% else %> <%= t("room.no_sessions") %> <% end %> diff --git a/app/views/shared/components/_public_recording_row.html.erb b/app/views/shared/components/_public_recording_row.html.erb index 1966cb92..1daa2f28 100644 --- a/app/views/shared/components/_public_recording_row.html.erb +++ b/app/views/shared/components/_public_recording_row.html.erb @@ -26,7 +26,7 @@
- <%= t("recording.recorded_on", date: recording_date(recording[:startTime])) %> + <%= t("recording.recorded_on", date: view_date(recording[:startTime])).html_safe %>
<% if recording_thumbnails? %> diff --git a/app/views/shared/components/_recording_row.html.erb b/app/views/shared/components/_recording_row.html.erb index 986b87a4..9efe062a 100644 --- a/app/views/shared/components/_recording_row.html.erb +++ b/app/views/shared/components/_recording_row.html.erb @@ -27,7 +27,7 @@
- <%= t("recording.recorded_on", date: recording_date(recording[:startTime])) %> + <%= t("recording.recorded_on", date: view_date(recording[:startTime])).html_safe %>
<% if recording_thumbnails? %> diff --git a/spec/helpers/recordings_helper_spec.rb b/spec/helpers/recordings_helper_spec.rb index ac8690c8..5a8f343f 100644 --- a/spec/helpers/recordings_helper_spec.rb +++ b/spec/helpers/recordings_helper_spec.rb @@ -19,13 +19,6 @@ require "rails_helper" describe RecordingsHelper do - describe "#recording_date" do - it "formats the date" do - date = DateTime.parse("2019-03-28 19:35:15 UTC") - expect(helper.recording_date(date)).to eql("March 28, 2019") - end - end - describe "#recording_length" do it "returns the time if length > 60" do playbacks = [{ type: "test", length: 85 }]