Ruby Time.new giving time zone offset of 14 minutes
When I create a time object in Ruby 1.9.2 with a date earlier than 1 September 1919, the time zone is set to +0014 rather than to the system zone (+0100) or UTC. Now that I discovered the problem being the early date, and since all I want is a time without a date, I will just use a recent date. But does anyone know why this happens?
ruby-1.9.2-p0 :034 > Time.new(1919,9,1,0,0,0)
=> 1919-09-01 00:46:24 +0100
ruby-1.9.2-p0 :035 > Time.new(1919,8,31,23,59,59)
=> 1919-08-31 23:59:59 +0014
ruby-1.9.2-p0 :036 > Time.new(1919,8,31,1,0,0)
=> 1919-08-31 01:00:00 +0开发者_JAVA百科014
Echoing what others are commenting on: there is no reproducible problem here with the information you have provided. On Windows 7, 64-bit:
irb(main):001:0> Time.new(1919,8,31,23,59,59)
#=> 1919-08-31 23:59:59 -0600
irb(main):002:0> RUBY_DESCRIPTION
#=> "ruby 1.9.2p180 (2011-02-18) [i386-mingw32]"
On Ubuntu 10.04, 32-bit:
ruby-1.9.2-p136 :001 > Time.new(1919,8,31,23,59,59)
#=> 1919-08-31 23:59:59 -0600
ruby-1.9.2-p136 :002 > RUBY_DESCRIPTION
#=> "ruby 1.9.2p136 (2010-12-25) [i686-linux]"
...and on your exact patch level:
ruby-1.9.2-p0 :001 > Time.new(1919,8,31,23,59,59)
#=> 1919-08-31 23:59:59 -0600
ruby-1.9.2-p0 :002 > RUBY_DESCRIPTION
#=> "ruby 1.9.2p0 (2010-08-18) [i686-linux]"
Please provide your OS version and bit-level for additional help.
精彩评论