0001-Fix-indentation.patch

Robert Speicher, 05/14/2011 05:40 AM

Download (18.7 KB)

View differences:

ext/date/lib/date.rb
215 215
  # month's numerical representation indexed into this array
216 216
  # gives the name of that month (hence the first element is nil).
217 217
  MONTHNAMES = [nil] + %w(January February March April May June July
218
			  August September October November December)
218
                          August September October November December)
219 219

  
220 220
  # Full names of days of the week, in English.  Days of the week
221 221
  # count from 0 to 6 (except in the commercial week); a day's numerical
......
224 224

  
225 225
  # Abbreviated month names, in English.
226 226
  ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun
227
			       Jul Aug Sep Oct Nov Dec)
227
                               Jul Aug Sep Oct Nov Dec)
228 228

  
229 229
  # Abbreviated day names, in English.
230 230
  ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
......
259 259
      when Infinity; return d <=> other.d
260 260
      when Numeric; return d
261 261
      else
262
	begin
263
	  l, r = other.coerce(self)
264
	  return l <=> r
265
	rescue NoMethodError
266
	end
262
        begin
263
          l, r = other.coerce(self)
264
          return l <=> r
265
        rescue NoMethodError
266
        end
267 267
      end
268 268
      nil
269 269
    end
......
272 272
      case other
273 273
      when Numeric; return -d, d
274 274
      else
275
	super
275
        super
276 276
      end
277 277
    end
278 278

  
279 279
    def to_f
280 280
      return 0 if @d == 0
281 281
      if @d > 0
282
	Float::INFINITY
282
        Float::INFINITY
283 283
      else
284
	-Float::INFINITY
284
        -Float::INFINITY
285 285
      end
286 286
    end
287 287

  
......
325 325
    def find_fdoy(y, sg) # :nodoc:
326 326
      j = nil
327 327
      1.upto(31) do |d|
328
	break if j = _valid_civil_r?(y, 1, d, sg)
328
        break if j = _valid_civil_r?(y, 1, d, sg)
329 329
      end
330 330
      j
331 331
    end
......
333 333
    def find_ldoy(y, sg) # :nodoc:
334 334
      j = nil
335 335
      31.downto(1) do |d|
336
	break if j = _valid_civil_r?(y, 12, d, sg)
336
        break if j = _valid_civil_r?(y, 12, d, sg)
337 337
      end
338 338
      j
339 339
    end
......
341 341
    def find_fdom(y, m, sg) # :nodoc:
342 342
      j = nil
343 343
      1.upto(31) do |d|
344
	break if j = _valid_civil_r?(y, m, d, sg)
344
        break if j = _valid_civil_r?(y, m, d, sg)
345 345
      end
346 346
      j
347 347
    end
......
349 349
    def find_ldom(y, m, sg) # :nodoc:
350 350
      j = nil
351 351
      31.downto(1) do |d|
352
	break if j = _valid_civil_r?(y, m, d, sg)
352
        break if j = _valid_civil_r?(y, m, d, sg)
353 353
      end
354 354
      j
355 355
    end
......
385 385
    # Returns the corresponding Julian Day Number.
386 386
    def civil_to_jd(y, m, d, sg=GREGORIAN) # :nodoc:
387 387
      if m <= 2
388
	y -= 1
389
	m += 12
388
        y -= 1
389
        m += 12
390 390
      end
391 391
      a = (y / 100.0).floor
392 392
      b = 2 - a + (a / 4.0).floor
393 393
      jd = (365.25 * (y + 4716)).floor +
394
	(30.6001 * (m + 1)).floor +
395
	d + b - 1524
394
        (30.6001 * (m + 1)).floor +
395
        d + b - 1524
396 396
      if jd < sg
397
	jd -= b
397
        jd -= b
398 398
      end
399 399
      jd
400 400
    end
......
407 407
    # as a three-element array.
408 408
    def jd_to_civil(jd, sg=GREGORIAN) # :nodoc:
409 409
      if jd < sg
410
	a = jd
410
        a = jd
411 411
      else
412
	x = ((jd - 1867216.25) / 36524.25).floor
413
	a = jd + 1 + x - (x / 4.0).floor
412
        x = ((jd - 1867216.25) / 36524.25).floor
413
        a = jd + 1 + x - (x / 4.0).floor
414 414
      end
415 415
      b = a + 1524
416 416
      c = ((b - 122.1) / 365.25).floor
......
418 418
      e = ((b - d) / 30.6001).floor
