Link to inyourtime.zone in all the sensible places

This commit is contained in:
Michael Ball 2020-07-23 04:16:35 -07:00
parent f86c474002
commit 440ba3511e
4 changed files with 30 additions and 11 deletions

View file

@ -180,9 +180,10 @@ module ApplicationHelper
# TODO:Snap!Con: Replace this with a search for a conference logo.
def nav_root_link_for(conference)
path = conference.present? ? conference_path(conference) : root_path
link_to(
image_tag('snapcon_logo.png'),
root_path,
path,
class: 'navbar-brand',
title: nav_link_text(conference)
)
@ -208,4 +209,15 @@ module ApplicationHelper
object.picture.large.url
end
end
# Embed links with a localized timezone URL
# Timestamps are stored at UTC but in the real timezone.
# We must convert then shift the time back to get the correct value.
def inyourtz(time, timezone = 'GMT', &block)
time = time.in_time_zone(timezone)
time -= time.utc_offset
link_to "https://inyourtime.zone/t?#{time.to_i}", target: '_blank' do
block.call
end
end
end

View file

@ -76,7 +76,9 @@
%dl#proposal-info
.col-md-12
%dt Date:
%dd= @event_schedule.start_time.strftime("%Y %B %e - %H:%M") if @event_schedule
%dd
= inyourtz(@event_schedule.start_time, @conference.timezone) do
= @event_schedule.start_time.strftime("%Y %B %e - %H:%M") if @event_schedule
.col-md-12
%dt Duration:
%dd= show_time(@event.event_type.length)
@ -121,7 +123,9 @@
%dl
%dt Start Time:
%dd
= event.program.selected_event_schedules.find { |es| es.event == event }.start_time.strftime("%Y %B %e %H:%M")
- event_schedule = event.program.selected_event_schedules.find { |es| es.event == event }
= inyourtz(event_schedule.start_time, @conference.timezone) do
= event_schedule.start_time.strftime("%Y %B %e %H:%M")
%br
%dt Room:
%dd

View file

@ -24,12 +24,13 @@
-# TODO: More informative text or aria-label.
= link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400
- if event_schedule.present?
%span.track
%span.fa.fa-clock-o
%span.label{ style: "background-color: grey" }
= event_schedule.start_time.strftime('%H:%M')
\-
= event_schedule.end_time.strftime('%H:%M')
= inyourtz(event_schedule.start_time, @conference.timezone) do
%span.track
%span.fa.fa-clock-o
%span.label{ style: "background-color: grey" }
= event_schedule.start_time.strftime('%H:%M')
\-
= event_schedule.end_time.strftime('%H:%M')
%span.track
%span.fa.fa-map-marker
%span.label{ style: "background-color: grey" }

View file

@ -27,13 +27,15 @@
.col-xs-12.col-md-12
.date-content
%span{ class: 'date-title', id: "#{ event_schedule.start_time.strftime('%Y-%m-%d') }" }
= date = event_schedule.start_time.strftime('%Y-%m-%d')
= inyourtz(event_schedule.start_time, @conference.timezone) do
= date = event_schedule.start_time.strftime('%Y-%m-%d')
%a{ title: "Go up", class: "pull-right", href: "#program" }
%i{ class: "fa fa-angle-double-up fa-lg", 'aria-hidden' => true }
- unless event_schedule.start_time.strftime('%H:%M').eql?(time)
.col-xs-12.col-md-1
.start-time
= time = event_schedule.start_time.strftime('%H:%M')
= inyourtz(event_schedule.start_time, @conference.timezone) do
= time = event_schedule.start_time.strftime('%H:%M')
.col-xs-12.col-md-11
.new-time-event
= render partial: 'event', locals: { event: event_schedule.event, event_schedule: event_schedule }