bug-7445.patch

Charlie Somerville, 11/27/2012 10:33 PM

Download (1.34 KB)

View differences:

ext/date/date_core.c
3638 3638
static VALUE
3639 3639
rt_rewrite_frags(VALUE hash)
3640 3640
{
3641
    VALUE seconds;
3641
    VALUE seconds, offset;
3642 3642

  
3643 3643
    seconds = ref_hash("seconds");
3644 3644
    if (!NIL_P(seconds)) {
3645 3645
	VALUE d, h, min, s, fr;
3646 3646

  
3647
	offset = ref_hash("offset");
3648
	if(!NIL_P(offset)) {
3649
	    seconds = f_add(seconds, offset);
3650
	}
3651

  
3647 3652
	d = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));
3648 3653
	fr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));
3649 3654

  
......
3662 3667
	set_hash("sec", s);
3663 3668
	set_hash("sec_fraction", fr);
3664 3669
	del_hash("seconds");
3665
	del_hash("offset");
3666 3670
    }
3667 3671
    return hash;
3668 3672
}
test/date/test_date_strptime.rb
308 308
		 DateTime.strptime('2002-03-14T11:22:33.123456789-09:00', '%FT%T.%N%Z'))
309 309
  end
310 310

  
311
  def test_strptime_bug_7445
312
    d = DateTime.strptime('0 +0100', '%s %z')
313
    assert_equal Rational(1, 24), d.offset
314
    assert_equal 0, d.second
315
  end
316

  
311 317
  def test_strptime__2
312 318
    n = 10**9
313 319
    (Date.new(2006,6,1)..Date.new(2007,6,1)).each do |d|