419 419
      dom = b - d - (30.6001 * e).floor
420 420
      if e <= 13
421
	m = e - 1
422
	y = c - 4716
421
        m = e - 1
422
        y = c - 4716
423 423
      else
424
	m = e - 13
425
	y = c - 4715
424
        m = e - 13
425
        y = c - 4715
426 426
      end
427 427
      return y, m, dom
428 428
    end
......
435 435
    def commercial_to_jd(y, w, d, sg=GREGORIAN) # :nodoc:
436 436
      j = find_fdoy(y, sg) + 3
437 437
      (j - (((j - 1) + 1) % 7)) +
438
	7 * (w - 1) +
439
	(d - 1)
438
        7 * (w - 1) +
439
        (d - 1)
440 440
    end
441 441

  
442 442
    # Convert a Julian Day Number to a Commercial Date
......
450 450
      a = jd_to_civil(jd - 3, sg)[0]
451 451
      j = commercial_to_jd(a + 1, 1, 1, sg)
452 452
      if jd >= j
453
	y = a + 1
453
        y = a + 1
454 454
      else
455
	j = commercial_to_jd(a, 1, 1, sg)
456
	y = a
455
        j = commercial_to_jd(a, 1, 1, sg)
456
        y = a
457 457
      end
458 458
      w = 1 + ((jd - j) / 7).floor
459 459
      d = (jd + 1) % 7
......
475 475

  
476 476
    def nth_kday_to_jd(y, m, n, k, sg=GREGORIAN) # :nodoc:
477 477
      j = if n > 0
478
	    find_fdom(y, m, sg) - 1
479
	  else
480
	    find_ldom(y, m, sg) + 7
481
	  end
478
            find_fdom(y, m, sg) - 1
479
          else
480
            find_ldom(y, m, sg) + 7
481
          end
482 482
      (j - (((j - k) + 1) % 7)) + 7 * n
483 483
    end
484 484

  
......
531 531
      Rational(Rational(1, 2), 2) # a challenge
532 532

  
533 533
      def time_to_day_fraction(h, min, s)
534
	Rational(h * 3600 + min * 60 + s, 86400) # 4p
534
        Rational(h * 3600 + min * 60 + s, 86400) # 4p
535 535
      end
536 536
    rescue
537 537
      def time_to_day_fraction(h, min, s)
538
	if Integer === h && Integer === min && Integer === s
539
	  Rational(h * 3600 + min * 60 + s, 86400) # 4p
540
	else
541
	  (h * 3600 + min * 60 + s).to_r/86400 # 4p
542
	end
538
        if Integer === h && Integer === min && Integer === s
539
          Rational(h * 3600 + min * 60 + s, 86400) # 4p
540
        else
541
          (h * 3600 + min * 60 + s).to_r/86400 # 4p
542
        end
543 543
      end
544 544
    end
545 545

  
......
593 593
    # +sg+ specifies the Day of Calendar Reform.
594 594
    def _valid_ordinal_r? (y, d, sg=GREGORIAN) # :nodoc:
595 595
      if d < 0
596
	return unless j = find_ldoy(y, sg)
597
	ny, nd = jd_to_ordinal(j + d + 1, sg)
598
	return unless ny == y
599
	d = nd
596
        return unless j = find_ldoy(y, sg)
597
        ny, nd = jd_to_ordinal(j + d + 1, sg)
598
        return unless ny == y
599
        d = nd
600 600
      end
601 601
      jd = ordinal_to_jd(y, d, sg)
602 602
      return unless [y, d] == jd_to_ordinal(jd, sg)
......
617 617
    # +sg+ specifies the Day of Calendar Reform.
618 618
    def _valid_civil_r? (y, m, d, sg=GREGORIAN) # :nodoc:
619 619
      if m < 0
620
	m += 13
620
        m += 13
621 621
      end
622 622
      if d < 0
623
	return unless j = find_ldom(y, m, sg)
624
	ny, nm, nd = jd_to_civil(j + d + 1, sg)
625
	return unless [ny, nm] == [y, m]
626
	d = nd
623
        return unless j = find_ldom(y, m, sg)
624
        ny, nm, nd = jd_to_civil(j + d + 1, sg)
625
        return unless [ny, nm] == [y, m]
626
        d = nd
627 627
      end
628 628
      jd = civil_to_jd(y, m, d, sg)
629 629
      return unless [y, m, d] == jd_to_civil(jd, sg)
