Project

General

Profile

Bug #7445 ยป 0001-time-fix-strptime.patch

felipec (Felipe Contreras), 10/06/2013 10:17 AM

View differences:

lib/time.rb
393 393
      d = Date._strptime(date, format)
394 394
      raise ArgumentError, "invalid strptime format - `#{format}'" unless d
395 395
      if seconds = d[:seconds]
396
        Time.at(seconds)
396
        offset = d[:offset] || 0
397
        Time.at(seconds).localtime(offset)
397 398
      else
398 399
        year = d[:year]
399 400
        year = yield(year) if year && block_given?
test/test_time.rb
400 400
  def test_strptime
401 401
    assert_equal(Time.utc(2005, 8, 28, 06, 54, 20), Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z"))
402 402
    assert_equal(Time.at(1).localtime, Time.strptime("1", "%s"))
403
    assert_equal(0, Time.strptime('0', '%s').utc_offset)
404
    assert_equal(3600, Time.strptime('0 +0100', '%s %z').utc_offset)
403 405
  end
404 406

  
405 407
  def test_nsec
406
-