<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Segment7: Time.today going away</title>
    <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Blog</description>
    <item>
      <title>Time.today going away</title>
      <description>&lt;p&gt;So you&amp;#8217;ve been using &lt;code&gt;Time::today&lt;/code&gt; for some time, and thought it was part of time.rb or ActiveSupport?  Well, you&amp;#8217;d be wrong.  I was!&lt;/p&gt;


	&lt;p&gt;It turns out that rubygems/specification.rb defines &lt;code&gt;Time::today&lt;/code&gt;, and that&amp;#8217;s wrong.  RubyGems has no business adding methods to the core when it doesn&amp;#8217;t need to, so I&amp;#8217;ve marked it for removal.&lt;/p&gt;


	&lt;p&gt;If you want to use &lt;code&gt;Time::today&lt;/code&gt; in the future you&amp;#8217;ll need to define it in your code somewhere, here is its definition:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;require 'time'

def Time.today
  t = Time.now
  t - (t.to_i % 86400)
end unless Time.respond_to? :today&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Go ahead and throw it in wherever you think is appropriate.  I suggest you do this now.&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;UPDATED&lt;/span&gt;: Now with a better &lt;code&gt;Time::today&lt;/code&gt;.&lt;/p&gt;
</description>
      <pubDate>Mon, 08 Oct 2007 15:22:32 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:1f8c5e17-18e2-4b58-9dd4-62b857cf5278</guid>
      <author>drbrain@segment7.net (Eric Hodel)</author>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away</link>
      <category>Ruby</category>
      <category>Rubygems</category>
    </item>
    <item>
      <title>"Time.today going away" by Eric Hodel</title>
      <description>&lt;p&gt;@dlh: No, its better, nearly twice as fast as yours in 1,000,000 iterations.&lt;/p&gt;


&lt;pre&gt;parse   37.110000   0.550000  37.660000 ( 55.822070)
mktime   2.680000   0.030000   2.710000 (  3.160472)
%        1.430000   0.020000   1.450000 (  1.779844)&lt;/pre&gt;</description>
      <pubDate>Mon, 08 Oct 2007 17:19:35 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:9909ca42-31f4-4850-a08e-bb01ae7e6351</guid>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away#comment-788</link>
    </item>
    <item>
      <title>"Time.today going away" by dlh</title>
      <description>&lt;p&gt;Um, your updated version is just as awful.&lt;/p&gt;</description>
      <pubDate>Mon, 08 Oct 2007 16:29:39 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:d8e4cbda-3ecf-4510-ae1a-fcd082766f33</guid>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away#comment-787</link>
    </item>
    <item>
      <title>"Time.today going away" by dlh</title>
      <description>&lt;p&gt;How about without parsing a string to get a Time object&amp;#8230; (no need to require &amp;#8220;time.rb&amp;#8221; for Time.parse)&lt;/p&gt;


&lt;pre&gt;def Time.today
  now = now()
  mktime(now.year, now.mon, now.day)
end

Time.today # =&amp;gt; Mon Oct 08 00:00:00 -0400 2007&lt;/pre&gt;</description>
      <pubDate>Mon, 08 Oct 2007 16:24:46 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:7f38c1ab-c98f-4c30-a4c3-8770ae186981</guid>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away#comment-786</link>
    </item>
    <item>
      <title>"Time.today going away" by Eric Hodel</title>
      <description>&lt;p&gt;@Sebastian: I&amp;#8217;ve only marked Time::today for removal.&lt;/p&gt;


	&lt;p&gt;Removal is accomplished in three phases.  Phase one is trumpeting it far and wide, where we&amp;#8217;re at now.  Phase two is warning whenever you call the to-be-removed thing.  Phase three is deleting.  There will be ample time between the three phases for people to adjust.  (Even though they usually don&amp;#8217;t.)&lt;/p&gt;</description>
      <pubDate>Mon, 08 Oct 2007 16:21:26 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:a454f45b-ee9c-451f-becf-cd751f761094</guid>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away#comment-785</link>
    </item>
    <item>
      <title>"Time.today going away" by Sebastian</title>
      <description>&lt;p&gt;While i fully agree with the rationale of throwing this out of gems, i don&amp;#8217;t think this is a good idea at this point at least not for a small dot-x release. I wouldn&amp;#8217;t wanna be the one trying to figure this one out and there may be some not reading this blog (come to think of it, screw &amp;#8216;em!). But seriously, are deprecation warnings an option?&lt;/p&gt;</description>
      <pubDate>Mon, 08 Oct 2007 16:08:43 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:2e073268-0bac-418e-a852-a367e12418c3</guid>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away#comment-784</link>
    </item>
    <item>
      <title>"Time.today going away" by Ben Mabey</title>
      <description>&lt;p&gt;Wow, that would of been a nasty one to figure out.  Thanks for the heads up.&lt;/p&gt;</description>
      <pubDate>Mon, 08 Oct 2007 15:45:30 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:9640b9c8-7283-4553-8f9d-e9726a355e4f</guid>
      <link>http://blog.segment7.net/articles/2007/10/08/time-today-going-away#comment-783</link>
    </item>
  </channel>
</rss>
