From: Greg Go Date: 2008-01-11T11:58:15+09:00 Subject: Re: DateTime new_offset unexpected results Todd Benson wrote: > On Jan 10, 2008 9:33 AM, Greg Go wrote: >> Todd Benson wrote: >> > On Jan 9, 2008 10:11 PM, Greg Go wrote: >> >> > >> >> > puts @jd ### >> >> you're going with this -- am I missing something with the way that ruby >> >> handles class variables? >> > >> > Simple. Just wanted to see if your dstStart and dstEnd vars were >> > correct, and if, in fact, you were actually entering the if condition. > > By this last statement, I meant if you were entering the if condition > during rise event with -6. > >> > It's probably the bug that was mentioned, but I can't reproduce your >> > error. >> > >> > Todd > >> Ah, I see. What I was doing to confirm that I had entered the test >> condition was changing the value of offset to, for example >> Rational(-8,24), and Rational(-5,24). >> >> I'll see if I can work up a test case and post it, just to be complete. > > You don't have to get super crazy :-). Do whatever you think will > help. Like I said, I don't see the same error on my system, but I > also don't have your data (your code might have changed the class > variables before the if statement during the "rise" event is what I > was thinking). > > Todd Todd, et al: This demonstrates the bug: @ut = DateTime.new!(2454535.05902777) # According to http://aa.usno.navy.mil/data/docs/JulianDate.php: # JD 2454535.05902 is CE 2008 March 09 13:24:59.3 UT puts @ut.to_s #=> 2008-03-09T13:24:59+00:00 (4..8).each do |i| puts @ut.new_offset(Rational(-i,24)) end # 2008-03-09T09:24:59-04:00 # 2008-03-09T08:24:59-05:00 # 2008-03-09T06:24:59-06:00 <- Should be 2008-03-09T07:24:59-06:00 # 2008-03-09T06:24:59-07:00 # 2008-03-09T05:24:59-08:00 Thanks, Greg -- Posted via http://www.ruby-forum.com/.