Issue #5399 has been reported by Christopher Eberz.

----------------------------------------
Bug #5399: Time.strptime does not correctly parse seconds since epoch
http://redmine.ruby-lang.org/issues/5399

Author: Christopher Eberz
Status: Open
Priority: Normal
Assignee: 
Category: lib
Target version: 
ruby -v: ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]


Reproducing the bug inside the IRB:

Time.strptime("1", "%s") 
=> 2011-10-03 15:51:02 -0700 

as opposed to:

Date.strptime("1", "%s").to_time 
=> 1970-01-01 00:00:00 -0800

The docs read that Time.strptime relies on Date._strptime to do the parsing, and then converts it to a Time object.  Date._strptime returns the time only as seconds (with "%s" as the format string):

Date.send(:_strptime, "100000", "%s") 
=> {:seconds=>100000} 

Class Date seems to check for this case (see Date.rewrite_frags) but class Time does not; Time seems to assume that Date._strptime will return a hash with all of the key/values necessary to correctly call Time.make_time:

# File lib/time.rb, line 277
d = Date._strptime(date, format)
. . .
make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)


-- 
http://redmine.ruby-lang.org