From fdae557a99cdb260c1ef27084a27333e0afc6b0d Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Wed, 25 May 2022 20:20:09 -0700 Subject: [PATCH] display: correctly show the time zone abbreviation --- app/helpers/application_helper.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bc74291b..67bbaad1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -154,8 +154,19 @@ def hugo_nom_deadline_long_form $nomination_closed_at.strftime("%H:%M %p, Pacific Daylight Time (PDT, UTC-7) on %B %d, %Y") end + def human_timezone(time_string, timezone) + time = time_string.in_time_zone(timezone) + + if time.zone.match?(/^\w/) + time.zone + else + time.formatted_offset + end + end + def hugo_vote_deadline - $hugo_closed_at.strftime("%A %-d %B %Y, %H:%M %p %Z") + time_zone = human_timezone($hugo_closed_at.to_s, "Pacific Time (US & Canada)") + $hugo_closed_at.strftime("%A %-d %B %Y, %H:%M %p #{time_zone}") end def hugo_ballot_pub_month