Time.parse's "now" argument as nil works again.
* lib/time.rb (make_time): "now" argument as nil works again.
This is broken since Ruby 2.2.
Mathieu Jobin pointed a problem.
e4b05d91eb (commitcomment-17421387)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2d8841791f
commit
5fa7cdbde5
@ -1,3 +1,10 @@
|
|||||||
|
Sat Nov 5 22:51:06 2016 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/time.rb (make_time): "now" argument as nil works again.
|
||||||
|
This is broken since Ruby 2.2.
|
||||||
|
Mathieu Jobin pointed a problem.
|
||||||
|
https://github.com/ruby/ruby/commit/e4b05d91eb0d48fd172abf015c493bb42d755d07#commitcomment-17421387
|
||||||
|
|
||||||
Sat Nov 5 22:50:13 2016 Akinori MUSHA <knu@iDaemons.org>
|
Sat Nov 5 22:50:13 2016 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* lib/ipaddr.rb (IPAddr#==): If coercion fails, return false
|
* lib/ipaddr.rb (IPAddr#==): If coercion fails, return false
|
||||||
|
@ -254,15 +254,19 @@ class Time
|
|||||||
raise ArgumentError, "no time information in #{date.inspect}"
|
raise ArgumentError, "no time information in #{date.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
off_year = year || now.year
|
|
||||||
off = nil
|
off = nil
|
||||||
|
if year || now
|
||||||
|
off_year = year || now.year
|
||||||
off = zone_offset(zone, off_year) if zone
|
off = zone_offset(zone, off_year) if zone
|
||||||
|
end
|
||||||
|
|
||||||
|
if now
|
||||||
if off
|
if off
|
||||||
now = now.getlocal(off) if now.utc_offset != off
|
now = now.getlocal(off) if now.utc_offset != off
|
||||||
else
|
else
|
||||||
now = now.getlocal
|
now = now.getlocal
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
usec = nil
|
usec = nil
|
||||||
usec = sec_fraction * 1000000 if sec_fraction
|
usec = sec_fraction * 1000000 if sec_fraction
|
||||||
|
@ -338,6 +338,11 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
|||||||
assert_equal(t1.utc?, t2.utc?)
|
assert_equal(t1.utc?, t2.utc?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_parse_now_nil
|
||||||
|
assert_equal(Time.new(2000,1,1,0,0,0,"+11:00"),
|
||||||
|
Time.parse("2000-01-01T00:00:00+11:00", nil))
|
||||||
|
end
|
||||||
|
|
||||||
def test_parse_leap_second
|
def test_parse_leap_second
|
||||||
t = Time.utc(1998,12,31,23,59,59)
|
t = Time.utc(1998,12,31,23,59,59)
|
||||||
assert_equal(t, Time.parse("Thu Dec 31 23:59:59 UTC 1998"))
|
assert_equal(t, Time.parse("Thu Dec 31 23:59:59 UTC 1998"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user