From: Arlen Cuss Date: 2012-12-10T15:01:11+09:00 Subject: Re: Time.new(2001, 12, 3).to_i returns wrong value Time internally stores the value in UTC, as does #to_i properly return the seconds since the epoch; the issue here is in your construction of it: the default is to use your local timezone. I'm in +11, hence: > > Time.new(2001, 12, 3) => 2001-12-03 00:00:00 +1100 > > Time.new(2001, 12, 3).to_i > => 1007298000 > > Time.new(2001, 12, 3, 0, 0, 0, 0) > => 2001-12-03 00:00:00 +0000 > > Time.new(2001, 12, 3, 0, 0, 0, 0).to_i > => 1007337600 On Monday, 10 December 2012 at 2:10 AM, Robert Buck wrote: > I basically subtracted the timezone offset for Time.new from my C code > and that fixed it all regardless of what default timezone is set. > > -- > Posted via http://www.ruby-forum.com/.