Skip to content

Display selected timezone on user's profile

In #15137 (closed) we added a timezone dropdown when editing your profile. The timezone is not yet displayed anywhere yet. We should display the timezone on the user's profile.

Before After
Screen_Shot_2021-07-07_at_2.34.34_PM Screen_Shot_2021-07-07_at_2.39.54_PM

Implementation plan

  1. Create a local_time helper in app/helpers/time_zone_helper.rb
def local_time(timezone)
  time_with_zone_instance = ActiveSupport::TimeZone.new(timezone).now
  offset = time_with_zone_instance.utc_offset
  formatted_offset = offset / 3600

  time_with_zone_instance.strftime("%H:%M (UTC#{formatted_offset})")
end
  1. Use that helper in app/views/users/show.html.haml#L75
  2. Add a feature spec in spec/features/users/show_spec.rb