From: Charlie Bowman Date: 2006-02-22T00:43:21+09:00 Subject: Re: DateTime.parse speed question --=-H4213iCPBbc547Vnz3cx Content-Type: text/plain Content-Transfer-Encoding: 7bit I decided to figure out just how much faster using Time was than using DateTime so I wrote a couple of benchmark scripts. It turns out that using Time offered an 800% increase in speed in my test app. I knew that Time was faster but I never thought it would be that much of a difference. I posted both scripts and a longer explanation at recentrambles.com. I would love to know if there are better ways to work with dates than what I used. I'm still trying to get the perl out of my ruby! On Tue, 2006-02-14 at 04:34 +0900, Jamey Cribbs wrote: > Charlie Bowman wrote: > > >The Time class doesn't appear to have any methods to parse a string into > >a time object or to find the difference of two times. How can this be > >done without using the DateTime class? > > > > > As Mike Fletcher answered in another email, there is a Standard Library > module called Time, that you can require into your script. This adds a > parse method to the Time built-in class. > > If you don't want to do that, you could roll your own by using > Time.local and parsing the string yourself and feeding the results to > Time.local. > > As far as finding the difference between two times, you can use the "-" > instance method to find the difference in seconds. If you need that in > hours or minutes, just have your script do the math. > > Definitely more work, but if you are looking for more speed than > DateTime, it might be worth it. > > Jamey > > --=-H4213iCPBbc547Vnz3cx--