......
646 646
    # +sg+ specifies the Day of Calendar Reform.
647 647
    def _valid_commercial_r? (y, w, d, sg=GREGORIAN) # :nodoc:
648 648
      if d < 0
649
	d += 8
649
        d += 8
650 650
      end
651 651
      if w < 0
652
	ny, nw, =
653
	  jd_to_commercial(commercial_to_jd(y + 1, 1, 1, sg) + w * 7, sg)
654
	return unless ny == y
655
	w = nw
652
        ny, nw, =
653
          jd_to_commercial(commercial_to_jd(y + 1, 1, 1, sg) + w * 7, sg)
654
        return unless ny == y
655
        w = nw
656 656
      end
657 657
      jd = commercial_to_jd(y, w, d, sg)
658 658
      return unless [y, w, d] == jd_to_commercial(jd, sg)
......
661 661

  
662 662
    def _valid_weeknum_r? (y, w, d, f, sg=GREGORIAN) # :nodoc:
663 663
      if d < 0
664
	d += 7
664
        d += 7
665 665
      end
666 666
      if w < 0
667
	ny, nw, =
668
	  jd_to_weeknum(weeknum_to_jd(y + 1, 1, f, f, sg) + w * 7, f, sg)
669
	return unless ny == y
670
	w = nw
667
        ny, nw, =
668
          jd_to_weeknum(weeknum_to_jd(y + 1, 1, f, f, sg) + w * 7, f, sg)
669
        return unless ny == y
670
        w = nw
671 671
      end
672 672
      jd = weeknum_to_jd(y, w, d, f, sg)
673 673
      return unless [y, w, d] == jd_to_weeknum(jd, f, sg)
......
676 676

  
677 677
    def _valid_nth_kday_r? (y, m, n, k, sg=GREGORIAN) # :nodoc:
678 678
      if k < 0
679
	k += 7
679
        k += 7
680 680
      end
681 681
      if n < 0
682
	ny, nm = (y * 12 + m).divmod(12)
683
	nm,    = (nm + 1)    .divmod(1)
684
	ny, nm, nn, =
685
	  jd_to_nth_kday(nth_kday_to_jd(ny, nm, 1, k, sg) + n * 7, sg)
686
	return unless [ny, nm] == [y, m]
687
	n = nn
682
        ny, nm = (y * 12 + m).divmod(12)
683
        nm,    = (nm + 1)    .divmod(1)
684
        ny, nm, nn, =
685
          jd_to_nth_kday(nth_kday_to_jd(ny, nm, 1, k, sg) + n * 7, sg)
686
        return unless [ny, nm] == [y, m]
687
        n = nn
688 688
      end
689 689
      jd = nth_kday_to_jd(y, m, n, k, sg)
690 690
      return unless [y, m, n, k] == jd_to_nth_kday(jd, sg)
......
705 705
      min += 60 if min < 0
706 706
      s   += 60 if s   < 0
707 707
      return unless ((0...24) === h &&
708
		     (0...60) === min &&
709
		     (0...60) === s) ||
710
		     (24 == h &&
711
		       0 == min &&
712
		       0 == s)
708
                     (0...60) === min &&
709
                     (0...60) === s) ||
710
                     (24 == h &&
711
                      0 == min &&
712
                      0 == s)
713 713
      time_to_day_fraction(h, min, s)
714 714
    end
715 715

  
......
734 734
  def self.new!(ajd=0, of=0, sg=ITALY)
735 735
    jd, df = ajd_to_jd(ajd, 0)
736 736
    if !(Fixnum === jd) ||
737
	jd < sg || df !=0 || of != 0 ||
737
        jd < sg || df !=0 || of != 0 ||
738 738
        jd < -327 || jd > 366963925
739 739
      return new_r!(ajd, of, sg)
740 740
    end
......
816 816
  def self.complete_frags(elem) # :nodoc:
817 817
    i = 0
818 818
    g = [[:time, [:hour, :min, :sec]],
819
	 [nil, [:jd]],
820
	 [:ordinal, [:year, :yday, :hour, :min, :sec]],
821
	 [:civil, [:year, :mon, :mday, :hour, :min, :sec]],
822
	 [:commercial, [:cwyear, :cweek, :cwday, :hour, :min, :sec]],
823
	 [:wday, [:wday, :hour, :min, :sec]],
824
	 [:wnum0, [:year, :wnum0, :wday, :hour, :min, :sec]],
825
	 [:wnum1, [:year, :wnum1, :wday, :hour, :min, :sec]],
826
	 [nil, [:cwyear, :cweek, :wday, :hour, :min, :sec]],
827
	 [nil, [:year, :wnum0, :cwday, :hour, :min, :sec]],
828
	 [nil, [:year, :wnum1, :cwday, :hour, :min, :sec]]].
