home_run 1.0.7-x86-mingw32 → 1.0.9-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.0.9 (2013-03-19)
2
+
3
+ * Add Date::Infinity implementation (jeremyevans) (#50)
4
+
5
+ === 1.0.8 (2013-02-28)
6
+
7
+ * Switch %i to %d in format strings to work on ruby 2.0 (jeremyevans)
8
+
1
9
  === 1.0.7 (2012-08-08)
2
10
 
3
11
  * Make DateTime constructors handle fractional seconds in seconds argument (jeremyevans)
data/README.rdoc CHANGED
@@ -4,6 +4,14 @@ home_run is an implementation of ruby's Date/DateTime classes in C,
4
4
  with much better performance (20-200x) than the version in the
5
5
  standard library, while being almost completely compatible.
6
6
 
7
+ == Not necessary in 1.9.3+
8
+
9
+ Ruby 1.9.3+ replaced the old date library with one written in C,
10
+ based partially on the design of home_run (but implemented
11
+ differently). In most cases, if you are using Ruby 1.9.3+, you
12
+ will not need to use home_run.
13
+
14
+
7
15
  == Performance increase (microbenchmarks)
8
16
 
9
17
  The speedup you'll get depends mostly on your version of ruby, but
data/bench/cpu_bench.rb CHANGED
@@ -7,7 +7,7 @@ compare(".commercial"){|dc| n.times{dc.commercial(2010, 1, 1)}}
7
7
  compare(".gregorian_leap?"){|dc| n.times{dc.gregorian_leap?(2000)}}
8
8
  compare(".jd"){|dc| n.times{dc.jd(2010)}}
9
9
  compare(".julian_leap?"){|dc| n.times{dc.julian_leap?(2000)}}
10
- compare(".new!"){|dc| n.times{dc.new!(2012)}}
10
+ compare(".new!"){|dc| n.times{dc.new!(2012)}} if RUBY_VERSION < '1.9.3'
11
11
  compare(".ordinal"){|dc| n.times{dc.ordinal(2012, 100)}}
12
12
  compare(".parse"){|dc| n.times{dc.parse('2010-12-13')}}
13
13
  compare(".strptime"){|dc| n.times{dc.strptime('fri jan 5 00:00:00 2007', '%c')}}
@@ -22,7 +22,7 @@ dt_compare("._strptime"){|dc| n.times{dc._strptime('fri jan 5 13:43:37 2007', '%
22
22
  dt_compare(".civil"){|dc| n.times{dc.civil(2010, 1, 1, 13, 43, 57)}}
23
23
  dt_compare(".commercial"){|dc| n.times{dc.commercial(2010, 1, 1, 13, 43, 57)}}
24
24
  dt_compare(".jd"){|dc| n.times{dc.jd(2010, 13, 43, 57)}}
25
- dt_compare(".new!"){|dc| n.times{dc.new!(201013.3, -8/24.0)}}
25
+ dt_compare(".new!"){|dc| n.times{dc.new!(201013.3, -8/24.0)}} if RUBY_VERSION < '1.9.3'
26
26
  dt_compare(".now"){|dc| n.times{dc.now}}
27
27
  dt_compare(".ordinal"){|dc| n.times{dc.ordinal(2010, 1, 13, 43, 57)}}
28
28
  dt_compare(".parse"){|dc| n.times{dc.parse('2010-12-13T13:43:57+08:00')}}
@@ -257,7 +257,7 @@ int rhrd__valid_civil(rhrd_t *d, long year, long month, long day, int overlimit_
257
257
 
258
258
  if(!rhrd__valid_civil_limits(year, month, day)) {
259
259
  if (overlimit_raise == RHR_OVERLIMIT_RAISE) {
260
- rb_raise(rb_eRangeError, "date out of range: year = %li, month = %li, day = %li", year, month, day);
260
+ rb_raise(rb_eRangeError, "date out of range: year = %ld, month = %ld, day = %ld", year, month, day);
261
261
  }
262
262
  return 0;
263
263
  }
@@ -779,49 +779,49 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
779
779
  cp += sprintf(str + cp, "%s", rhrd__month_names[d->month]);
780
780
  break;
781
781
  case 'c':
782
- cp += sprintf(str + cp, "%s %s %2i %02i:%02i:%02i %04li", rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)], rhrd__abbr_month_names[d->month], (int)d->day, (int)d->hour, (int)d->minute, (int)d->second, d->year);
782
+ cp += sprintf(str + cp, "%s %s %2d %02d:%02d:%02d %04ld", rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)], rhrd__abbr_month_names[d->month], (int)d->day, (int)d->hour, (int)d->minute, (int)d->second, d->year);
783
783
  break;
784
784
  case 'C':
785
- cp += sprintf(str + cp, "%02li", d->year / 100);
785
+ cp += sprintf(str + cp, "%02ld", d->year / 100);
786
786
  break;
787
787
  case 'd':
788
- cp += sprintf(str + cp, "%02i", (int)d->day);
788
+ cp += sprintf(str + cp, "%02d", (int)d->day);
789
789
  break;
790
790
  case 'e':
791
- cp += sprintf(str + cp, "%2i", (int)d->day);
791
+ cp += sprintf(str + cp, "%2d", (int)d->day);
792
792
  break;
793
793
  case 'F':
794
- cp += sprintf(str + cp, "%04li-%02i-%02i", d->year, (int)d->month, (int)d->day);
794
+ cp += sprintf(str + cp, "%04ld-%02d-%02d", d->year, (int)d->month, (int)d->day);
795
795
  break;
796
796
  case 'g':
797
- cp += sprintf(str + cp, "%02li", cd.year % 100);
797
+ cp += sprintf(str + cp, "%02ld", cd.year % 100);
798
798
  break;
799
799
  case 'G':
800
- cp += sprintf(str + cp, "%04li", cd.year);
800
+ cp += sprintf(str + cp, "%04ld", cd.year);
801
801
  break;
802
802
  case 'H':
803
- cp += sprintf(str + cp, "%02i", (int)d->hour);
803
+ cp += sprintf(str + cp, "%02d", (int)d->hour);
804
804
  break;
805
805
  case 'I':
806
- cp += sprintf(str + cp, "%02i", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12));
806
+ cp += sprintf(str + cp, "%02d", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12));
807
807
  break;
808
808
  case 'j':
809
- cp += sprintf(str + cp, "%03li", rhrd__ordinal_day(d->year, d->month, d->day));
809
+ cp += sprintf(str + cp, "%03ld", rhrd__ordinal_day(d->year, d->month, d->day));
810
810
  break;
811
811
  case 'k':
812
- cp += sprintf(str + cp, "%2i", (int)(d->hour));
812
+ cp += sprintf(str + cp, "%2d", (int)(d->hour));
813
813
  break;
814
814
  case 'l':
815
- cp += sprintf(str + cp, "%2i", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12));
815
+ cp += sprintf(str + cp, "%2d", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12));
816
816
  break;
