[MacRuby] #926: MacRuby throws an exception of "undefined method `subsec'" with DateTime#inspect.

MacRuby ruby-noreply at macosforge.org
Sun Oct 3 20:35:33 PDT 2010


#926: MacRuby throws an exception of "undefined method `subsec'" with
DateTime#inspect.
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  major                 |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 Test Script:
 {{{
 #!ruby
 require 'date'

 dt =  DateTime.now
 dt.inspect
 }}}

 Result:
 {{{
 $ macruby -v test_date.rb
 MacRuby 0.8 (ruby 1.9.2) [universal-darwin10.0, x86_64]
 undefined method `subsec' for 2010-10-04 12:28:06 +0900:Time
 (NoMethodError)
 }}}

 Patch (merged with Ruby 1.9):
 {{{
 #!diff
 diff --git a/lib/date.rb b/lib/date.rb
 index 3bb0875..4775a4a 100644
 --- a/lib/date.rb
 +++ b/lib/date.rb
 @@ -1787,7 +1787,7 @@ class Time
    def to_datetime
      jd = DateTime.__send__(:civil_to_jd, year, mon, mday,
 DateTime::ITALY)
      fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec,
 59].min) +
 -      Rational(subsec, 86400)
 +      Rational(nsec, 86400_000_000_000)
      of = Rational(utc_offset, 86400)
      DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
                   of, DateTime::ITALY)
 @@ -1817,7 +1817,7 @@ class Date
      t = Time.now
      jd = civil_to_jd(t.year, t.mon, t.mday, sg)
      fr = time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
 -      Rational(t.subsec, 86400)
 +      Rational(t.nsec, 86400_000_000_000)
      of = Rational(t.utc_offset, 86400)
      new!(jd_to_ajd(jd, fr, of), of, sg)
    end
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/926>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list