<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">15783</assigned-user-id>
  <attachments-count type="integer">0</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2008-06-19T22:30:14+01:00</created-at>
  <creator-id type="integer">8163</creator-id>
  <milestone-due-on type="datetime">2009-03-18T00:00:00+00:00</milestone-due-on>
  <milestone-id type="integer">9901</milestone-id>
  <number type="integer">454</number>
  <permalink>activerecord-timezone-issues</permalink>
  <priority type="integer">2</priority>
  <project-id type="integer">8994</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>invalid</state>
  <tag>activerecord bug timezone</tag>
  <title>ActiveRecord timezone issues</title>
  <updated-at type="datetime">2009-12-01T21:03:05+00:00</updated-at>
  <user-id type="integer">23266</user-id>
  <user-name>Richie Vos</user-name>
  <creator-name>Eugene Pimenov</creator-name>
  <assigned-user-name>Geoff Buesing</assigned-user-name>
  <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
  <milestone-title>2.1.1</milestone-title>
  <original-body>@@@ ruby
&gt;&gt; Fileset.find(:all, :conditions =&gt; {:created_at =&gt; Fileset.last.created_at})
=&gt; [#&lt;Fileset id: 7, name: &quot;Untitled.xls&quot;, description: nil, created_at: &quot;2008-06-19 20:31:07&quot;, updated_at: &quot;2008-06-19 20:31:07&quot;, original_size: 433152&gt;]
&gt;&gt; Fileset.find(:all, :conditions =&gt; {:created_at =&gt; Time.mktime(2008, 06, 20, 0, 31, 7)})
=&gt; []
&gt;&gt; Time.mktime(2008, 06, 20, 0, 31, 7)
=&gt; Fri Jun 20 00:31:07 +0400 2008
&gt;&gt; Fileset.last.created_at
=&gt; &#1087;&#1090;, 20 &#1080;&#1102;&#1085; 2008 00:31:07 MSD +04:00

#

&gt;&gt; Time.now
=&gt; Fri Jun 20 01:27:26 +0400 2008
&gt;&gt; Time.now.utc
=&gt; Thu Jun 19 21:27:39 UTC 2008
&gt;&gt; Time.now.zone
=&gt; &quot;MSD&quot;
@@@

Since Time.now.zone shows me correct timezone, I do not see the reason why I should pass UTC to ActiveRecord::Base.find</original-body>
  <latest-body>@@@ ruby
&gt;&gt; Fileset.find(:all, :conditions =&gt; {:created_at =&gt; Fileset.last.created_at})
=&gt; [#&lt;Fileset id: 7, name: &quot;Untitled.xls&quot;, description: nil, created_at: &quot;2008-06-19 20:31:07&quot;, updated_at: &quot;2008-06-19 20:31:07&quot;, original_size: 433152&gt;]
&gt;&gt; Fileset.find(:all, :conditions =&gt; {:created_at =&gt; Time.mktime(2008, 06, 20, 0, 31, 7)})
=&gt; []
&gt;&gt; Time.mktime(2008, 06, 20, 0, 31, 7)
=&gt; Fri Jun 20 00:31:07 +0400 2008
&gt;&gt; Fileset.last.created_at
=&gt; &#1087;&#1090;, 20 &#1080;&#1102;&#1085; 2008 00:31:07 MSD +04:00

#

&gt;&gt; Time.now
=&gt; Fri Jun 20 01:27:26 +0400 2008
&gt;&gt; Time.now.utc
=&gt; Thu Jun 19 21:27:39 UTC 2008
&gt;&gt; Time.now.zone
=&gt; &quot;MSD&quot;
@@@

Since Time.now.zone shows me correct timezone, I do not see the reason why I should pass UTC to ActiveRecord::Base.find</latest-body>
  <original-body-html>&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;gt;&amp;gt; Fileset.find(:all, :conditions =&amp;gt; {:created_at =&amp;gt; Fileset.last.created_at})
=&amp;gt; [#&amp;lt;Fileset id: 7, name: &amp;quot;Untitled.xls&amp;quot;, description: nil, created_at: &amp;quot;2008-06-19 20:31:07&amp;quot;, updated_at: &amp;quot;2008-06-19 20:31:07&amp;quot;, original_size: 433152&amp;gt;]
&amp;gt;&amp;gt; Fileset.find(:all, :conditions =&amp;gt; {:created_at =&amp;gt; Time.mktime(2008, 06, 20, 0, 31, 7)})
=&amp;gt; []
&amp;gt;&amp;gt; Time.mktime(2008, 06, 20, 0, 31, 7)
=&amp;gt; Fri Jun 20 00:31:07 +0400 2008
&amp;gt;&amp;gt; Fileset.last.created_at
=&amp;gt; &#1087;&#1090;, 20 &#1080;&#1102;&#1085; 2008 00:31:07 MSD +04:00

#

&amp;gt;&amp;gt; Time.now
=&amp;gt; Fri Jun 20 01:27:26 +0400 2008
&amp;gt;&amp;gt; Time.now.utc
=&amp;gt; Thu Jun 19 21:27:39 UTC 2008
&amp;gt;&amp;gt; Time.now.zone
=&amp;gt; &amp;quot;MSD&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Since Time.now.zone shows me correct timezone, I do not see the reason why I should pass UTC to ActiveRecord::Base.find
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>@@@ ruby
&gt;&gt; Fileset.find(:all, :conditions =&gt; [&quot;created_at &gt;= ?&quot;, Fileset.last.created_at])
=&gt; [#&lt;Fileset id: 7, name: &quot;Untitled.xls&quot;, description: nil, created_at: &quot;2008-06-19 20:31:07&quot;, updated_at: &quot;2008-06-19 20:31:07&quot;, original_size: 433152&gt;]
&gt;&gt; Fileset.find(:all, :conditions =&gt; [&quot;created_at &gt;= ?&quot;, Time.mktime(2008, 06, 20, 0, 31, 7)])
=&gt; []
&gt;&gt; Fileset.find(:all, :conditions =&gt; {:created_at =&gt; Time.now.midnight..Time.now})
=&gt; []
&gt;&gt; Fileset.find(:all, :conditions =&gt; {:created_at =&gt; Time.now.midnight.utc..Time.now})
=&gt; [#&lt;Fileset id: 7, name: &quot;Untitled.xls&quot;, description: nil, created_at: &quot;2008-06-19 20:31:07&quot;, updated_at: &quot;2008-06-19 20:31:07&quot;, original_size: 433152&gt;]
&gt;&gt; Time.mktime(2008, 06, 20, 0, 31, 7)
=&gt; Fri Jun 20 00:31:07 +0400 2008
&gt;&gt; Fileset.last.created_at
=&gt; &#1087;&#1090;, 20 &#1080;&#1102;&#1085; 2008 00:31:07 MSD +04:00

#

&gt;&gt; Time.now
=&gt; Fri Jun 20 01:27:26 +0400 2008
&gt;&gt; Time.now.utc
=&gt; Thu Jun 19 21:27:39 UTC 2008
&gt;&gt; Time.now.zone
=&gt; &quot;MSD&quot;
@@@

Since Time.now.zone shows me correct timezone, I do not see the reason why I should pass UTC to ActiveRecord::Base.find</body>
      <body-html>&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;gt;&amp;gt; Fileset.find(:all, :conditions =&amp;gt; [&amp;quot;created_at &amp;gt;= ?&amp;quot;, Fileset.last.created_at])
=&amp;gt; [#&amp;lt;Fileset id: 7, name: &amp;quot;Untitled.xls&amp;quot;, description: nil, created_at: &amp;quot;2008-06-19 20:31:07&amp;quot;, updated_at: &amp;quot;2008-06-19 20:31:07&amp;quot;, original_size: 433152&amp;gt;]
&amp;gt;&amp;gt; Fileset.find(:all, :conditions =&amp;gt; [&amp;quot;created_at &amp;gt;= ?&amp;quot;, Time.mktime(2008, 06, 20, 0, 31, 7)])
=&amp;gt; []
&amp;gt;&amp;gt; Fileset.find(:all, :conditions =&amp;gt; {:created_at =&amp;gt; Time.now.midnight..Time.now})
=&amp;gt; []
&amp;gt;&amp;gt; Fileset.find(:all, :conditions =&amp;gt; {:created_at =&amp;gt; Time.now.midnight.utc..Time.now})
=&amp;gt; [#&amp;lt;Fileset id: 7, name: &amp;quot;Untitled.xls&amp;quot;, description: nil, created_at: &amp;quot;2008-06-19 20:31:07&amp;quot;, updated_at: &amp;quot;2008-06-19 20:31:07&amp;quot;, original_size: 433152&amp;gt;]
&amp;gt;&amp;gt; Time.mktime(2008, 06, 20, 0, 31, 7)
=&amp;gt; Fri Jun 20 00:31:07 +0400 2008
&amp;gt;&amp;gt; Fileset.last.created_at
=&amp;gt; &#1087;&#1090;, 20 &#1080;&#1102;&#1085; 2008 00:31:07 MSD +04:00

#

&amp;gt;&amp;gt; Time.now
=&amp;gt; Fri Jun 20 01:27:26 +0400 2008
&amp;gt;&amp;gt; Time.now.utc
=&amp;gt; Thu Jun 19 21:27:39 UTC 2008
&amp;gt;&amp;gt; Time.now.zone
=&amp;gt; &amp;quot;MSD&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Since Time.now.zone shows me correct timezone, I do not see the reason why I should pass UTC to ActiveRecord::Base.find
&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-06-19T22:55:04+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-19T22:55:04+01:00</updated-at>
      <user-id type="integer">8163</user-id>
      <user-name>Eugene Pimenov</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>sorry, it's already fixed</body>
      <body-html>&lt;div&gt;&lt;p&gt;
sorry, it's already fixed
&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-06-19T22:31:54+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-19T22:31:54+01:00</updated-at>
      <user-id type="integer">8163</user-id>
      <user-name>Eugene Pimenov</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>okay, hash conditions works, but string do not.

edge rails, installed via rake rails:freeze:edge today (20 jun 2008)</body>
      <body-html>&lt;div&gt;&lt;p&gt;
okay, hash conditions works, but string do not.
&lt;/p&gt;&lt;p&gt;
edge rails, installed via rake rails:freeze:edge today (20 jun 2008)
&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-06-19T22:55:55+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-19T22:55:55+01:00</updated-at>
      <user-id type="integer">8163</user-id>
      <user-name>Eugene Pimenov</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-06-19T23:45:19+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
:assigned_user: 
:milestone: 
</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-19T23:45:19+01:00</updated-at>
      <user-id type="integer">85</user-id>
      <user-name>Jeremy Kemper</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Time#to_s(:db) ignores Time#zone -- example:

@@@ ruby
&gt;&gt; Time.mktime(2008, 06, 20, 0, 31, 7).to_s(:db)
=&gt; &quot;2008-06-20 00:31:07&quot;
&gt;&gt; Time.utc(2008, 06, 20, 0, 31, 7).to_s(:db)
=&gt; &quot;2008-06-20 00:31:07&quot;
@@@

...therefore, AR will treat Time.mktime values as if they were Time.utc values.

@@@ ruby
&gt;&gt; Comment.find(:all, :conditions =&gt; {:created_at =&gt; Time.local(2008,1,1)})
June 19, 2008 21:18 -- Comment Load (0.001406)  SELECT * FROM &quot;comments&quot; WHERE (&quot;comments&quot;.&quot;created_at&quot; = '2008-01-01 00:00:00') 
@@@

However, if you're setting config.time_zone, you should be able to specify a local time with Time.zone.local() for :conditions, and the correct time value will be sent to the db:

@@@ ruby
&gt;&gt; Comment.find(:all, :conditions =&gt; ['created_at &gt; ?', Time.zone.local(2008,1,1)])
June 19, 2008 21:23 -- Comment Load (0.001179)  SELECT * FROM &quot;comments&quot; WHERE (created_at &gt; '2008-01-01 06:00:00')  
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;
Time#to_s(:db) ignores Time#zone -- example:
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;gt;&amp;gt; Time.mktime(2008, 06, 20, 0, 31, 7).to_s(:db)
=&amp;gt; &amp;quot;2008-06-20 00:31:07&amp;quot;
&amp;gt;&amp;gt; Time.utc(2008, 06, 20, 0, 31, 7).to_s(:db)
=&amp;gt; &amp;quot;2008-06-20 00:31:07&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
...therefore, AR will treat Time.mktime values as if they were Time.utc values.
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;gt;&amp;gt; Comment.find(:all, :conditions =&amp;gt; {:created_at =&amp;gt; Time.local(2008,1,1)})
June 19, 2008 21:18 -- Comment Load (0.001406)  SELECT * FROM &amp;quot;comments&amp;quot; WHERE (&amp;quot;comments&amp;quot;.&amp;quot;created_at&amp;quot; = '2008-01-01 00:00:00') &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
However, if you're setting config.time_zone, you should be able to specify a local time with Time.zone.local() for :conditions, and the correct time value will be sent to the db:
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;gt;&amp;gt; Comment.find(:all, :conditions =&amp;gt; ['created_at &amp;gt; ?', Time.zone.local(2008,1,1)])
June 19, 2008 21:23 -- Comment Load (0.001179)  SELECT * FROM &amp;quot;comments&amp;quot; WHERE (created_at &amp;gt; '2008-01-01 06:00:00')  &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-06-20T03:34:02+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-20T03:34:02+01:00</updated-at>
      <user-id type="integer">15783</user-id>
      <user-name>Geoff Buesing</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I'm setting config.time_zone&#8230;

I think you should consider automatic conversation to UTC&#8230;

Because of midnight (and similar) functions. It simply do not point to midnight. 

Of course if there're some issues with it, simply close this ticket&#8230;</body>
      <body-html>&lt;div&gt;&lt;p&gt;
I'm setting config.time_zone&#8230;
&lt;/p&gt;&lt;p&gt;
I think you should consider automatic conversation to UTC&#8230;
&lt;/p&gt;&lt;p&gt;
Because of midnight (and similar) functions. It simply do not point to midnight.
&lt;/p&gt;&lt;p&gt;
Of course if there're some issues with it, simply close this ticket&#8230;
&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-06-20T03:46:06+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-20T03:46:06+01:00</updated-at>
      <user-id type="integer">8163</user-id>
      <user-name>Eugene Pimenov</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-06-20T04:03:51+01:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- 
:state: open
</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>invalid</state>
      <tag nil="true"></tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2008-06-20T04:03:51+01:00</updated-at>
      <user-id type="integer">85</user-id>
      <user-name>Jeremy Kemper</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Jeremy, I know it's been awhile, but can you explain why this is invalid?

It seems like an inconsistent api that the following doesn't work:

@@@ ruby {
time = Time.mktime(2000, 1, 1)
Model.create!(:occurred_at =&gt; time)
Model.find(:first, :conditions =&gt; { :occurred_at =&gt; time)
}</body>
      <body-html>&lt;div&gt;&lt;p&gt;Jeremy, I know it's been awhile, but can you explain why this is
invalid?&lt;/p&gt;
&lt;p&gt;It seems like an inconsistent api that the following doesn't
work:&lt;/p&gt;
&lt;p&gt;@@@ ruby { time = Time.mktime(2000, 1, 1)&lt;br&gt;
Model.create!(:occurred_at =&amp;gt; time)&lt;br&gt;
Model.find(:first, :conditions =&amp;gt; { :occurred_at =&amp;gt; time)&lt;br&gt;
}&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-12-01T20:48:57+00:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: 
</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>invalid</state>
      <tag>activerecord bug</tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2009-12-01T20:49:01+00:00</updated-at>
      <user-id type="integer">23266</user-id>
      <user-name>Richie Vos</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I am confident I will never properly format a lighthouse post.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I am confident I will never properly format a lighthouse
post.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-12-01T20:50:03+00:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>invalid</state>
      <tag>activerecord bug</tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2009-12-01T20:50:06+00:00</updated-at>
      <user-id type="integer">23266</user-id>
      <user-name>Richie Vos</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15783</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Sorry, for 3 separate comments, but I think I should clarify, since I had too much timezone info in my brain and didn't properly say it (will be quite happy when lighthouse gets that edit/preview button).

My environment has my local box's timezone as Central. In my environment.rb I have:
    config.time_zone = &quot;Eastern Time (US &amp; Canada)&quot;

So when I do 
    time = Time.mktime(2000, 1, 1)
    model = Model.create!(:occurred_at =&gt; time)
    model = Model.find(model.id) # just to get it clean from the AR/DB point of view

I end up with a model in the db with the time as
model.occurred_at.to_s: &quot;2000-01-01 01:00:00 -0500&quot;
model.occurred_at_before_type_cast: &quot;2000-01-01 06:00:00&quot;

This makes complete sense, since my time was created with an implicit timezone and AR respected that. However, right after doing that, if I do my find, AR doesn't do a conversion, leading to the find not finding anything.

    Model.first(:conditions =&gt; { :occurred_at =&gt; model.occurred_at }) !=
    Model.first(:conditions =&gt; { :occurred_at =&gt; time })

That seems really confusing to me. I can't really think of a reason why that'd be desired behavior.

So I'm thinking I'm misunderstanding something, and would appreciate some clarification.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Sorry, for 3 separate comments, but I think I should clarify,
since I had too much timezone info in my brain and didn't properly
say it (will be quite happy when lighthouse gets that edit/preview
button).&lt;/p&gt;
&lt;p&gt;My environment has my local box's timezone as Central. In my
environment.rb I have:&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;config.time_zone = &quot;Eastern Time (US &amp;amp; Canada)&quot;&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;So when I do&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;time = Time.mktime(2000, 1, 1)
model = Model.create!(:occurred_at =&amp;gt; time)
model = Model.find(model.id) # just to get it clean from the AR/DB point of view&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;I end up with a model in the db with the time as&lt;br&gt;
model.occurred_at.to_s: &quot;2000-01-01 01:00:00 -0500&quot;&lt;br&gt;
model.occurred_at_before_type_cast: &quot;2000-01-01 06:00:00&quot;&lt;/p&gt;
&lt;p&gt;This makes complete sense, since my time was created with an
implicit timezone and AR respected that. However, right after doing
that, if I do my find, AR doesn't do a conversion, leading to the
find not finding anything.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Model.first(:conditions =&amp;gt; { :occurred_at =&amp;gt; model.occurred_at }) !=
Model.first(:conditions =&amp;gt; { :occurred_at =&amp;gt; time })&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;That seems really confusing to me. I can't really think of a
reason why that'd be desired behavior.&lt;/p&gt;
&lt;p&gt;So I'm thinking I'm misunderstanding something, and would
appreciate some clarification.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-12-01T21:03:00+00:00</created-at>
      <creator-id type="integer">8163</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: activerecord bug
</diffable-attributes>
      <milestone-id type="integer">9901</milestone-id>
      <number type="integer">454</number>
      <permalink>activerecord-timezone-issues</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>invalid</state>
      <tag>activerecord bug timezone</tag>
      <title>ActiveRecord timezone issues</title>
      <updated-at type="datetime">2009-12-01T21:03:05+00:00</updated-at>
      <user-id type="integer">23266</user-id>
      <user-name>Richie Vos</user-name>
      <creator-name>Eugene Pimenov</creator-name>
      <assigned-user-name>Geoff Buesing</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/454</url>
      <milestone-title>2.1.1</milestone-title>
    </version>
  </versions>
</ticket>