817
817
  case 'L':
818
818
  cp += sprintf(str + cp, "%03" PRId64, (d->nanos % RHR_NANOS_PER_SECOND)/1000000);
819
819
  break;
820
820
  case 'm':
821
- cp += sprintf(str + cp, "%02i", (int)(d->month));
821
+ cp += sprintf(str + cp, "%02d", (int)(d->month));
822
822
  break;
823
823
  case 'M':
824
- cp += sprintf(str + cp, "%02i", (int)(d->minute));
824
+ cp += sprintf(str + cp, "%02d", (int)(d->minute));
825
825
  break;
826
826
  case 'N':
827
827
  cp += sprintf(str + cp, "%09" PRId64, (d->nanos % RHR_NANOS_PER_SECOND));
@@ -839,60 +839,60 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
839
839
  cp += sprintf(str + cp, "%" PRId64, rhrd__jd_to_unix((long long)d->jd) * 1000 + d->nanos/RHR_NANOS_PER_MILLISECOND - d->offset * 60000);
840
840
  break;
841
841
  case 'r':
842
- cp += sprintf(str + cp, "%2i:%02i:%02i %s", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12), (int)d->minute, (int)d->second, d->hour >= 12 ? "PM" : "AM");
842
+ cp += sprintf(str + cp, "%2d:%02d:%02d %s", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12), (int)d->minute, (int)d->second, d->hour >= 12 ? "PM" : "AM");
843
843
  break;
844
844
  case 'R':
845
- cp += sprintf(str + cp, "%02i:%02i", (int)d->hour, (int)d->minute);
845
+ cp += sprintf(str + cp, "%02d:%02d", (int)d->hour, (int)d->minute);
846
846
  break;
847
847
  case 's':
848
848
  cp += sprintf(str + cp, "%" PRId64, rhrd__jd_to_unix((long long)d->jd) + d->nanos/RHR_NANOS_PER_SECOND - d->offset * 60);
849
849
  break;
850
850
  case 'S':
851
- cp += sprintf(str + cp, "%02i", (int)d->second);
851
+ cp += sprintf(str + cp, "%02d", (int)d->second);
852
852
  break;
853
853
  case 't':
854
854
  cp += sprintf(str + cp, "\t");
855
855
  break;
856
856
  case 'X':
857
857
  case 'T':
858
- cp += sprintf(str + cp, "%02i:%02i:%02i", (int)d->hour, (int)d->minute, (int)d->second);
858
+ cp += sprintf(str + cp, "%02d:%02d:%02d", (int)d->hour, (int)d->minute, (int)d->second);
859
859
  break;
860
860
  case 'u':
861
- cp += sprintf(str + cp, "%i", (int)cd.day);
861
+ cp += sprintf(str + cp, "%d", (int)cd.day);
862
862
  break;
863
863
  case 'U':
864
- cp += sprintf(str + cp, "%li", rhrd__jd_to_weeknum(d->jd, 0));
864
+ cp += sprintf(str + cp, "%ld", rhrd__jd_to_weeknum(d->jd, 0));
865
865
  break;
866
866
  case 'v':
867
- cp += sprintf(str + cp, "%2i-%s-%04li", (int)d->day, rhrd__abbr_month_names[d->month], d->year);
867
+ cp += sprintf(str + cp, "%2d-%s-%04ld", (int)d->day, rhrd__abbr_month_names[d->month], d->year);
868
868
  break;
869
869
  case 'V':
870
- cp += sprintf(str + cp, "%02i", (int)cd.month);
870
+ cp += sprintf(str + cp, "%02d", (int)cd.month);
871
871
  break;
872
872
  case 'w':
873
- cp += sprintf(str + cp, "%li", rhrd__jd_to_wday(d->jd));
873
+ cp += sprintf(str + cp, "%ld", rhrd__jd_to_wday(d->jd));
874
874
  break;
875
875
  case 'W':
876
- cp += sprintf(str + cp, "%li", rhrd__jd_to_weeknum(d->jd, 1));
876
+ cp += sprintf(str + cp, "%ld", rhrd__jd_to_weeknum(d->jd, 1));
877
877
  break;
878
878
  case 'D':
879
879
  case 'x':
880
- cp += sprintf(str + cp, "%02i/%02i/%02li", (int)d->month, (int)d->day, d->year % 100);
880
+ cp += sprintf(str + cp, "%02d/%02d/%02ld", (int)d->month, (int)d->day, d->year % 100);
881
881
  break;
882
882
  case 'y':
883
- cp += sprintf(str + cp, "%02li", d->year % 100);
883
+ cp += sprintf(str + cp, "%02ld", d->year % 100);
884
884
  break;
885
885
  case 'Y':
886
- cp += sprintf(str + cp, "%04li", d->year);
886
+ cp += sprintf(str + cp, "%04ld", d->year);
887
887
  break;
888
888
  case 'z':
889
- cp += sprintf(str + cp, "%+03i%02i", d->offset/60, abs(d->offset % 60));
889
+ cp += sprintf(str + cp, "%+03d%02d", d->offset/60, abs(d->offset % 60));
890
890
  break;
891
891
  case 'Z':
892
- cp += sprintf(str + cp, "%+03i:%02i", d->offset/60, abs(d->offset % 60));
892
+ cp += sprintf(str + cp, "%+03d:%02d", d->offset/60, abs(d->offset % 60));
893
893
  break;
894
894
  case '+':
895
- cp += sprintf(str + cp, "%s %s %2i %02i:%02i:%02i %+03i:%02i %04li", rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)], rhrd__abbr_month_names[d->month], (int)d->day, (int)d->hour, (int)d->minute, (int)d->second, d->offset/60, abs(d->offset % 60), d->year);
895
+ cp += sprintf(str + cp, "%s %s %2d %02d:%02d:%02d %+03d:%02d %04ld", rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)], rhrd__abbr_month_names[d->month], (int)d->day, (int)d->hour, (int)d->minute, (int)d->second, d->offset/60, abs(d->offset % 60), d->year);
896
896
  break;
897
897
  default:
898
898
  str[cp] = c;
@@ -1509,7 +1509,7 @@ static VALUE rhrd_s__strptime(int argc, VALUE *argv, VALUE klass) {
1509
1509
  case 1:
1510
1510
  break;
1511
1511
  default:
1512
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
1512
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
1513
1513
  break;
1514
1514
  }
1515
1515
 
@@ -1557,12 +1557,12 @@ static VALUE rhrd_s_civil(int argc, VALUE *argv, VALUE klass) {
1557
1557
  d->flags = RHR_HAVE_JD;
1558
1558
  return rd;
1559
1559
  default:
1560
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 4", argc);
1560
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 4", argc);
1561
1561
  break;
1562
1562
  }
1563
1563
 
