title: Troubled by Timezones in Rails
body: <p>I have an application which uses the following config:</p>
  
  <pre><code>Rails.application.configure do
    # Settings specified here will take precedence over those in config/application.rb.
    config.time_zone = 'Amsterdam'
    config.active_record.default_timezone = :utc
  end
  </code></pre>
  
  <p>I'm offering the user a form that asks for a separate date (datepicker) and time field (drop down). On the before method I'm concatenating the date &amp; time into a single datetime field. It seems though that the Time object is somehow in UTC, while the Date object doesn't care about that.</p>
  
  <p>When storing this into the database, somehow the timezone gets corrected, but the time is 2 hours off. Is this due to the fact that the time is still in UTC? How can I compensate for that in a way also daylight savings is respected?</p>
  
  <p><strong>Code sample</strong></p>
  
  <p>The form:</p>
  
  <pre><code>= simple_form_for @report do |f|
    .row
      .col.s6
        = f.association :report_category
      .col.s6
        = f.association :account
    .row
      .col.s6.l4
        = f.input :day, as: :string, input_html: {class: 'datepicker current-date'}
      .col.s6.l4
        = f.input :time, as: :string, input_html: {class: 'timepicker current-date'}
  </code></pre>
  
  <p>The callback in the model</p>
  
  <pre><code>  def create_timestamp
      self.date = day.to_datetime + time.seconds_since_midnight.seconds
    end
  </code></pre>
  
  <p>After saving, there's a 2 hour difference between de time I've chosen in the form.</p>
  
  <p>This is how it looks like after creating a new record where time is just the same time as the record was created, to see the difference:</p>
  
  <pre><code> date: Sat, 20 May 2017 16:10:00 CEST +02:00,
   created_at: Sat, 20 May 2017 14:10:33 CEST +02:00,
   updated_at: Sat, 20 May 2017 14:10:33 CEST +02:00,
   deleted_at: nil,
   time: 2000-01-01 14:10:00 UTC,
   day: Sat, 20 May 2017,
  </code></pre>
  
  <p>As you van see, the time is stored in UTC, while it is actually 14:10 CET +0200 where I created the record. So that could be causing the discrepancy. Which you can see in date, where the time is +2 hours from the created_at.</p>
  
  <p>Thanks</p>