819
        [nil, [:jd]],
820
        [:ordinal, [:year, :yday, :hour, :min, :sec]],
821
        [:civil, [:year, :mon, :mday, :hour, :min, :sec]],
822
        [:commercial, [:cwyear, :cweek, :cwday, :hour, :min, :sec]],
823
        [:wday, [:wday, :hour, :min, :sec]],
824
        [:wnum0, [:year, :wnum0, :wday, :hour, :min, :sec]],
825
        [:wnum1, [:year, :wnum1, :wday, :hour, :min, :sec]],
826
        [nil, [:cwyear, :cweek, :wday, :hour, :min, :sec]],
827
        [nil, [:year, :wnum0, :cwday, :hour, :min, :sec]],
828
        [nil, [:year, :wnum1, :cwday, :hour, :min, :sec]]].
829 829
      collect{|k, a| e = elem.values_at(*a).compact; [k, a, e]}.
830 830
      select{|k, a, e| e.size > 0}.
831 831
      sort_by{|k, a, e| [e.size, i -= 1]}.last
......
837 837

  
838 838
      case g[0]
839 839
      when :ordinal
840
	elem[:year] ||= d.year
841
	elem[:yday] ||= 1
840
        elem[:year] ||= d.year
841
        elem[:yday] ||= 1
842 842
      when :civil
843
	g[1].each do |e|
844
	  break if elem[e]
845
	  elem[e] = d.__send__(e)
846
	end
847
	elem[:mon]  ||= 1
848
	elem[:mday] ||= 1
843
        g[1].each do |e|
844
          break if elem[e]
845
          elem[e] = d.__send__(e)
846
        end
847
        elem[:mon]  ||= 1
848
        elem[:mday] ||= 1
849 849
      when :commercial
850
	g[1].each do |e|
851
	  break if elem[e]
852
	  elem[e] = d.__send__(e)
853
	end
854
	elem[:cweek] ||= 1
855
	elem[:cwday] ||= 1
850
        g[1].each do |e|
851
          break if elem[e]
852
          elem[e] = d.__send__(e)
853
        end
854
        elem[:cweek] ||= 1
855
        elem[:cwday] ||= 1
856 856
      when :wday
857
	elem[:jd] ||= (d - d.wday + elem[:wday]).jd
857
        elem[:jd] ||= (d - d.wday + elem[:wday]).jd
858 858
      when :wnum0
859
	g[1].each do |e|
860
	  break if elem[e]
861
	  elem[e] = d.__send__(e)
862
	end
863
	elem[:wnum0] ||= 0
864
	elem[:wday]  ||= 0
859
        g[1].each do |e|
860
          break if elem[e]
861
          elem[e] = d.__send__(e)
862
        end
863
        elem[:wnum0] ||= 0
864
        elem[:wday]  ||= 0
865 865
      when :wnum1
866
	g[1].each do |e|
867
	  break if elem[e]
868
	  elem[e] = d.__send__(e)
869
	end
870
	elem[:wnum1] ||= 0
871
	elem[:wday]  ||= 1
866
        g[1].each do |e|
867
          break if elem[e]
868
          elem[e] = d.__send__(e)
869
        end
870
        elem[:wnum1] ||= 0
871
        elem[:wday]  ||= 1
872 872
      end
873 873
    end
874 874

  
875 875
    if g && g[0] == :time
876 876
      if self <= DateTime
877
	d ||= Date.today
878
	elem[:jd] ||= d.jd
877
        d ||= Date.today
878
        elem[:jd] ||= d.jd
879 879
      end
880 880
    end
881 881

  
......
893 893
    catch :jd do
894 894
      a = elem.values_at(:jd)
895 895
      if a.all?
896
	if jd = _valid_jd_r?(*(a << sg))
897
	  throw :jd, jd
898
	end
896
        if jd = _valid_jd_r?(*(a << sg))
897
          throw :jd, jd
898
        end
899 899
      end
900 900

  
901 901
      a = elem.values_at(:year, :yday)
902 902
      if a.all?
903
	if jd = _valid_ordinal_r?(*(a << sg))
904
	  throw :jd, jd
