Index: test/testTime.rb =================================================================== --- test/testTime.rb (revision 4912) +++ test/testTime.rb (working copy) @@ -102,6 +102,10 @@ test_equal "12:00AM", Time.utc(2007,01,01,0,0).strftime("%I:%M%p") test_equal "12:00PM", Time.utc(2007,01,01,12,0).strftime("%I:%M%p") +# MRI only accepts usec arguments that fit in signed int +test_exception {Time.utc(2001,2,3,4,5,6,0x80000000)} +test_exception {Time.utc(2001,2,3,4,5,6,-0x80000001)} + # Time.utc accepts 8 arguments for compatibility with parsedate (two last arguments are ignored) test_no_exception {Time.utc(2007, 10, 10, 11, 55, 23, "-0200", 3)} Index: src/org/jruby/RubyTime.java =================================================================== --- src/org/jruby/RubyTime.java (revision 4912) +++ src/org/jruby/RubyTime.java (working copy) @@ -634,8 +634,8 @@ private static final String[] months = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}; - private static final long[] time_min = {1, 0, 0, 0, Long.MIN_VALUE}; - private static final long[] time_max = {31, 23, 59, 60, Long.MAX_VALUE}; + private static final int[] time_min = {1, 0, 0, 0, Integer.MIN_VALUE}; + private static final int[] time_max = {31, 23, 59, 60, Integer.MAX_VALUE}; private static final int ARG_SIZE = 7; private static RubyTime createTime(IRubyObject recv, IRubyObject[] args, boolean gmt) { @@ -699,10 +699,11 @@ if(!(args[i+2] instanceof RubyNumeric)) { args[i+2] = args[i+2].callMethod(tc,"to_i"); } - int_args[i] = (int)RubyNumeric.num2long(args[i + 2]); - if (time_min[i] > int_args[i] || int_args[i] > time_max[i]) { + long value = RubyNumeric.num2long(args[i + 2]); + if (time_min[i] > value || value > time_max[i]) { throw runtime.newArgumentError("Argument out of range."); } + int_args[i] = (int) value; } }