title: Monkey-patching the Time class in Rails leads to time zone confusion
body: <p>I've got a Rails 3.2.6 app running on Ruby 1.8.7. The app is configured to use central European time (i.e. UTC+2) as its time zone, and in my initializers, I monkey-patch <code>Time</code> and <code>DateTime</code> with some custom functionality.</p>
  
  <p>The odd thing is, that in my monkey-patched methods, the Time/DateTime instances act as if they're UTC (but using the time zone-adjusted value), but elsewhere in the app they respect the time zone config.</p>
  
  <p>So, as an example, in <code>config/initializers/monkey_patching.rb</code> I have the following</p>
  
  <pre><code>module MonkeyPatching
    def foo
      inspect
    end
  end
  
  class Time
    include MonkeyPatching
  end
  
  class DateTime
    include MonkeyPatching
  end
  </code></pre>
  
  <p>Now, elsewhere in the app (or in the rails console), here's what I get</p>
  
  <pre><code>model.created_at.inspect #=&gt; "Mon, 24 Sep 2012 15:06:34 CEST +02:00" (correct!)
  model.created_at.foo     #=&gt; "Mon Sep 24 15:06:34 UTC 2012"          (all wrong!)
  </code></pre>
  
  <p>So, calling <code>inspect</code> "directly" on <code>model.created_at</code> gives me the correct, timezone-adjusted result. But calling the patched-in method <code>foo</code> - which also just calls <code>inspect</code>! - treats the time as UTC, even though it isn't.</p>
  
  <p>To add to my confusion, this only happens with model attributes. I.e. in the rails console, I get identical - and correct - results for <code>DateTime.now.inspect</code> and for <code>DateTime.now.foo</code>. But doing the same for a DateTime attribute, give me the strange behavior seen above.</p>
  
  <p>Any idea why this happens (and how to fix it)?</p>