When I use a datetime_select in my form, Rails will correctly adjust the timezone of the datetime data (as per my config.time_zone
setting), and will render the
As I said in the question, the main problem I had was getting ActiveRecord to apply the existing 'config.time_zone' setting to text_fields.
It turns out that there's a very simple and future-proof way to make that happen: just explicitly add a :value and pull the exact same data--no extra/new methods to call! In my case, that meant:
<%= f.text_field :time_start, :value => f.object.time_start, :class => "datetimefield" %>
This was an intermediary step to another potential solution I was going to try, and I was surprised to find that it worked all on its own (again, working with the 'config.time_zone' I'd already set in 'config/application.rb').
I've tested it, and it applies the proper DST offset when applicable as well (just as one would expect, since 'config.time_zone' is set).
How about converting it with TimeZone#utc_to_local
?
Check out the API docs, http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html