Time.utc_offset is incorrect in small time range ------------------------------------------------
Key: JRUBY-4842 URL: http://jira.codehaus.org/browse/JRUBY-4842 Project: JRuby Issue Type: Bug Components: Standard Library Affects Versions: JRuby 1.5, JRuby 1.4, JRuby 1.3.1 Environment: Windows XP SP2 c:\>java -version java version "1.6.0_18" Java(TM) SE Runtime Environment (build 1.6.0_18-b07) Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing) c:\>jruby --version jruby 1.4.1 (ruby 1.8.7 patchlevel 174) (2010-04-26 ea6db6a) (Java HotSpot(TM) Client VM 1.6.0_18) [x86-java] Reporter: Jared Dahl Assignee: Thomas E Enebo When testing on my PC (which is in the USA central time zone), the following simple ruby code returns different values in Jruby (1.3.1, 1.4.1, and 1.5.0) from Ruby (1.8.6, 1.8.7, and 1.9.1). code: puts Time.local(2010,3,13,20,59,59).utc_offset puts Time.local(2010,3,13,21,00,00).utc_offset puts Time.local(2010,3,13,21,59,59).utc_offset puts Time.local(2010,3,13,22,59,59).utc_offset puts Time.local(2010,3,14,1,0,0).utc_offset puts Time.local(2010,3,14,1,59,0).utc_offset puts Time.local(2010,3,14,3,0,0).utc_offset Note that Daylight Saving Time started at 2:00 am CST on March 14. When I am running Ruby (I tested with all ther versions I listed above and got the same results), I get results that I expect. The offset goes from -6 hours to -5 hours after 2:00 am. c:\>cd ruby\ruby1.8.6 c:\ruby\ruby1.8.6>cd bin c:\ruby\ruby1.8.6\bin>ruby --version ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] c:\ruby\ruby1.8.6\bin>ruby c:\test.rb -21600 -21600 -21600 -21600 -21600 -21600 -18000 When I run in Jruby, I get the following incorrect results. C:\>jruby --version jruby 1.4.1 (ruby 1.8.7 patchlevel 174) (2010-04-26 ea6db6a) (Java HotSpot(TM) Client VM 1.6.0_18) [x86-java] C:\>jruby -S test.rb -21600 -18000 -18000 -18000 -18000 -18000 -18000 I do not think that it is a coincidence that JRuby made the jump to Daylight Saving Time 5 hours early. When I change my PC to the Pacific Time Zone, it makes the same mistake, but off by 7 hours instead. I think JRuby is making the switch at 2:00 am GMT, instead of 2:00 am local time. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email