905
	end
903
        if jd = _valid_ordinal_r?(*(a << sg))
904
          throw :jd, jd
905
        end
906 906
      end
907 907

  
908 908
      a = elem.values_at(:year, :mon, :mday)
909 909
      if a.all?
910
	if jd = _valid_civil_r?(*(a << sg))
911
	  throw :jd, jd
912
	end
910
        if jd = _valid_civil_r?(*(a << sg))
911
          throw :jd, jd
912
        end
913 913
      end
914 914

  
915 915
      a = elem.values_at(:cwyear, :cweek, :cwday)
916 916
      if a[2].nil? && elem[:wday]
917
	a[2] = elem[:wday].nonzero? || 7
917
        a[2] = elem[:wday].nonzero? || 7
918 918
      end
919 919
      if a.all?
920
	if jd = _valid_commercial_r?(*(a << sg))
921
	  throw :jd, jd
922
	end
920
        if jd = _valid_commercial_r?(*(a << sg))
921
          throw :jd, jd
922
        end
923 923
      end
924 924

  
925 925
      a = elem.values_at(:year, :wnum0, :wday)
926 926
      if a[2].nil? && elem[:cwday]
927
	a[2] = elem[:cwday] % 7
927
        a[2] = elem[:cwday] % 7
928 928
      end
929 929
      if a.all?
930
	if jd = _valid_weeknum_r?(*(a << 0 << sg))
931
	  throw :jd, jd
932
	end
930
        if jd = _valid_weeknum_r?(*(a << 0 << sg))
931
          throw :jd, jd
932
        end
933 933
      end
934 934

  
935 935
      a = elem.values_at(:year, :wnum1, :wday)
936 936
      if a[2]
937
	a[2] = (a[2] - 1) % 7
937
        a[2] = (a[2] - 1) % 7
938 938
      end
939 939
      if a[2].nil? && elem[:cwday]
940
	a[2] = (elem[:cwday] - 1) % 7
940
        a[2] = (elem[:cwday] - 1) % 7
941 941
      end
942 942
      if a.all?
943
	if jd = _valid_weeknum_r?(*(a << 1 << sg))
944
	  throw :jd, jd
945
	end
943
        if jd = _valid_weeknum_r?(*(a << 1 << sg))
944
          throw :jd, jd
945
        end
946 946
      end
947 947
    end
948 948
  end
......
1043 1043

  
1044 1044
    def once(*ids) # :nodoc: -- restricted
1045 1045
      for id in ids
1046
	module_eval <<-"end;"
1047
	  alias_method :__#{id.object_id}__, :#{id.to_s}
1048
	  private :__#{id.object_id}__
1049
	  def #{id.to_s}(*args)