1564
1564
  if (!rhrd__valid_civil(d, year, month, day, RHR_OVERLIMIT_RAISE)) {
1565
- rb_raise(rb_eArgError, "invalid date (year: %li, month: %li, day: %li)", year, month, day);
1565
+ rb_raise(rb_eArgError, "invalid date (year: %ld, month: %ld, day: %ld)", year, month, day);
1566
1566
  }
1567
1567
  return rd;
1568
1568
  }
@@ -1606,12 +1606,12 @@ static VALUE rhrd_s_commercial(int argc, VALUE *argv, VALUE klass) {
1606
1606
  break;
1607
1607
  #endif
1608
1608
  default:
1609
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 4", argc);
1609
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 4", argc);
1610
1610
  break;
1611
1611
  }
1612
1612
 
1613
1613
  if(!rhrd__valid_commercial(d, cwyear, cweek, cwday, RHR_OVERLIMIT_RAISE)) {
1614
- rb_raise(rb_eArgError, "invalid date (cwyear: %li, cweek: %li, cwday: %li)", cwyear, cweek, cwday);
1614
+ rb_raise(rb_eArgError, "invalid date (cwyear: %ld, cweek: %ld, cwday: %ld)", cwyear, cweek, cwday);
1615
1615
  }
1616
1616
  return rd;
1617
1617
  }
@@ -1645,7 +1645,7 @@ static VALUE rhrd_s_jd (int argc, VALUE *argv, VALUE klass) {
1645
1645
  d->jd = NUM2LONG(argv[0]);
1646
1646
  break;
1647
1647
  default:
1648
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 2", argc);
1648
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 2", argc);
1649
1649
  break;
1650
1650
  }
1651
1651
  RHR_CHECK_JD(d)
@@ -1683,7 +1683,7 @@ static VALUE rhrd_s_new_b(int argc, VALUE *argv, VALUE klass) {
1683
1683
  d->jd = NUM2LONG(argv[0]);
1684
1684
  break;
1685
1685
  default:
1686
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
1686
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
1687
1687
  break;
1688
1688
  }
1689
1689
  RHR_CHECK_JD(d)
@@ -1713,14 +1713,14 @@ static VALUE rhrd_s_ordinal(int argc, VALUE *argv, VALUE klass) {
1713
1713
  case 1:
1714
1714
  year = NUM2LONG(argv[0]);
1715
1715
  if(!rhrd__valid_ordinal(d, year, day, RHR_OVERLIMIT_RAISE)) {
1716
- rb_raise(rb_eArgError, "invalid date (year: %li, yday: %li)", year, day);
1716
+ rb_raise(rb_eArgError, "invalid date (year: %ld, yday: %ld)", year, day);
1717
1717
  }
1718
1718
  break;
1719
1719
  case 0:
1720
1720
  d->flags = RHR_HAVE_JD;
1721
1721
  return rd;
1722
1722
  default:
1723
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
1723
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
1724
1724
  break;
1725
1725
  }
1726
1726
 
@@ -1754,7 +1754,7 @@ static VALUE rhrd_s_parse(int argc, VALUE *argv, VALUE klass) {
1754
1754
  case 3:
1755
1755
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__parse, 2, argv[0], argv[1]));
1756
1756
  default:
1757
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 3)", argc);
1757
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)", argc);
1758
1758
  break;
1759
1759
  }
1760
1760
  }
@@ -1786,7 +1786,7 @@ static VALUE rhrd_s_strptime(int argc, VALUE *argv, VALUE klass) {
1786
1786
  argc = 2;
1787
1787
  break;
1788
1788
  default:
1789
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 3)", argc);
1789
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)", argc);
1790
1790
  break;
1791
1791
  }
1792
1792
 
@@ -1812,7 +1812,7 @@ static VALUE rhrd_s_today(int argc, VALUE *argv, VALUE klass) {
1812
1812
  case 1:
1813
1813
  break;
1814
1814
  default:
1815
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
1815
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
1816
1816
  break;
1817
1817
  }
1818
1818
 
@@ -1848,7 +1848,7 @@ static VALUE rhrd_s_valid_civil_q(int argc, VALUE *argv, VALUE klass) {
1848
1848
  }
1849
1849
  break;
1850
1850
  default:
1851
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 4", argc);
1851
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 4", argc);
1852
1852
  break;
1853
1853
  }
1854
1854
 
@@ -1888,7 +1888,7 @@ static VALUE rhrd_s_valid_commercial_q(int argc, VALUE *argv, VALUE klass) {
1888
1888
  }
1889
1889
  break;
1890
1890
  default:
1891
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 4", argc);
1891
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 4", argc);
1892
1892
  break;
1893
1893
  }
1894
1894
 
@@ -1913,7 +1913,7 @@ static VALUE rhrd_s_valid_jd_q(int argc, VALUE *argv, VALUE klass) {
1913
1913
  case 2:
1914
1914
  break;
1915
1915
  default:
1916
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 2", argc);
1916
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 2", argc);
1917
1917
  break;
1918
1918
  }
1919
1919
 
@@ -1952,7 +1952,7 @@ static VALUE rhrd_s_valid_ordinal_q(int argc, VALUE *argv, VALUE klass) {
1952
1952
  }
1953
1953
  break;
1954
1954
  default:
1955
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
1955
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
1956
1956
  break;
1957
1957
  }
1958
1958
 
