0001-datetime-fix-strptime-s-z.patch

Fix - Felipe Contreras, 05/02/2014 10:20 AM

Download (1.94 KB)

View differences:

ext/date/date_core.c
3663 3663
static VALUE
3664 3664
rt_rewrite_frags(VALUE hash)
3665 3665
{
3666
    VALUE seconds;
3666
    VALUE seconds, offset;
3667 3667

  
3668 3668
    seconds = ref_hash("seconds");
3669 3669
    if (!NIL_P(seconds)) {
3670 3670
	VALUE d, h, min, s, fr;
3671 3671

  
3672
	offset = ref_hash("offset");
3673
	if(!NIL_P(offset)) {
3674
	    seconds = f_add(seconds, offset);
3675
	}
3676

  
3672 3677
	d = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));
3673 3678
	fr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));
3674 3679

  
......
3687 3692
	set_hash("sec", s);
3688 3693
	set_hash("sec_fraction", fr);
3689 3694
	del_hash("seconds");
3690
	del_hash("offset");
3691 3695
    }
3692 3696
    return hash;
3693 3697
}
test/date/test_date_strptime.rb
310 310
		 DateTime.strptime('2002-03-14T11:22:33-09:00', '%FT%T%Z'))
311 311
    assert_equal(DateTime.new(2002,3,14,11,22,33, -9.to_r/24) + 123456789.to_r/1000000000/86400,
312 312
		 DateTime.strptime('2002-03-14T11:22:33.123456789-09:00', '%FT%T.%N%Z'))
313
    assert_equal(Rational(1, 24), DateTime.strptime('0 +0100', '%s %z').offset)
313 314
  end
314 315

  
315 316
  def test_strptime__2
316
-