From: Brian Candler Date: 2010-05-11T23:04:51+09:00 Subject: Re: Differences in Time v1.8.6 and 1.9.1 > You haven't even shown us what those print lines show. Are they what you > expect? If not, what do you see, and what did you expect to see? Or is > the problem occurring later on in the code? If I run just those lines, I get: [1.8.6p114] 2010 Thu Jan 01 00:33:30 +0100 1970 Thu Jan 01 00 [1.9.2preview2] 2010 1970-01-01 00:33:30 +0100 1970-01-01 00 So the difference is simply that Time#to_s has a different default format. $ ruby -e 'puts Time.now.to_s' Tue May 11 15:02:06 +0100 2010 $ ruby19 -e 'puts Time.now.to_s' 2010-05-11 15:02:08 +0100 If that's the problem, then use Time#strftime to make it explicit what format you want. The documentation of Time#to_s is clear: [ruby 1.8] ------------------------------------------------------------------------ Returns a string representing _time_. Equivalent to calling +Time#strftime+ with a format string of ``+%a+ +%b+ +%d+ +%H:%M:%S+ +%Z+ +%Y+''. Time.now.to_s #=> "Wed Apr 09 08:56:04 CDT 2003" [ruby 1.9] ------------------------------------------------------------------------ Returns a string representing _time_. Equivalent to calling +Time#strftime+ with a format string of ``+%Y-%m-%d+ +%H:%M:%S+ +%z+'' for a local time and ``+%Y-%m-%d+ +%H:%M:%S+ +UTC+'' for a UTC time. Time.now.to_s #=> "2007-10-05 16:09:51 +0900" Time.now.utc.to_s #=> "2007-10-05 07:09:51 UTC" Remember also that Time.at(2010) will give you the time 2,010 seconds after midnight at 1 Jan 1970. -- Posted via http://www.ruby-forum.com/.