@@ -2088,7 +2088,7 @@ static VALUE rhrd_asctime(VALUE self) {
2088
2088
  RHR_FILL_JD(d)
2089
2089
 
2090
2090
  s = rb_str_buf_new(128);
2091
- len = snprintf(RSTRING_PTR(s), 128, "%s %s %2i 00:00:00 %04li",
2091
+ len = snprintf(RSTRING_PTR(s), 128, "%s %s %2d 00:00:00 %04ld",
2092
2092
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
2093
2093
  rhrd__abbr_month_names[d->month],
2094
2094
  (int)d->day,
@@ -2336,7 +2336,7 @@ static VALUE rhrd_inspect(VALUE self) {
2336
2336
  RHR_FILL_CIVIL(d)
2337
2337
 
2338
2338
  s = rb_str_buf_new(128);
2339
- len = snprintf(RSTRING_PTR(s), 128, "#<Date %04li-%02i-%02i>",
2339
+ len = snprintf(RSTRING_PTR(s), 128, "#<Date %04ld-%02d-%02d>",
2340
2340
  d->year, (int)d->month, (int)d->day);
2341
2341
  if (len == -1 || len > 127) {
2342
2342
  rb_raise(rb_eNoMemError, "in Date#inspect (in snprintf)");
@@ -2457,7 +2457,7 @@ static VALUE rhrd_new_start(int argc, VALUE *argv, VALUE self) {
2457
2457
  case 1:
2458
2458
  break;
2459
2459
  default:
2460
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2460
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2461
2461
  break;
2462
2462
  }
2463
2463
 
@@ -2518,7 +2518,7 @@ static VALUE rhrd_step(int argc, VALUE *argv, VALUE self) {
2518
2518
  }
2519
2519
  break;
2520
2520
  default:
2521
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 2", argc);
2521
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 2", argc);
2522
2522
  break;
2523
2523
  }
2524
2524
  rlimit = argv[0];
@@ -2642,7 +2642,7 @@ static VALUE rhrd_strftime(int argc, VALUE *argv, VALUE self) {
2642
2642
  r = rb_str_to_str(argv[0]);
2643
2643
  break;
2644
2644
  default:
2645
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2645
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2646
2646
  break;
2647
2647
  }
2648
2648
 
@@ -2674,7 +2674,7 @@ static VALUE rhrd_to_s(VALUE self) {
2674
2674
  RHR_FILL_CIVIL(d)
2675
2675
 
2676
2676
  s = rb_str_buf_new(128);
2677
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02i",
2677
+ len = snprintf(RSTRING_PTR(s), 128, "%04ld-%02d-%02d",
2678
2678
  d->year, (int)d->month, (int)d->day);
2679
2679
  if (len == -1 || len > 127) {
2680
2680
  rb_raise(rb_eNoMemError, "in Date#to_s (in snprintf)");
@@ -3040,7 +3040,7 @@ static VALUE rhrd_s_httpdate(int argc, VALUE *argv, VALUE klass) {
3040
3040
  case 2:
3041
3041
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__httpdate, 1, argv[0]));
3042
3042
  default:
3043
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
3043
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
3044
3044
  break;
3045
3045
  }
3046
3046
  }
@@ -3074,7 +3074,7 @@ static VALUE rhrd_s_iso8601(int argc, VALUE *argv, VALUE klass) {
3074
3074
  case 2:
3075
3075
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__iso8601, 1, argv[0]));
3076
3076
  default:
3077
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
3077
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
3078
3078
  break;
3079
3079
  }
3080
3080
  }
@@ -3108,7 +3108,7 @@ static VALUE rhrd_s_jisx0301(int argc, VALUE *argv, VALUE klass) {
3108
3108
  case 2:
3109
3109
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__jisx0301, 1, argv[0]));
3110
3110
  default:
3111
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
3111
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
3112
3112
  break;
3113
3113
  }
3114
3114
  }
@@ -3142,7 +3142,7 @@ static VALUE rhrd_s_rfc2822(int argc, VALUE *argv, VALUE klass) {
3142
3142
  case 2:
3143
3143
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__rfc2822, 1, argv[0]));
3144
3144
  default:
3145
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
3145
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
3146
3146
  break;
3147
3147
  }
3148
3148
  }
@@ -3176,7 +3176,7 @@ static VALUE rhrd_s_rfc3339(int argc, VALUE *argv, VALUE klass) {
3176
3176
  case 2:
3177
3177
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__rfc3339, 1, argv[0]));
3178
3178
  default:
3179
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
3179
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
3180
3180
  break;
3181
3181
  }
3182
3182
  }
@@ -3210,7 +3210,7 @@ static VALUE rhrd_s_xmlschema(int argc, VALUE *argv, VALUE klass) {
3210
3210
  case 2:
3211
3211
  return rhrd__from_hash(klass, rb_funcall(klass, rhrd_id__xmlschema, 1, argv[0]));
3212
3212
  default:
3213
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
3213
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
3214
3214
  break;
3215
3215
  }
3216
3216
  }
