* VRFS-1917 - timezone set correctly
This commit is contained in:
parent
2923969e94
commit
471a0d13a0
|
|
@ -441,24 +441,16 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def get_timezone
|
||||
tz = nil
|
||||
if timezone.blank?
|
||||
tz = ActiveSupport::TimeZone["Central Time (US & Canada)"]
|
||||
self.timezone = tz.name + ',' + tz.tzinfo.name
|
||||
else
|
||||
tz = ActiveSupport::TimeZone[self.timezone.split(',')[0]]
|
||||
end
|
||||
|
||||
tz
|
||||
end
|
||||
|
||||
def scheduled_end_time
|
||||
|
||||
end
|
||||
|
||||
def timezone_id
|
||||
MusicSession.split_timezone(timezone)[0]
|
||||
end
|
||||
|
||||
def timezone_description
|
||||
self.get_timezone.to_s
|
||||
MusicSession.split_timezone(timezone)[1]
|
||||
end
|
||||
|
||||
def musician_access_description
|
||||
|
|
@ -720,28 +712,23 @@ module JamRuby
|
|||
|
||||
result = scheduled_start
|
||||
|
||||
if timezone_param
|
||||
index = timezone_param.rindex(',')
|
||||
if index
|
||||
tz_identifier = timezone_param[(index + 1)..-1]
|
||||
begin
|
||||
timezone = ActiveSupport::TimeZone.new(tz_identifier)
|
||||
rescue Exception => e
|
||||
@@log.error("unable to find timezone=#{tz_identifier}, e=#{e}")
|
||||
end
|
||||
tz_identifier = split_timezone(timezone_param)[0]
|
||||
begin
|
||||
timezone = ActiveSupport::TimeZone.new(tz_identifier)
|
||||
rescue Exception => e
|
||||
@@log.error("unable to find timezone=#{tz_identifier}, e=#{e}")
|
||||
end
|
||||
|
||||
if timezone
|
||||
begin
|
||||
# first convert the time provided, and convert to the specified timezone (local_to_utc)
|
||||
# then, convert that to the system timezone, under the ASSUMPTION that the database is configured to use the system timezone
|
||||
# you can get into trouble if your dev database is not using the system timezone of the web machine
|
||||
if timezone
|
||||
begin
|
||||
# first convert the time provided, and convert to the specified timezone (local_to_utc)
|
||||
# then, convert that to the system timezone, under the ASSUMPTION that the database is configured to use the system timezone
|
||||
# you can get into trouble if your dev database is not using the system timezone of the web machine
|
||||
|
||||
result = timezone.parse(scheduled_start)
|
||||
rescue Exception => e
|
||||
@@log.error("unable to convert #{scheduled_start} to #{timezone}, e=#{e}")
|
||||
puts "unable to convert #{scheduled_start} to #{timezone}, e=#{e}"
|
||||
end
|
||||
end
|
||||
result = timezone.parse(scheduled_start)
|
||||
rescue Exception => e
|
||||
@@log.error("unable to convert #{scheduled_start} to #{timezone}, e=#{e}")
|
||||
puts "unable to convert #{scheduled_start} to #{timezone}, e=#{e}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -756,6 +743,19 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
# takes our stored timezone which is DISPLAY,ID and returns an array of the two values (id first, then description)
|
||||
def self.split_timezone(tz)
|
||||
result = [nil, nil]
|
||||
if tz
|
||||
index = tz.rindex(',')
|
||||
if index
|
||||
tz_display = tz[0, index]
|
||||
tz_identifier = tz[(index + 1)..-1]
|
||||
result = [tz_identifier, tz_display]
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
# should create a timestamp like:
|
||||
#
|
||||
# with_timezone = TRUE
|
||||
|
|
@ -765,29 +765,26 @@ module JamRuby
|
|||
# Thursday, July 10 - 10:00pm
|
||||
# this should be in a helper
|
||||
def pretty_scheduled_start(with_timezone)
|
||||
if scheduled_start &&
|
||||
if scheduled_start && scheduled_duration
|
||||
start_time = scheduled_start
|
||||
timezone_display = 'UTC'
|
||||
index = timezone.rindex(',')
|
||||
if index
|
||||
tz_display = timezone[0, index]
|
||||
tz_identifier = timezone[(index + 1)..-1]
|
||||
begin
|
||||
tz = TZInfo::Timezone.get(tz_identifier)
|
||||
rescue Exception => e
|
||||
@@log.error("unable to find timezone=#{tz_identifier}, e=#{e}")
|
||||
end
|
||||
tz_identifier, tz_display = MusicSession.split_timezone(timezone)
|
||||
begin
|
||||
tz = TZInfo::Timezone.get(tz_identifier)
|
||||
rescue Exception => e
|
||||
@@log.error("unable to find timezone=#{tz_identifier}, e=#{e}")
|
||||
end
|
||||
|
||||
if tz
|
||||
begin
|
||||
start_time = tz.utc_to_local(scheduled_start.utc)
|
||||
timezone_display = tz_display
|
||||
rescue Exception => e
|
||||
@@log.error("unable to convert #{scheduled_start} to #{tz}, e=#{e}")
|
||||
puts "unable to convert #{e}"
|
||||
end
|
||||
if tz
|
||||
begin
|
||||
start_time = tz.utc_to_local(scheduled_start.utc)
|
||||
timezone_display = tz_display
|
||||
rescue Exception => e
|
||||
@@log.error("unable to convert #{scheduled_start} to #{tz}, e=#{e}")
|
||||
puts "unable to convert #{e}"
|
||||
end
|
||||
end
|
||||
|
||||
duration = scheduled_duration
|
||||
# you can put seconds into the scheduled_duration field, but once stored, it comes back out as a string
|
||||
if scheduled_duration.class == String
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ else
|
|||
|
||||
attributes :id, :music_session_id, :name, :description, :musician_access, :approval_required, :fan_access, :fan_chat,
|
||||
:band_id, :user_id, :genre_id, :created_at, :like_count, :comment_count, :play_count, :scheduled_duration,
|
||||
:language, :recurring_mode, :language_description, :scheduled_start_time, :access_description, :timezone, :timezone_description,
|
||||
:language, :recurring_mode, :language_description, :scheduled_start_time, :access_description, :timezone, :timezone_id, :timezone_description,
|
||||
:musician_access_description, :fan_access_description, :session_removed_at, :legal_policy, :open_rsvps, :is_unstructured_rsvp?
|
||||
|
||||
node :share_url do |history|
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
.right-column
|
||||
%select#timezone-prop-list{style: "width: 100%"}
|
||||
- ActiveSupport::TimeZone.zones_map.each do |name, tz|
|
||||
%option.label{value: "#{name}, #{tz.tzinfo.name}"} #{tz.to_s}
|
||||
%option.label{value: "#{name},#{tz.tzinfo.name}"} #{tz.to_s}
|
||||
.clearall.left-column
|
||||
Recurring:
|
||||
.right-column
|
||||
|
|
|
|||
Loading…
Reference in New Issue