[MacRuby] #927: MacRuby throws an exception of "undefined method `subsec'" with Time#iso8601.
#927: MacRuby throws an exception of "undefined method `subsec'" with Time#iso8601. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: joshua.ballanco@… Type: defect | Status: new Priority: blocker | Milestone: Component: ControlTower | Keywords: ----------------------------------+----------------------------------------- Test Script: {{{ #!ruby require 'date' require 'time' t = Time.mktime(2004, 9, 19, 1, 2, 3, 456789) d = t.to_datetime p t.iso8601(10) p d.iso8601(10) }}} Result: {{{ $ macruby -v test_time.rb MacRuby 0.8 (ruby 1.9.2) [universal-darwin10.0, x86_64] undefined local variable or method `subsec' for 2004-09-19 01:02:03 +0900:Time (NameError) }}} Patch (merged with Ruby 1.9): {{{ #!diff git diff lib/time.rb diff --git a/lib/time.rb b/lib/time.rb index 1c43371..bd5f750 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -513,12 +513,14 @@ class Time # require 'time' # def xmlschema(fraction_digits=0) - sprintf('%0*d-%02d-%02dT%02d:%02d:%02d', - year < 0 ? 5 : 4, year, mon, day, hour, min, sec) + + sprintf('%d-%02d-%02dT%02d:%02d:%02d', + year, mon, day, hour, min, sec) + if fraction_digits == 0 '' + elsif fraction_digits <= 9 + '.' + sprintf('%09d', nsec)[0, fraction_digits] else - '.' + sprintf('%0*d', fraction_digits, (subsec * 10**fraction_digits).floor) + '.' + sprintf('%09d', nsec) + '0' * (fraction_digits - 9) end + if utc? 'Z' }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/927> MacRuby <http://macruby.org/>
#927: MacRuby throws an exception of "undefined method `subsec'" with Time#iso8601. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by watson1978@…): * owner: joshua.ballanco@… => lsansonetti@… * priority: blocker => major * component: ControlTower => MacRuby -- Ticket URL: <http://www.macruby.org/trac/ticket/927#comment:1> MacRuby <http://macruby.org/>
#927: MacRuby throws an exception of "undefined method `subsec'" with Time#iso8601. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by watson1978@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.8 Comment: Fixed with r4571. -- Ticket URL: <http://www.macruby.org/trac/ticket/927#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby