ruby-changes:11623
From: nobu <ko1@a...>
Date: Wed, 22 Apr 2009 20:25:40 +0900 (JST)
Subject: [ruby-changes:11623] Ruby:r23260 (trunk): * time.c (time_timespec): check out-of-range.
nobu 2009-04-22 20:25:26 +0900 (Wed, 22 Apr 2009) New Revision: 23260 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23260 Log: * time.c (time_timespec): check out-of-range. [ruby-core:23282] [Bug #1396] Modified files: trunk/ChangeLog trunk/time.c Index: time.c =================================================================== --- time.c (revision 23259) +++ time.c (revision 23260) @@ -1217,7 +1217,14 @@ if (f != t.tv_sec) { rb_raise(rb_eRangeError, "%f out of Time range", RFLOAT_VALUE(num)); } - t.tv_nsec = (long)(d*1e9+0.5); + t.tv_nsec = (int)(d*1e9+0.5); + if (t.tv_nsec >= 1000000000) { + t.tv_nsec -= 1000000000; + if (++t.tv_sec <= 0) { + --t.tv_nsec; + t.tv_nsec = 999999999; + } + } } break; Index: ChangeLog =================================================================== --- ChangeLog (revision 23259) +++ ChangeLog (revision 23260) @@ -1,6 +1,7 @@ -Wed Apr 22 19:33:13 2009 Tanaka Akira <akr@f...> +Wed Apr 22 20:25:24 2009 Nobuyoshi Nakada <nobu@r...> - * lib/time.rb (Time.parse): use year completion in Date._parse. + * time.c (time_timespec): check out-of-range. [ruby-core:23282] + [Bug #1396] Wed Apr 22 11:12:15 2009 NAKAMURA Usaku <usa@r...> -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/