On 25 Mar 2011, at 04:27, Seth Willits <lists@ruby-forum. > > > ...except that doing this, Rails interprets the datetime the user > entered in my configured default time zone (UTC). Instead, I need to use > the time zone the user specified. So after failing to find any good way > to do this, it seems to me, the shortest way to do this is: > How about setting Time.zone to whatever the user supplies before updating your event object?
Fred > > def method > @event = Event.find(params[:id]) > > zone = ActiveSupport::TimeZone.new(params[:time_zone]) > yr = params[:event][:"start(1i)"].to_i > mon = params[:event][:"start(2i)"].to_i > day = params[:event][:"start(3i)"].to_i > hr = params[:event][:"start(4i)"].to_i > min = params[:event][:"start(5i)"].to_i > sec = 0 > off = zone.utc_offset / 86400.0 > > @event.attributes = params[:event] > @event.start = DateTime.civil(yr, mon, day, hr, min, sec, off) > > if @event.save > yay > end > end > > > > I can obviously make a separate method to factor out creating a date > with the given time zone, but there has to be a better way overall of > doing this. > > Any suggestions? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