1050
	    __ca__[#{id.object_id}] ||= __#{id.object_id}__(*args)
1051
	  end
1052
	end;
1046
        module_eval <<-"end;"
1047
          alias_method :__#{id.object_id}__, :#{id.to_s}
1048
          private :__#{id.object_id}__
1049
          def #{id.to_s}(*args)
1050
            __ca__[#{id.object_id}] ||= __#{id.object_id}__(*args)
1051
          end
1052
        end;
1053 1053
      end
1054 1054
    end # <<dummy
1055 1055

  
......
1166 1166

  
1167 1167
  def leap_r? # :nodoc:
1168 1168
    jd_to_civil(civil_to_jd(year, 3, 1, fix_style) - 1,
1169
		fix_style)[-1] == 29
1169
                fix_style)[-1] == 29
1170 1170
  end
1171 1171

  
1172 1172
  once :leap_r?
......
1207 1207
    case n
1208 1208
    when Numeric
1209 1209
      if Float === n
1210
	n = Rational((n * 86400000000000).round, 86400000000000)
1210
        n = Rational((n * 86400000000000).round, 86400000000000)
1211 1211
      end
1212 1212
      return self.class.new_r!(ajd + n, offset, start)
1213 1213
    end
......
1220 1220
    case x
1221 1221
    when Numeric
1222 1222
      if Float === x
1223
	x = Rational((x * 86400000000000).round, 86400000000000)
1223
        x = Rational((x * 86400000000000).round, 86400000000000)
1224 1224
      end
1225 1225
      return self.class.new_r!(ajd - x, offset, start)
1226 1226
    when Date
......
1253 1253
    when Date;    return jd == other.jd
1254 1254
    else
1255 1255
      begin
1256
	l, r = other.coerce(self)
1257
	return l === r
1256
        l, r = other.coerce(self)
1257
        return l === r
1258 1258
      rescue NoMethodError
1259 1259
      end
1260 1260
    end
......
1414 1414
    sf, ssf = (sf * 1000000000).divmod(1)
1415 1415
    odf, osf = (of * 86400).divmod(1)
1416 1416
    if !(Fixnum === jd) ||
1417
	jd < sg || ssf != 0 || osf != 0 ||
1417
        jd < sg || ssf != 0 || osf != 0 ||
1418 1418
        jd < -327 || jd > 366963925
1419 1419
      return new_r!(ajd, of, sg)
1420 1420
    end
......
1423 1423

  
1424 1424
  def self.jd_r(jd=0, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
1425 1425
    unless (jd = _valid_jd_r?(jd, sg)) &&
1426
	   (fr = _valid_time_r?(h, min, s))
1426
           (fr = _valid_time_r?(h, min, s))
1427 1427
      raise ArgumentError, 'invalid date'
1428 1428
    end
1429 1429
    if String === of
......
1438 1438

  
1439 1439
  def self.ordinal_r(y=-4712, d=1, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
1440 1440
    unless (jd = _valid_ordinal_r?(y, d, sg)) &&
1441
	   (fr = _valid_time_r?(h, min, s))
1441
           (fr = _valid_time_r?(h, min, s))
1442 1442
      raise ArgumentError, 'invalid date'
1443 1443
    end
1444 1444
    if String === of
......
1453 1453

  
1454 1454
  def self.civil_r(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
1455 1455
    unless (jd = _valid_civil_r?(y, m, d, sg)) &&
1456
	   (fr = _valid_time_r?(h, min, s))
1456
           (fr = _valid_time_r?(h, min, s))
1457 1457
      raise ArgumentError, 'invalid date'
1458 1458
    end
1459 1459
    if String === of
......
1468 1468

  
1469 1469
  def self.commercial_r(y=-4712, w=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
1470 1470
    unless (jd = _valid_commercial_r?(y, w, d, sg)) &&
1471
	   (fr = _valid_time_r?(h, min, s))
1471
           (fr = _valid_time_r?(h, min, s))
1472 1472
      raise ArgumentError, 'invalid date'
1473 1473
    end
1474 1474
    if String === of
......
1483 1483

  
1484 1484
  def self.weeknum(y=-4712, w=0, d=1, f=0, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
1485 1485
    unless (jd = _valid_weeknum_r?(y, w, d, f, sg)) &&
1486
	   (fr = _valid_time_r?(h, min, s))
1486
           (fr = _valid_time_r?(h, min, s))
1487 1487
      raise ArgumentError, 'invalid date'
1488 1488
    end
1489 1489
    if String === of
......
1498 1498

  
1499 1499
  def self.nth_kday(y=-4712, m=1, n=1, k=1, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
1500 1500
    unless (jd = _valid_nth_kday_r?(y, m, n, k, sg)) &&
1501
	   (fr = _valid_time_r?(h, min, s))
1501
           (fr = _valid_time_r?(h, min, s))
1502 1502
      raise ArgumentError, 'invalid date'
1503 1503
    end
1504 1504
    if String === of
......
1515 1515
    elem = rewrite_frags(elem)
1516 1516
    elem = complete_frags(elem)
1517 1517
    unless (jd = valid_date_frags?(elem, sg)) &&
1518
	   (fr = valid_time_frags?(elem))
1518
           (fr = valid_time_frags?(elem))
1519 1519
      raise ArgumentError, 'invalid date'
1520 1520
    end
1521 1521
    fr += (elem[:sec_fraction] || 0) / 86400
......
1593 1593

  
1594 1594
  def to_s_r # :nodoc: # 4p
1595 1595
    format('%.4d-%02d-%02dT%02d:%02d:%02d%s',
1596
	   year, mon, mday, hour, min, sec, zone)
1596
           year, mon, mday, hour, min, sec, zone)
1597 1597
  end
1598 1598

  
1599 1599
  private :to_s_r
......
1633 1633
  def to_time
1634 1634
    d = new_offset(0)
1635 1635
    d.instance_eval do
1636
      Time.utc(year, mon, mday, hour, min, sec +
1637
	       sec_fraction)
1636
      Time.utc(year, mon, mday, hour, min, sec + sec_fraction)
1638 1637
    end.
1639 1638
        getlocal
1640 1639
  end
1641
-