From: Greg Go Date: 2008-01-07T05:04:07+09:00 Subject: DateTime new_offset unexpected results Hello, everybody: I'm new to ruby, but I'm pretty sure this isn't a problem with me. I'm running ruby 1.8.6 on Windows XP, and using NetBeans as my IDE. My application reads the rise, transit and set times for the sun at my location from a spreadsheet. The spreadsheet provides the date and time as an astronomical julian date that I then use to create a number of DateTime objects. I manually check for Daylight Savings Time by creating two more DateTime objects, one for DST start, the other for DST end as class variables. I have a method that returns the local time of the event as another DateTime object created with DateTime's new_offset method. Here's the code that actually determines whether it's DST or not, and creates the local time object accordingly: offset = Rational(-7,24) if (@jd > @@dstStart) && (@jd < @@dstEnd) offset = Rational(-6,24) end @ld = @jd.new_offset(offset) @jd is the julian date of the event. The problem is this: For some events, @ld is one hour off. Here's an example: @jd.to_s #=> 2008-03-09T13:24:59+00:00 @ld.to_s #=> 2008-03-09T06:24:59-06:00 In my book, 13 - 6 = 7, not 6. I've tried with different offset values, as well: @jd.to_s #=> 2008-03-09T13:24:59+00:00 @ld.to_s #=> 2008-03-09T08:24:59-05:00 - Correct @jd.to_s #=> 2008-03-09T13:24:59+00:00 @ld.to_s #=> 2008-03-09T05:24:59-08:00 - Correct So, it appears that it's only when the offset is -6. This is only happening to some events. However, all events are instances the same class, with the code above. I've used this base class to do the same thing with lunar events, with no problem. This seems like a bug to me. Any ideas as to what's going on? Thanks for your help! Greg -- Posted via http://www.ruby-forum.com/.