[MacRuby-devel] Strange NSDate behavior building 32 bit v 64 bit (Richard Sepulveda)
Richard Sepulveda
rsepulveda2 at gmail.com
Tue Feb 1 11:22:42 PST 2011
Here is an update on what is going on with the NSDate issues.
i have been working with 3 version's of MacRuby.
MacRuby 0.7 with Vincent's first suggested modification (commenting out the NSDate clause in objc.m (This
essentially makes MacRuby use a real NSDate object instead of converting it into a Ruby Time object)
MacRuby 0.8 with no changes
MacRuby 0.9 with Vincent's NSDate changes. (He fixes the NSDate/Ruby Time object)
The test code:
NSLog( "In rb_main.rb")
i = 1296445544
NSLog( "i = %d class = %s" % [i, i.class.to_s])
f = 1296445544.0
NSLog( "f = %f class = %@ DIG = %d" % [ f, f.class, Float::DIG.to_s])
if i == f
NSLog( "Is equal")
else
NSLog( "Not equal")
end
time = Time.new
NSLog( "time = %s" % [time.to_s])
NSLog( "time to_i = %d" % [time.to_i])
NSLog( "time to_f = %f" % [time.to_f])
nsdate = NSDate.date
NSLog( "nsdate = %s" % [nsdate.description])
i = nsdate.timeIntervalSinceReferenceDate.to_i
f = nsdate.timeIntervalSinceReferenceDate.to_f
NSLog( "nsdate to_i = %d" % [i])
NSLog( "nsdate to_f = %f" % [f])
Summary (all tests were run in 32 bit mode): I can provide the output if you wish to see it.
MacRuby 0.7
- NSDate is fixed, Can also do calculations with the date like adding 60 seconds,etc.
- Ruby Time - date is correct, to_i is correct, to_f is incorrect
- Bignum.to_i is correct, Bignum.to_f is wrong
MacRuby 0.8
- NSDate is broken - wrong time, wrong to_i, wrong to_f
- Ruby Time - date is correct, to_i is correct, to_f is incorrect
- Bignum.to_i is correct, Bignum.to_f is wrong
MacRuby 0.9
- NSDate is somewhat fixed. It returns the correct time, but fails when doing calculations with that date
- Ruby Time - date is correct, to_i is correct, to_f is incorrect
- Bignum.to_i is correct, Bignum.to_f is wrong
My conclusions,
- 0.7 and 0.9 fix return the correct time now, 0.9 fix can't do necessary time arithmetic
- Ruby Time.to_f is broken in all 3 versions
- Bignum.to_f is broken in all 3 versions
- I believe the to_f method is behind all of these problems but i haven't had time to find the problem nor
a solution.
* Late breaking news, I was running my real app with the modified 0.7 version and when i attempted
to 'play' an NSSound, the application exited with a return code 45?? I am not sure what this means.
I will try to create a test case for this later on.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110201/57622345/attachment.html>
More information about the MacRuby-devel
mailing list