@@ -3235,7 +3235,7 @@ static VALUE rhrd_httpdate(VALUE self) {
3235
3235
  RHR_FILL_JD(d)
3236
3236
 
3237
3237
  s = rb_str_buf_new(128);
3238
- len = snprintf(RSTRING_PTR(s), 128, "%s, %02i %s %04li 00:00:00 GMT",
3238
+ len = snprintf(RSTRING_PTR(s), 128, "%s, %02d %s %04ld 00:00:00 GMT",
3239
3239
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
3240
3240
  (int)d->day,
3241
3241
  rhrd__abbr_month_names[d->month],
@@ -3268,7 +3268,7 @@ static VALUE rhrd_jisx0301(VALUE self) {
3268
3268
 
3269
3269
  s = rb_str_buf_new(128);
3270
3270
  if (d->jd < 2405160) {
3271
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02i", d->year, (int)d->month, (int)d->day);
3271
+ len = snprintf(RSTRING_PTR(s), 128, "%04ld-%02d-%02d", d->year, (int)d->month, (int)d->day);
3272
3272
  } else {
3273
3273
  if (d->jd >= 2447535) {
3274
3274
  c = 'H';
@@ -3283,7 +3283,7 @@ static VALUE rhrd_jisx0301(VALUE self) {
3283
3283
  c = 'M';
3284
3284
  year = d->year - 1867;
3285
3285
  }
3286
- len = snprintf(RSTRING_PTR(s), 128, "%c%02li.%02i.%02i", c, year, (int)d->month, (int)d->day);
3286
+ len = snprintf(RSTRING_PTR(s), 128, "%c%02ld.%02d.%02d", c, year, (int)d->month, (int)d->day);
3287
3287
  }
3288
3288
  if (len == -1 || len > 127) {
3289
3289
  rb_raise(rb_eNoMemError, "in Date#jisx0301 (in snprintf)");
@@ -3315,7 +3315,7 @@ static VALUE rhrd_next_day(int argc, VALUE *argv, VALUE self) {
3315
3315
  i = NUM2LONG(argv[0]);
3316
3316
  break;
3317
3317
  default:
3318
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
3318
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
3319
3319
  break;
3320
3320
  }
3321
3321
 
@@ -3345,7 +3345,7 @@ static VALUE rhrd_next_month(int argc, VALUE *argv, VALUE self) {
3345
3345
  i = NUM2LONG(argv[0]);
3346
3346
  break;
3347
3347
  default:
3348
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
3348
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
3349
3349
  break;
3350
3350
  }
3351
3351
 
@@ -3375,7 +3375,7 @@ static VALUE rhrd_next_year(int argc, VALUE *argv, VALUE self) {
3375
3375
  i = NUM2LONG(argv[0]);
3376
3376
  break;
3377
3377
  default:
3378
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
3378
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
3379
3379
  break;
3380
3380
  }
3381
3381
 
@@ -3405,7 +3405,7 @@ static VALUE rhrd_prev_day(int argc, VALUE *argv, VALUE self) {
3405
3405
  i = -NUM2LONG(argv[0]);
3406
3406
  break;
3407
3407
  default:
3408
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
3408
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
3409
3409
  break;
3410
3410
  }
3411
3411
 
@@ -3435,7 +3435,7 @@ static VALUE rhrd_prev_month(int argc, VALUE *argv, VALUE self) {
3435
3435
  i = -NUM2LONG(argv[0]);
3436
3436
  break;
3437
3437
  default:
3438
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
3438
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
3439
3439
  break;
3440
3440
  }
3441
3441
 
@@ -3465,7 +3465,7 @@ static VALUE rhrd_prev_year(int argc, VALUE *argv, VALUE self) {
3465
3465
  i = -NUM2LONG(argv[0]);
3466
3466
  break;
3467
3467
  default:
3468
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
3468
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
3469
3469
  break;
3470
3470
  }
3471
3471
 
@@ -3490,7 +3490,7 @@ static VALUE rhrd_rfc2822(VALUE self) {
3490
3490
  RHR_FILL_JD(d)
3491
3491
 
3492
3492
  s = rb_str_buf_new(128);
3493
- len = snprintf(RSTRING_PTR(s), 128, "%s, %i %s %04li 00:00:00 +0000",
3493
+ len = snprintf(RSTRING_PTR(s), 128, "%s, %d %s %04ld 00:00:00 +0000",
3494
3494
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
3495
3495
  (int)d->day,
3496
3496
  rhrd__abbr_month_names[d->month],
@@ -3519,7 +3519,7 @@ static VALUE rhrd_rfc3339(VALUE self) {
3519
3519
  RHR_FILL_CIVIL(d)
3520
3520
 
3521
3521
  s = rb_str_buf_new(128);
3522
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02iT00:00:00+00:00", d->year, (int)d->month, (int)d->day);
3522
+ len = snprintf(RSTRING_PTR(s), 128, "%04ld-%02d-%02dT00:00:00+00:00", d->year, (int)d->month, (int)d->day);
3523
3523
  if (len == -1 || len > 127) {
3524
3524
  rb_raise(rb_eNoMemError, "in Date#rfc3339 (in snprintf)");
3525
3525
  }
@@ -3709,7 +3709,7 @@ static VALUE rhrd_s_ajd_to_jd(int argc, VALUE *argv, VALUE klass) {
3709
3709
  case 2:
3710
3710
  break;
3711
3711
  default:
3712
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 2", argc);
3712
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 2", argc);
3713
3713
  break;
3714
3714
  }
3715
3715
 
@@ -3746,7 +3746,7 @@ static VALUE rhrd_s_civil_to_jd(int argc, VALUE *argv, VALUE klass) {
3746
3746
  d.day = (unsigned char)NUM2LONG(argv[2]);
3747
3747
  break;
3748
3748
  default:
3749
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 4", argc);
3749
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 4", argc);
3750
3750
  break;
3751
3751
  }
3752
3752
  d.flags = RHR_HAVE_CIVIL;
@@ -3771,7 +3771,7 @@ static VALUE rhrd_s_commercial_to_jd(int argc, VALUE *argv, VALUE klass) {
3771
3771
  jd = rhrd__commercial_to_jd(NUM2LONG(argv[0]), NUM2LONG(argv[1]), NUM2LONG(argv[2]));
3772
3772
  break;
3773
3773
  default:
3774
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 4", argc);
3774
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 4", argc);
3775
3775
  break;
3776
3776
  }
3777
3777
 
@@ -3830,7 +3830,7 @@ static VALUE rhrd_s_jd_to_ajd(int argc, VALUE *argv, VALUE klass) {
3830
3830
  case 3:
3831
3831
  break;
3832
3832
  default:
3833
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
3833
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
3834
3834
  break;
3835
3835
  }
3836
3836
  return argv[0];
@@ -3853,7 +3853,7 @@ static VALUE rhrd_s_jd_to_civil(int argc, VALUE *argv, VALUE klass) {
3853
3853
  d.jd = NUM2LONG(argv[0]);
3854
3854
  break;
3855
3855
  default:
3856
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
3856
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
3857
3857
  break;
3858
3858
  }
3859
3859
  RHR_FILL_CIVIL(&d)
@@ -3877,7 +3877,7 @@ static VALUE rhrd_s_jd_to_commercial(int argc, VALUE *argv, VALUE klass) {
3877
3877
  d.jd = NUM2LONG(argv[0]);
3878
3878
  break;
3879
3879
  default:
3880
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
3880
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
3881
3881
  break;
3882
3882
  }
3883
3883
  rhrd__fill_commercial(&d);
@@ -3922,7 +3922,7 @@ static VALUE rhrd_s_jd_to_ordinal(int argc, VALUE *argv, VALUE klass) {
3922
3922
  d.jd = NUM2LONG(argv[0]);
3923
3923
  break;
3924
3924
  default:
3925
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
3925
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
3926
3926
  break;
3927
3927
  }
3928
3928
  RHR_FILL_CIVIL(&d)
@@ -3991,7 +3991,7 @@ static VALUE rhrd_s_ordinal_to_jd(int argc, VALUE *argv, VALUE klass) {
3991
3991
  return LONG2NUM(rhrd__ymd_to_jd(NUM2LONG(argv[0]), 1, NUM2LONG(argv[1])));
3992
3992
  break;
3993
3993
  default:
3994
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
3994
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
3995
3995
  break;
3996
3996
  }
3997
3997
  }
@@ -133,8 +133,8 @@ so that no calculations can overflow.
133
133
 
134
134
  #define RHR_SPACE_SHIP(x, l, r) if (l < r) { x = -1; } else if (l == r) { x = 0; } else { x = 1; }
135
135
 
136
- #define RHR_CHECK_JD(d) if ((d->jd > RHR_JD_MAX) || (d->jd < RHR_JD_MIN)) { rb_raise(rb_eRangeError, "date out of range: jd = %li", d->jd);}
137
- #define RHR_CHECK_CIVIL(d) if (!rhrd__valid_civil_limits(d->year, d->month, d->day)) { rb_raise(rb_eRangeError, "date out of range: year = %li, month = %i, day = %i", d->year, (int)d->month, (int)d->day);}
136
+ #define RHR_CHECK_JD(d) if ((d->jd > RHR_JD_MAX) || (d->jd < RHR_JD_MIN)) { rb_raise(rb_eRangeError, "date out of range: jd = %ld", d->jd);}
137
+ #define RHR_CHECK_CIVIL(d) if (!rhrd__valid_civil_limits(d->year, d->month, d->day)) { rb_raise(rb_eRangeError, "date out of range: year = %ld, month = %d, day = %d", d->year, (int)d->month, (int)d->day);}
138
138
 
139
139
  #define RHR_CACHED_IV(self, iv) VALUE v = rb_ivar_get(self, iv); if (RTEST(v)) {return v;}
140
140
 
@@ -102,7 +102,7 @@ int rhrdt__valid_civil(rhrdt_t *dt, long year, long month, long day) {
102
102
  }
103
103
 
104
104
  if(!rhrd__valid_civil_limits(year, month, day)) {
105
- rb_raise(rb_eRangeError, "datetime out of range: year = %li, month = %li, day = %li", year, month, day);
105
+ rb_raise(rb_eRangeError, "datetime out of range: year = %ld, month = %ld, day = %ld", year, month, day);
106
106
  }
107
107
 
108
108
  dt->year = year;
@@ -607,7 +607,7 @@ static VALUE rhrdt_s__strptime(int argc, VALUE *argv, VALUE klass) {
607
607
  case 1:
608
608
  break;
609
609
  default:
610
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
610
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
611
611
  break;
612
612
  }
613
613
 
@@ -670,12 +670,12 @@ static VALUE rhrdt_s_civil(int argc, VALUE *argv, VALUE klass) {
670
670
  year = NUM2LONG(argv[0]);
671
671
  break;
672
672
  default:
673
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 8", argc);
673
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 8", argc);
674
674
  break;
675
675
  }
676
676
 
677
677
  if (!rhrdt__valid_civil(dt, year, month, day)) {
678
- rb_raise(rb_eArgError, "invalid date (year: %li, month: %li, day: %li)", year, month, day);
678
+ rb_raise(rb_eArgError, "invalid date (year: %ld, month: %ld, day: %ld)", year, month, day);
679
679
  }
680
680
  rhrdt__set_time_nanos(dt, hour, minute, second, nanos, offset);
681
681
  return rdt;
@@ -734,11 +734,11 @@ static VALUE rhrdt_s_commercial(int argc, VALUE *argv, VALUE klass) {
734
734
  break;
735
735
  #endif
736
736
  default:
737
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 8", argc);
737
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 8", argc);
738
738
  break;
739
739
  }
740
740
  if(!rhrdt__valid_commercial(dt, cwyear, cweek, cwday)) {
741
- rb_raise(rb_eArgError, "invalid date (cwyear: %li, cweek: %li, cwday: %li)", cwyear, cweek, cwday);
741
+ rb_raise(rb_eArgError, "invalid date (cwyear: %ld, cweek: %ld, cwday: %ld)", cwyear, cweek, cwday);
742
742
  }
743
743
  rhrdt__set_time_nanos(dt, hour, minute, second, nanos, offset);
744
744
  return rdt;
@@ -782,7 +782,7 @@ static VALUE rhrdt_s_jd(int argc, VALUE *argv, VALUE klass) {
782
782
  dt->jd = NUM2LONG(argv[0]);
783
783
  break;
784
784
  default:
785
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 6", argc);
785
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 6", argc);
786
786
  break;
787
787
  }
788
788
 
@@ -835,7 +835,7 @@ static VALUE rhrdt_s_new_b(int argc, VALUE *argv, VALUE klass) {
835
835
  dt->flags = RHR_HAVE_JD | RHR_HAVE_NANOS;
836
836
  break;
837
837
  default:
838
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 3", argc);
838
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 3", argc);
839
839
  break;
840
840
  }
841
841
 
@@ -859,7 +859,7 @@ static VALUE rhrdt_s_now(int argc, VALUE *argv, VALUE klass) {
859
859
  case 1:
860
860
  break;
861
861
  default:
862
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
862
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
863
863
  break;
864
864
  }
865
865
 
@@ -908,13 +908,13 @@ static VALUE rhrdt_s_ordinal(int argc, VALUE *argv, VALUE klass) {
908
908
  dt->flags = RHR_HAVE_JD | RHR_HAVE_NANOS | RHR_HAVE_HMS;
909
909
  return rdt;
910
910
  default:
911
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 7", argc);
911
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 7", argc);
912
912
  break;
913
913
  }
914
914
 
915
915
  if(!rhrdt__valid_ordinal(dt, year, day)) {
916
916
  RHR_CHECK_JD(dt)
917
- rb_raise(rb_eArgError, "invalid date (year: %li, yday: %li)", year, day);
917
+ rb_raise(rb_eArgError, "invalid date (year: %ld, yday: %ld)", year, day);
918
918
  }
919
919
  rhrdt__set_time_nanos(dt, hour, minute, second, nanos, offset);
920
920
  return rdt;
@@ -948,7 +948,7 @@ static VALUE rhrdt_s_parse(int argc, VALUE *argv, VALUE klass) {
948
948
  rhrdt__fill_from_hash(dt, rb_funcall(klass, rhrd_id__parse, 2, argv[0], argv[1]));
949
949
  break;
950
950
  default:
951
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 3)", argc);
951
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)", argc);
952
952
  break;
953
953
  }
954
954
 
@@ -980,7 +980,7 @@ static VALUE rhrdt_s_strptime(int argc, VALUE *argv, VALUE klass) {
980
980
  case 2:
981
981
  break;
982
982
  default:
983
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 3)", argc);
983
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)", argc);
984
984
  break;
985
985
  }
986
986
 
@@ -1050,7 +1050,7 @@ static VALUE rhrdt_asctime(VALUE self) {
1050
1050
  RHRDT_FILL_HMS(d)
1051
1051
 
1052
1052
  s = rb_str_buf_new(128);
1053
- len = snprintf(RSTRING_PTR(s), 128, "%s %s %2i %02i:%02i:%02i %04li",
1053
+ len = snprintf(RSTRING_PTR(s), 128, "%s %s %2d %02d:%02d:%02d %04ld",
1054
1054
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
1055
1055
  rhrd__abbr_month_names[d->month],
1056
1056
  (int)d->day, (int)d->hour, (int)d->minute, (int)d->second,
@@ -1303,7 +1303,7 @@ static VALUE rhrdt_inspect(VALUE self) {
1303
1303
  RHRDT_FILL_HMS(dt)
1304
1304
 
1305
1305
  s = rb_str_buf_new(128);
1306
- len = snprintf(RSTRING_PTR(s), 128, "#<DateTime %04li-%02i-%02iT%02i:%02i:%02i%+03i:%02i>",
1306
+ len = snprintf(RSTRING_PTR(s), 128, "#<DateTime %04ld-%02d-%02dT%02d:%02d:%02d%+03d:%02d>",
1307
1307
  dt->year, (int)dt->month, (int)dt->day, (int)dt->hour, (int)dt->minute, (int)dt->second, dt->offset/60, abs(dt->offset % 60));
1308
1308
  if (len == -1 || len > 127) {
1309
1309
  rb_raise(rb_eNoMemError, "in DateTime#inspect (in snprintf)");
@@ -1431,7 +1431,7 @@ static VALUE rhrdt_new_offset(int argc, VALUE *argv, VALUE self) {
1431
1431
  offset= rhrdt__constructor_offset(rb_obj_class(self), argv[0]);
1432
1432
  break;
1433
1433
  default:
1434
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
1434
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
1435
1435
  break;
1436
1436
  }
1437
1437
  return rhrdt__new_offset(self, offset);
@@ -1560,7 +1560,7 @@ static VALUE rhrdt_step(int argc, VALUE *argv, VALUE self) {
1560
1560
  }
1561
1561
  break;
1562
1562
  default:
1563
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 2", argc);
1563
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 2", argc);
1564
1564
  break;
1565
1565
  }
1566
1566
  rlimit = argv[0];
@@ -1648,7 +1648,7 @@ static VALUE rhrdt_strftime(int argc, VALUE *argv, VALUE self) {
1648
1648
  r = rb_str_to_str(argv[0]);
1649
1649
  break;
1650
1650
  default:
1651
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
1651
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
1652
1652
  break;
1653
1653
  }
1654
1654
 
@@ -1677,7 +1677,7 @@ static VALUE rhrdt_to_s(VALUE self) {
1677
1677
  RHRDT_FILL_HMS(dt)
1678
1678
 
1679
1679
  s = rb_str_buf_new(128);
1680
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02iT%02i:%02i:%02i%+03i:%02i",
1680
+ len = snprintf(RSTRING_PTR(s), 128, "%04ld-%02d-%02dT%02d:%02d:%02d%+03d:%02d",
1681
1681
  dt->year, (int)dt->month, (int)dt->day, (int)dt->hour, (int)dt->minute, (int)dt->second, dt->offset/60, abs(dt->offset % 60));
1682
1682
  if (len == -1 || len > 127) {
1683
1683
  rb_raise(rb_eNoMemError, "in DateTime#to_s (in snprintf)");
@@ -1769,7 +1769,7 @@ static VALUE rhrdt_zone(VALUE self) {
1769
1769
  Data_Get_Struct(self, rhrdt_t, dt);
1770
1770
 
1771
1771
  s = rb_str_buf_new(128);
1772
- len = snprintf(RSTRING_PTR(s), 128, "%+03i:%02i", dt->offset/60, abs(dt->offset % 60));
1772
+ len = snprintf(RSTRING_PTR(s), 128, "%+03d:%02d", dt->offset/60, abs(dt->offset % 60));
1773
1773
  if (len == -1 || len > 127) {
1774
1774
  rb_raise(rb_eNoMemError, "in DateTime#zone (in snprintf)");
1775
1775
  }
@@ -1988,7 +1988,7 @@ long rhrdt__add_iso_time_format(rhrdt_t *dt, char *str, long len, long i) {
1988
1988
  i = 9;
1989
1989
  }
1990
1990
 
1991
- l = snprintf(str + len, (size_t)(128 - len), "T%02i:%02i:%02i", (int)dt->hour, (int)dt->minute, (int)dt->second);
1991
+ l = snprintf(str + len, (size_t)(128 - len), "T%02d:%02d:%02d", (int)dt->hour, (int)dt->minute, (int)dt->second);
1992
1992
  if (l == -1 || l > 127) {
1993
1993
  rb_raise(rb_eNoMemError, "in DateTime formatting method (in snprintf)");
1994
1994
  }
@@ -2003,7 +2003,7 @@ long rhrdt__add_iso_time_format(rhrdt_t *dt, char *str, long len, long i) {
2003
2003
  len += i + 1;
2004
2004
  }
2005
2005
 
2006
- l = snprintf(str + len, (size_t)(128 - len), "%+03i:%02i", dt->offset/60, abs(dt->offset % 60));
2006
+ l = snprintf(str + len, (size_t)(128 - len), "%+03d:%02d", dt->offset/60, abs(dt->offset % 60));
2007
2007
  if (l == -1 || l > 127) {
2008
2008
  rb_raise(rb_eNoMemError, "in DateTime formatting method (in snprintf)");
2009
2009
  }
@@ -2043,7 +2043,7 @@ static VALUE rhrdt_s_httpdate(int argc, VALUE *argv, VALUE klass) {
2043
2043
  rhrdt__fill_from_hash(d, rb_funcall(klass, rhrd_id__httpdate, 1, argv[0]));
2044
2044
  return rd;
2045
2045
  default:
2046
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
2046
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
2047
2047
  break;
2048
2048
  }
2049
2049
  }
@@ -2078,7 +2078,7 @@ static VALUE rhrdt_s_iso8601(int argc, VALUE *argv, VALUE klass) {
2078
2078
  rhrdt__fill_from_hash(d, rb_funcall(klass, rhrd_id__iso8601, 1, argv[0]));
2079
2079
  return rd;
2080
2080
  default:
2081
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
2081
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
2082
2082
  break;
2083
2083
  }
2084
2084
  }
@@ -2113,7 +2113,7 @@ static VALUE rhrdt_s_jisx0301(int argc, VALUE *argv, VALUE klass) {
2113
2113
  rhrdt__fill_from_hash(d, rb_funcall(klass, rhrd_id__jisx0301, 1, argv[0]));
2114
2114
  return rd;
2115
2115
  default:
2116
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
2116
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
2117
2117
  break;
2118
2118
  }
2119
2119
  }
@@ -2148,7 +2148,7 @@ static VALUE rhrdt_s_rfc2822(int argc, VALUE *argv, VALUE klass) {
2148
2148
  rhrdt__fill_from_hash(d, rb_funcall(klass, rhrd_id__rfc2822, 1, argv[0]));
2149
2149
  return rd;
2150
2150
  default:
2151
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
2151
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
2152
2152
  break;
2153
2153
  }
2154
2154
  }
@@ -2183,7 +2183,7 @@ static VALUE rhrdt_s_rfc3339(int argc, VALUE *argv, VALUE klass) {
2183
2183
  rhrdt__fill_from_hash(d, rb_funcall(klass, rhrd_id__rfc3339, 1, argv[0]));
2184
2184
  return rd;
2185
2185
  default:
2186
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
2186
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
2187
2187
  break;
2188
2188
  }
2189
2189
  }
@@ -2218,7 +2218,7 @@ static VALUE rhrdt_s_xmlschema(int argc, VALUE *argv, VALUE klass) {
2218
2218
  rhrdt__fill_from_hash(d, rb_funcall(klass, rhrd_id__xmlschema, 1, argv[0]));
2219
2219
  return rd;
2220
2220
  default:
2221
- rb_raise(rb_eArgError, "wrong number of arguments (%i for 2)", argc);
2221
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
2222
2222
  break;
2223
2223
  }
2224
2224
  }
@@ -2245,7 +2245,7 @@ static VALUE rhrdt_httpdate(VALUE self) {
2245
2245
  RHRDT_FILL_HMS(d)
2246
2246
 
2247
2247
  s = rb_str_buf_new(128);
2248
- len = snprintf(RSTRING_PTR(s), 128, "%s, %02i %s %04li %02i:%02i:%02i GMT",
2248
+ len = snprintf(RSTRING_PTR(s), 128, "%s, %02d %s %04ld %02d:%02d:%02d GMT",
2249
2249
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
2250
2250
  (int)d->day,
2251
2251
  rhrd__abbr_month_names[d->month],
@@ -2288,14 +2288,14 @@ static VALUE rhrdt_iso8601(int argc, VALUE *argv, VALUE self) {
2288
2288
  i = 0;
2289
2289
  break;
2290
2290
  default:
2291
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2291
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2292
2292
  break;
2293
2293
  }
2294
2294
 
2295
2295
  s = rb_str_buf_new(128);
2296
2296
  str = RSTRING_PTR(s);
2297
2297
 
2298
- len = snprintf(str, 128, "%04li-%02i-%02i", dt->year, (int)dt->month, (int)dt->day);
2298
+ len = snprintf(str, 128, "%04ld-%02d-%02d", dt->year, (int)dt->month, (int)dt->day);
2299
2299
  if (len == -1 || len > 127) {
2300
2300
  rb_raise(rb_eNoMemError, "in DateTime#to_s (in snprintf)");
2301
2301
  }
@@ -2338,7 +2338,7 @@ static VALUE rhrdt_jisx0301(int argc, VALUE *argv, VALUE self) {
2338
2338
  i = 0;
2339
2339
  break;
2340
2340
  default:
2341
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2341
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2342
2342
  break;
2343
2343
  }
2344
2344
 
@@ -2346,7 +2346,7 @@ static VALUE rhrdt_jisx0301(int argc, VALUE *argv, VALUE self) {
2346
2346
  str = RSTRING_PTR(s);
2347
2347
 
2348
2348
  if (d->jd < 2405160) {
2349
- len = snprintf(str, 128, "%04li-%02i-%02i", d->year, (int)d->month, (int)d->day);
2349
+ len = snprintf(str, 128, "%04ld-%02d-%02d", d->year, (int)d->month, (int)d->day);
2350
2350
  } else {
2351
2351
  if (d->jd >= 2447535) {
2352
2352
  c = 'H';
@@ -2361,7 +2361,7 @@ static VALUE rhrdt_jisx0301(int argc, VALUE *argv, VALUE self) {
2361
2361
  c = 'M';
2362
2362
  year = d->year - 1867;
2363
2363
  }
2364
- len = snprintf(RSTRING_PTR(s), 128, "%c%02li.%02i.%02i", c, year, (int)d->month, (int)d->day);
2364
+ len = snprintf(RSTRING_PTR(s), 128, "%c%02ld.%02d.%02d", c, year, (int)d->month, (int)d->day);
2365
2365
  }
2366
2366
  if (len == -1 || len > 127) {
2367
2367
  rb_raise(rb_eNoMemError, "in DateTime#jisx0301 (in snprintf)");
@@ -2395,7 +2395,7 @@ static VALUE rhrdt_next_day(int argc, VALUE *argv, VALUE self) {
2395
2395
  i = NUM2LONG(argv[0]);
2396
2396
  break;
2397
2397
  default:
2398
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2398
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2399
2399
  break;
2400
2400
  }
2401
2401
 
@@ -2426,7 +2426,7 @@ static VALUE rhrdt_next_month(int argc, VALUE *argv, VALUE self) {
2426
2426
  i = NUM2LONG(argv[0]);
2427
2427
  break;
2428
2428
  default:
2429
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2429
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2430
2430
  break;
2431
2431
  }
2432
2432
 
@@ -2457,7 +2457,7 @@ static VALUE rhrdt_next_year(int argc, VALUE *argv, VALUE self) {
2457
2457
  i = NUM2LONG(argv[0]);
2458
2458
  break;
2459
2459
  default:
2460
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2460
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2461
2461
  break;
2462
2462
  }
2463
2463
 
@@ -2488,7 +2488,7 @@ static VALUE rhrdt_prev_day(int argc, VALUE *argv, VALUE self) {
2488
2488
  i = -NUM2LONG(argv[0]);
2489
2489
  break;
2490
2490
  default:
2491
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2491
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2492
2492
  break;
2493
2493
  }
2494
2494
 
@@ -2519,7 +2519,7 @@ static VALUE rhrdt_prev_month(int argc, VALUE *argv, VALUE self) {
2519
2519
  i = -NUM2LONG(argv[0]);
2520
2520
  break;
2521
2521
  default:
2522
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2522
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2523
2523
  break;
2524
2524
  }
2525
2525
 
@@ -2550,7 +2550,7 @@ static VALUE rhrdt_prev_year(int argc, VALUE *argv, VALUE self) {
2550
2550
  i = -NUM2LONG(argv[0]);
2551
2551
  break;
2552
2552
  default:
2553
- rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
2553
+ rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
2554
2554
  break;
2555
2555
  }
2556
2556
 
@@ -2576,7 +2576,7 @@ static VALUE rhrdt_rfc2822(VALUE self) {
2576
2576
  RHRDT_FILL_HMS(d)
2577
2577
 
2578
2578
  s = rb_str_buf_new(128);
2579
- len = snprintf(RSTRING_PTR(s), 128, "%s, %i %s %04li %02i:%02i:%02i %+03i%02i",
2579
+ len = snprintf(RSTRING_PTR(s), 128, "%s, %d %s %04ld %02d:%02d:%02d %+03d%02d",
2580
2580
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
2581
2581
  (int)d->day,
2582
2582
  rhrd__abbr_month_names[d->month],
data/lib/1.8/date_ext.so CHANGED
Binary file
data/lib/1.9/date_ext.so CHANGED
Binary file
data/lib/date.rb CHANGED
@@ -4,4 +4,59 @@ rescue LoadError
4
4
  raise unless RUBY_PLATFORM =~ /mswin|mingw/
5
5
  require "#{RUBY_VERSION[0...3]}/date_ext"
6
6
  end
7
+
8
+ class Date
9
+ class Infinity < Numeric # :nodoc:
10
+
11
+ include Comparable
12
+
13
+ def initialize(d=1) @d = d <=> 0 end
14
+
15
+ def d() @d end
16
+
17
+ protected :d
18
+
19
+ def zero? () false end
20
+ def finite? () false end
21
+ def infinite? () d.nonzero? end
22
+ def nan? () d.zero? end
23
+
24
+ def abs() self.class.new end
25
+
26
+ def -@ () self.class.new(-d) end
27
+ def +@ () self.class.new(+d) end
28
+
29
+ def <=> (other)
30
+ case other
31
+ when Infinity; return d <=> other.d
32
+ when Numeric; return d
33
+ else
34
+ begin
35
+ l, r = other.coerce(self)
36
+ return l <=> r
37
+ rescue NoMethodError
38
+ end
39
+ end
40
+ nil
41
+ end
42
+
43
+ def coerce(other)
44
+ case other
45
+ when Numeric; return -d, d
46
+ else
47
+ super
48
+ end
49
+ end
50
+
51
+ def to_f
52
+ return 0 if @d == 0
53
+ if @d > 0
54
+ Float::INFINITY
55
+ else
56
+ -Float::INFINITY
57
+ end
58
+ end
59
+ end
60
+ end
61
+
7
62
  require "date/format" unless defined?(Date::Format::ZONES)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: home_run
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 7
10
- version: 1.0.7
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Jeremy Evans
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-07 00:00:00 Z
18
+ date: 2013-03-19 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: |