1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/time.rb (Time.strptime): Raise ArgumentError if Date._strptime

doesn't extract date information.
  Reported by tadayoshi funaba.  [ruby-core:62349]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-05-05 02:47:53 +00:00
parent a72f9f3476
commit c2a87a1fa1
4 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,9 @@
Mon May 5 11:44:03 2014 Tanaka Akira <akr@fsij.org>
* lib/time.rb (Time.strptime): Raise ArgumentError if Date._strptime
doesn't extract date information.
Reported by tadayoshi funaba. [ruby-core:62349]
Mon May 5 01:12:27 2014 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c (rt_rewrite_frags): a new feature (not a

1
NEWS
View file

@ -77,6 +77,7 @@ with all sufficient information, see the ChangeLog file.
fixed-offset Time objects.
It is happen when usual localtime doesn't preserve the offset from UTC.
* Time.httpdate produces always UTC Time object.
* Time.strptime raises ArgumentError when no date information.
=== Built-in global variables compatibility issues

View file

@ -416,6 +416,9 @@ class Time
force_zone!(t, zone)
end
else
if !d[:year] && !d[:mon] && !d[:mday] && !d[:hour] && !d[:min] && !d[:sec] && !d[:sec_fraction]
raise ArgumentError, "no time information in #{date.inspect}"
end
year = d[:year]
year = yield(year) if year && block_given?
t = make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)

View file

@ -423,6 +423,11 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
assert_equal(false, Time.strptime('0', '%s').utc?)
end
def test_strptime_empty
assert_raise(ArgumentError) { Time.strptime('', '') }
assert_raise(ArgumentError) { Time.strptime('+09:00', '%z') }
end
def test_strptime_s_z
t = Time.strptime('0 +0100', '%s %z')
assert_equal(0, t.to_r)