I’m working with an app for a concert tour website (www.yogabbagabbalive.com), where all times (announcement times, on-sale start times, and event start times) are local to each particular venue’s time zone. I take the user entered date/time where applicable and run a before_filter to set the appropriate time zone so that everything is stored in the database in UTC. For the ‘new’ form and for displaying the times in index and show actions, no problem at all. When the data is brought back out of the database and into a view, I use in_time_zone to adjust per the particular venue.
The only issue is on the edit form. The date/time select is showing the data in UTC. When I’m working on the site, I mentally adjust, but for others it’s confusing. I’d like to do something along the lines of:
<%= f.datetime_select :start_datetime.in_time_zone(@event.time_zone) %>
Or, in the controller:
def edit @performance = Performance.find(params[:id]) @event = @performance.event @performance.start_datetime = @performance.start_datetime.in_time_zone(@event.time_zone) end
<%= f.datetime_select :start_datetime %>.
Unfortunately, I haven’t found the right way to do this. Do you have any ideas worth giving a shot?
Thank you very much.