Time.parse fails on Windows system with Thai environment
--------------------------------------------------------

                 Key: JRUBY-1654
                 URL: http://jira.codehaus.org/browse/JRUBY-1654
             Project: JRuby
          Issue Type: Bug
         Environment: JRuby 1.1b1 and trunk
Windows Vista (x86-64), Windows XP (x86)
Java 6 Update 3
            Reporter: Kridsada Thanabulpong
            Assignee: Thomas E Enebo


Running {{Time.parse}} fail on Windows with Thai environment, may cause by Thai 
calendar which add 543 years to Gregorian calendar (and this calendar is most 
common in Thailand). I've tested the following in Windows (Vista 64 and XP 32 
produce the same result):

JRuby r5143 tests were build by headius from #JRuby. {{Time.now}} were taken 
later in a different IRB session. 

{code:title=Windows JRuby 1.1b1}
>> Time.now
=> Mon Dec 03 02:57:57 ICT 2007
>> Time.parse("Mon Dec 03 01:27:38 +0700 2550")
=> Mon Dec 03 01:27:38 ICT 2550
>> Time.parse("Mon Dec 03 01:27:38 +0700 2007")
ArgumentError: time out of range
        from C:/Applications/JRuby/jruby/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1:in `binding'
>> Time.parse("Mon Dec 03 01:27:38 ICT 2550")
=> Mon Dec 03 01:27:38 ICT 2550
>> Time.parse("Mon Dec 03 01:27:38 ICT 2007")
ArgumentError: time out of range
        from C:/Applications/JRuby/jruby/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1:in `binding'
{code}

with trunk, behavior is same as 1.1b1 except {{Time.now}} now returns Thai 
calendar instead (so {{Time.parse(Time.now.to_s)}} doesn't raise 
{{ArgumentError: time out of range}} now)

{code:title=Windows JRuby 1.1 trunk}
>> Time.now
=> Mon Dec 03 03:00:56 +0700 2550
>> Time.parse("Mon Dec 03 01:27:38 +0700 2550")
=> Mon Dec 03 01:27:38 +0700 2550
>> Time.parse("Mon Dec 03 01:27:38 +0700 2007")
ArgumentError: time out of range
        from C:/Applications/JRuby/jruby/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1:in `signal_status'
>> Time.parse("Mon Dec 03 01:27:38 ICT 2550")
=> Mon Dec 03 01:27:38 +0700 2550
>> Time.parse("Mon Dec 03 01:27:38 ICT 2007")
ArgumentError: time out of range
        from C:/Applications/JRuby/jruby/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1:in `signal_status'
{code}

The behavior of MRI 1.8.6 is

{code:title=Windows MRI 1.8.6}
>> Time.now
=> Mon Dec 03 02:52:11 +0700 2007
>> Time.parse("Mon Dec 03 01:27:38 +0700 2550")
ArgumentError: time out of range
        from C:/Applications/Ruby/ruby/lib/ruby/1.8/time.rb:180:in `utc'
        from C:/Applications/Ruby/ruby/lib/ruby/1.8/time.rb:180:in `make_time'
        from C:/Applications/Ruby/ruby/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):2
>> Time.parse("Mon Dec 03 01:27:38 +0700 2007")
=> Mon Dec 03 01:27:38 +0700 2007
>> Time.parse("Mon Dec 03 01:27:38 ICT 2550")
ArgumentError: time out of range
        from C:/Applications/Ruby/ruby/lib/ruby/1.8/time.rb:184:in `local'
        from C:/Applications/Ruby/ruby/lib/ruby/1.8/time.rb:184:in `make_time'
        from C:/Applications/Ruby/ruby/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):4
>> Time.parse("Mon Dec 03 01:27:38 ICT 2007")
=> Mon Dec 03 01:27:38 +0700 2007
{code}

The tests also behave differently under Mac OS X with similar environment

{code:title=Mac OS X JRuby 1.1b1}
>> Time.now
=> Mon Dec 03 02:56:33 ICT 2007
>> Time.parse("Mon Dec 03 01:27:38 +0700 2550")
=> Thu Dec 03 01:27:38 ICT 2550
>> Time.parse("Mon Dec 03 01:27:38 +0700 2007")
=> Mon Dec 03 01:27:38 ICT 2007
>> Time.parse("Mon Dec 03 01:27:38 ICT 2550")
=> Thu Dec 03 01:27:38 ICT 2550
>> Time.parse("Mon Dec 03 01:27:38 ICT 2007")
=> Mon Dec 03 01:27:38 ICT 2007
{code}

and again different with trunk JRuby

{code:title=Mac OS X JRuby trunk}
> Time.now
=> Mon Dec 03 02:50:51 +0700 2007
>> Time.parse("Mon Dec 03 01:27:38 +0700 2550")
ArgumentError: time out of range
        from /Users/Sirn/Desktop/jruby-1.1b1/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1:in `signal_status'
>> Time.parse("Mon Dec 03 01:27:38 +0700 2007")
=> Mon Dec 03 01:27:38 +0700 2007
>> Time.parse("Mon Dec 03 01:27:38 ICT 2550")
ArgumentError: time out of range
        from /Users/Sirn/Desktop/jruby-1.1b1/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1:in `signal_status'
>> Time.parse("Mon Dec 03 01:27:38 ICT 2007")
=> Mon Dec 03 01:27:38 +0700 2007
{code}

but is the same one with MRI 1.8.6

{code:title=Mac OS X MRI 1.8.6}
>> Time.now
=> Mon Dec 03 02:51:28 +0700 2007
>> Time.parse("Mon Dec 03 01:27:38 +0700 2550")
ArgumentError: time out of range
        from /opt/local/lib/ruby/1.8/time.rb:180:in `utc'
        from /opt/local/lib/ruby/1.8/time.rb:180:in `make_time'
        from /opt/local/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):1
>> Time.parse("Mon Dec 03 01:27:38 +0700 2007")
=> Mon Dec 03 01:27:38 +0700 2007
>> Time.parse("Mon Dec 03 01:27:38 ICT 2550")
ArgumentError: time out of range
        from /opt/local/lib/ruby/1.8/time.rb:184:in `local'
        from /opt/local/lib/ruby/1.8/time.rb:184:in `make_time'
        from /opt/local/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):3
>> Time.parse("Mon Dec 03 01:27:38 ICT 2007")
=> Mon Dec 03 01:27:38 +0700 2007
{code}

headius asked me to execute this: {{jruby -e "require 'java'; puts 
java.util.Locale.getDefault.display_name"}} in IRC, the result are as follow:
*Mac OS X*: {{English}}
*Windows*: {{ไทย 
(ประเทศไทย)}} [trans: 
Thai (Thailand)]

even when {{Time.parse(Time.now.to_s)}} runs fine in Windows, {{rubygems}} 
still fail to start:

{code:title=Windows JRuby 1.1 trunk}
> gem
C:/Applications/JRuby/jruby/lib/ruby/1.8/time.rb:243:in `parse': time out of 
range (ArgumentError)
        from 
C:/Applications/JRuby/jruby/lib/ruby/site_ruby/1.8/rubygems/specification.rb:308:in
 `date='
        from 
C:/Applications/JRuby/jruby/lib/ruby/site_ruby/1.8/rubygems/specification.rb:302:in
 `date='
        from (eval):4:in `load_specification'
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to