home_run 0.9.1-x86-mingw32 → 0.9.2-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
+ === 0.9.2 (2010-09-13)
2
+
3
+ * Make DateTime#sec_fraction on ruby 1.9 to be compatible with 1.9 stdlib (jeremyevans)
4
+
5
+ * Remove the use of the %hhi sprintf format specifier, for greater standards compatibility (jeremyevans)
6
+
7
+ * Fix a bug where the same symbol was present in multiple objects, causing build failures with -fno-common (jeremyevans) (#10)
8
+
1
9
  === 0.9.1 (2010-09-01)
2
10
 
3
11
  * Fix strptime for %Y%m%d and similar formats (jeremyevans) (#9)
data/README.rdoc CHANGED
@@ -78,9 +78,6 @@ and 1.9.
78
78
 
79
79
  == Installing into site_ruby
80
80
 
81
- This is only necessary on ruby 1.8, as on ruby 1.9, gem directories
82
- come before the standard library directories in the load path.
83
-
84
81
  After installing the gem:
85
82
 
86
83
  home_run --install
@@ -94,9 +91,6 @@ If you ever want to uninstall from site_ruby:
94
91
 
95
92
  == Running without installing into site_ruby
96
93
 
97
- Just like installing into site_ruby, this should only be necessary
98
- on ruby 1.8.
99
-
100
94
  If you don't want to install into site_ruby, you can use home_run's
101
95
  Date/DateTime classes for specific programs by running your script
102
96
  using home_run:
@@ -118,7 +112,9 @@ date, you can end up with situations where the Date instances created
118
112
  before the require use the standard library version of Date, while the
119
113
  Date instances created after the require use this library's version.
120
114
  However, in some cases (such as on Heroku), this is the only way to
121
- easily use this library.
115
+ easily use this library. If you need to do this and you are using
116
+ Rails 3, make sure you require home_run before rails/all in
117
+ config/application.rb.
122
118
 
123
119
  == Running the specs
124
120
 
@@ -1,6 +1,10 @@
1
1
  #include <ctype.h>
2
2
  #include "date_ext.h"
3
3
 
4
+ #ifdef RHR_ENCODING
5
+ int rhrd_encoding_index;
6
+ #endif
7
+
4
8
  const unsigned char rhrd_days_in_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
5
9
  const long rhrd_cumulative_days_in_month[13] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
6
10
  const unsigned char rhrd_yday_to_month[366] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12};
@@ -111,7 +115,7 @@ long rhrd__mod(long a, long b) {
111
115
  /* Same as above but for long long dividend. */
112
116
  long rhrd__modll(long long a, long b) {
113
117
  long c;
114
- c = a % b;
118
+ c = (long)(a % b);
115
119
  if (c < 0) {
116
120
  c += b;
117
121
  }
@@ -189,12 +193,12 @@ void rhrd__jd_to_civil(rhrd_t *date) {
189
193
  c = (long)floor((b - 122.1) / 365.25);
190
194
  d = (long)floor(365.25 * c);
191
195
  e = (long)floor((b - d) / 30.6001);
192
- date->day = b - d - (long)floor(30.6001 * e);
196
+ date->day = (unsigned char)(b - d - (long)floor(30.6001 * e));
193
197
  if (e <= 13) {
194
- date->month = e - 1;
198
+ date->month = (unsigned char)(e - 1);
195
199
  date->year = c - 4716;
196
200
  } else {
197
- date->month = e - 13;
201
+ date->month = (unsigned char)(e - 13);
198
202
  date->year = c - 4715;
199
203
  }
200
204
  date->flags |= RHR_HAVE_CIVIL;
@@ -318,13 +322,13 @@ VALUE rhrd__add_months(VALUE self, long n) {
318
322
  n = rhrd__safe_add_long(n, (long)(d->month));
319
323
  if(n > 1 && n <= 12) {
320
324
  newd->year = d->year;
321
- newd->month = n;
325
+ newd->month = (unsigned char)n;
322
326
  } else {
323
327
  x = n / 12;
324
328
  n = n % 12;
325
329
  if (n <= 0) {
326
330
  newd->year = d->year + x - 1;
327
- newd->month = n + 12;
331
+ newd->month = (unsigned char)(n + 12);
328
332
  } else {
329
333
  newd->year = d->year + x;
330
334
  newd->month = (unsigned char)n;
@@ -405,7 +409,7 @@ void rhrd__fill_commercial(rhrd_t *d) {
405
409
  rhrd__jd_to_civil(&n);
406
410
  a = n.year;
407
411
  d->year = d->jd >= rhrd__commercial_to_jd(a + 1, 1, 1) ? a + 1 : a;
408
- d->month = 1 + (d->jd - rhrd__commercial_to_jd(d->year, 1, 1)) / 7;
412
+ d->month = (unsigned char)(1 + (d->jd - rhrd__commercial_to_jd(d->year, 1, 1)) / 7);
409
413
  d->day = (unsigned char)rhrd__jd_to_cwday(d->jd);
410
414
  }
411
415
 
@@ -519,7 +523,7 @@ long long rhrd__jd_to_unix(long long jd) {
519
523
  * julian date, losing any information about
520
524
  * fractional days. */
521
525
  long rhrd__unix_to_jd(long long t) {
522
- return t/RHR_SECONDS_PER_DAY + RHR_UNIX_EPOCH;
526
+ return (long)(t/RHR_SECONDS_PER_DAY + RHR_UNIX_EPOCH);
523
527
  }
524
528
 
525
529
  /* Fill the given rhrt_d's jd field based on the
@@ -527,7 +531,7 @@ long rhrd__unix_to_jd(long long t) {
527
531
  void rhrd__today(rhrd_t * d) {
528
532
  VALUE t;
529
533
  t = rb_funcall(rb_cTime, rhrd_id_now, 0);
530
- d->jd = rhrd__unix_to_jd(NUM2LONG(rb_funcall(t, rhrd_id_to_i, 0)) + NUM2LONG(rb_funcall(t, rhrd_id_utc_offset, 0)));
534
+ d->jd = rhrd__unix_to_jd((long long)NUM2LONG(rb_funcall(t, rhrd_id_to_i, 0)) + NUM2LONG(rb_funcall(t, rhrd_id_utc_offset, 0)));
531
535
  d->flags |= RHR_HAVE_JD;
532
536
  RHR_CHECK_JD(d);
533
537
  }
@@ -644,7 +648,7 @@ int rhrd__fill_from_hash(rhrd_t *d, VALUE hash) {
644
648
  if(!rhrd__valid_commercial(d, d->year, 1, NUM2LONG(rwday), RHR_NO_RAISE)) {
645
649
  return 1;
646
650
  }
647
- d->flags &= ~RHR_HAVE_CIVIL;
651
+ d->flags &= (unsigned char)~RHR_HAVE_CIVIL;
648
652
  return 0;
649
653
  } else if (RTEST(rwnum0)) {
650
654
  d->jd = rhrd__weeknum_to_jd(year, NUM2LONG(rwnum0), RTEST(rwday) ? NUM2LONG(rwday) : (RTEST(rcwday) ? rhrd__mod(NUM2LONG(rcwday), 7) : 0), 0);
@@ -693,7 +697,7 @@ int rhrd__fill_from_hash(rhrd_t *d, VALUE hash) {
693
697
  wday = NUM2LONG(rwday);
694
698
  rhrd__today(d);
695
699
  d->jd += wday - rhrd__jd_to_wday(d->jd);
696
- d->flags &= ~RHR_HAVE_CIVIL;
700
+ d->flags &= (unsigned char)~RHR_HAVE_CIVIL;
697
701
  return 0;
698
702
  } else {
699
703
  return -1;
@@ -774,19 +778,19 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
774
778
  cp += sprintf(str + cp, "%s", rhrd__month_names[d->month]);
775
779
  break;
776
780
  case 'c':
777
- cp += sprintf(str + cp, "%s %s %2hhi %02hhi:%02hhi:%02hhi %04li", rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)], rhrd__abbr_month_names[d->month], d->day, d->hour, d->minute, d->second, d->year);
781
+ 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);
778
782
  break;
779
783
  case 'C':
780
784
  cp += sprintf(str + cp, "%02li", d->year / 100);
781
785
  break;
782
786
  case 'd':
783
- cp += sprintf(str + cp, "%02hhi", d->day);
787
+ cp += sprintf(str + cp, "%02i", (int)d->day);
784
788
  break;
785
789
  case 'e':
786
- cp += sprintf(str + cp, "%2hhi", d->day);
790
+ cp += sprintf(str + cp, "%2i", (int)d->day);
787
791
  break;
788
792
  case 'F':
789
- cp += sprintf(str + cp, "%04li-%02hhi-%02hhi", d->year, d->month, d->day);
793
+ cp += sprintf(str + cp, "%04li-%02i-%02i", d->year, (int)d->month, (int)d->day);
790
794
  break;
791
795
  case 'g':
792
796
  cp += sprintf(str + cp, "%02li", cd.year % 100);
@@ -795,28 +799,28 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
795
799
  cp += sprintf(str + cp, "%04li", cd.year);
796
800
  break;
797
801
  case 'H':
798
- cp += sprintf(str + cp, "%02hhi", d->hour);
802
+ cp += sprintf(str + cp, "%02i", (int)d->hour);
799
803
  break;
800
804
  case 'I':
801
- cp += sprintf(str + cp, "%02hhi", (d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12);
805
+ cp += sprintf(str + cp, "%02i", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12));
802
806
  break;
803
807
  case 'j':
804
808
  cp += sprintf(str + cp, "%03li", rhrd__ordinal_day(d->year, d->month, d->day));
805
809
  break;
806
810
  case 'k':
807
- cp += sprintf(str + cp, "%2hhi", d->hour);
811
+ cp += sprintf(str + cp, "%2i", (int)(d->hour));
808
812
  break;
809
813
  case 'l':
810
- cp += sprintf(str + cp, "%2hhi", (d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12);
814
+ cp += sprintf(str + cp, "%2i", (int)((d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12));
811
815
  break;
812
816
  case 'L':
813
817
  cp += sprintf(str + cp, "%03" PRId64, (d->nanos % RHR_NANOS_PER_SECOND)/1000000);
814
818
  break;
815
819
  case 'm':
816
- cp += sprintf(str + cp, "%02hhi", d->month);
820
+ cp += sprintf(str + cp, "%02i", (int)(d->month));
817
821
  break;
818
822
  case 'M':
819
- cp += sprintf(str + cp, "%02hhi", d->minute);
823
+ cp += sprintf(str + cp, "%02i", (int)(d->minute));
820
824
  break;
821
825
  case 'N':
822
826
  cp += sprintf(str + cp, "%09" PRId64, (d->nanos % RHR_NANOS_PER_SECOND));
@@ -831,38 +835,38 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
831
835
  cp += sprintf(str + cp, d->hour >= 12 ? "pm" : "am");
832
836
  break;
833
837
  case 'Q':
834
- cp += sprintf(str + cp, "%" PRId64, rhrd__jd_to_unix(d->jd) * 1000 + d->nanos/RHR_NANOS_PER_MILLISECOND - d->offset * 60000);
838
+ cp += sprintf(str + cp, "%" PRId64, rhrd__jd_to_unix((long long)d->jd) * 1000 + d->nanos/RHR_NANOS_PER_MILLISECOND - d->offset * 60000);
835
839
  break;
836
840
  case 'r':
837
- cp += sprintf(str + cp, "%2hhi:%02hhi:%02hhi %s", (d->hour == 12 || d->hour == 0) ? 12 : d->hour % 12, d->minute, d->second, d->hour >= 12 ? "PM" : "AM");
841
+ 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");
838
842
  break;
839
843
  case 'R':
840
- cp += sprintf(str + cp, "%02hhi:%02hhi", d->hour, d->minute);
844
+ cp += sprintf(str + cp, "%02i:%02i", (int)d->hour, (int)d->minute);
841
845
  break;
842
846
  case 's':
843
- cp += sprintf(str + cp, "%" PRId64, rhrd__jd_to_unix(d->jd) + d->nanos/RHR_NANOS_PER_SECOND - d->offset * 60);
847
+ cp += sprintf(str + cp, "%" PRId64, rhrd__jd_to_unix((long long)d->jd) + d->nanos/RHR_NANOS_PER_SECOND - d->offset * 60);
844
848
  break;
845
849
  case 'S':
846
- cp += sprintf(str + cp, "%02hhi", d->second);
850
+ cp += sprintf(str + cp, "%02i", (int)d->second);
847
851
  break;
848
852
  case 't':
849
853
  cp += sprintf(str + cp, "\t");
850
854
  break;
851
855
  case 'X':
852
856
  case 'T':
853
- cp += sprintf(str + cp, "%02hhi:%02hhi:%02hhi", d->hour, d->minute, d->second);
857
+ cp += sprintf(str + cp, "%02i:%02i:%02i", (int)d->hour, (int)d->minute, (int)d->second);
854
858
  break;
855
859
  case 'u':
856
- cp += sprintf(str + cp, "%hhi", cd.day);
860
+ cp += sprintf(str + cp, "%i", (int)cd.day);
857
861
  break;
858
862
  case 'U':
859
863
  cp += sprintf(str + cp, "%li", rhrd__jd_to_weeknum(d->jd, 0));
860
864
  break;
861
865
  case 'v':
862
- cp += sprintf(str + cp, "%2hhi-%s-%04li", d->day, rhrd__abbr_month_names[d->month], d->year);
866
+ cp += sprintf(str + cp, "%2i-%s-%04li", (int)d->day, rhrd__abbr_month_names[d->month], d->year);
863
867
  break;
864
868
  case 'V':
865
- cp += sprintf(str + cp, "%02hhi", cd.month);
869
+ cp += sprintf(str + cp, "%02i", (int)cd.month);
866
870
  break;
867
871
  case 'w':
868
872
  cp += sprintf(str + cp, "%li", rhrd__jd_to_wday(d->jd));
@@ -872,7 +876,7 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
872
876
  break;
873
877
  case 'D':
874
878
  case 'x':
875
- cp += sprintf(str + cp, "%02hhi/%02hhi/%02li", d->month, d->day, d->year % 100);
879
+ cp += sprintf(str + cp, "%02i/%02i/%02li", (int)d->month, (int)d->day, d->year % 100);
876
880
  break;
877
881
  case 'y':
878
882
  cp += sprintf(str + cp, "%02li", d->year % 100);
@@ -887,7 +891,7 @@ VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len) {
887
891
  cp += sprintf(str + cp, "%+03i:%02i", d->offset/60, abs(d->offset % 60));
888
892
  break;
889
893
  case '+':
890
- cp += sprintf(str + cp, "%s %s %2hhi %02hhi:%02hhi:%02hhi %+03i:%02i %04li", rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)], rhrd__abbr_month_names[d->month], d->day, d->hour, d->minute, d->second, d->offset/60, abs(d->offset % 60), d->year);
894
+ 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);
891
895
  break;
892
896
  default:
893
897
  str[cp] = c;
@@ -973,9 +977,9 @@ VALUE rhrd__strptime(VALUE rstr, const char *fmt_str, long fmt_len) {
973
977
  break;
974
978
  case 'A':
975
979
  for(i = 0; i < 7; i++) {
976
- scan_len = strlen(rhrd__day_names[i]);
980
+ scan_len = (int)strlen(rhrd__day_names[i]);
977
981
  if (pos + scan_len <= len) {
978
- if(strncasecmp(str + pos, rhrd__day_names[i], scan_len) == 0) {
982
+ if(strncasecmp(str + pos, rhrd__day_names[i], (size_t)scan_len) == 0) {
979
983
  wday = i;
980
984
  break;
981
985
  }
@@ -1006,9 +1010,9 @@ VALUE rhrd__strptime(VALUE rstr, const char *fmt_str, long fmt_len) {
1006
1010
  break;
1007
1011
  case 'B':
1008
1012
  for(i = 1; i < 13; i++) {
1009
- scan_len = strlen(rhrd__month_names[i]);
1013
+ scan_len = (int)strlen(rhrd__month_names[i]);
1010
1014
  if (pos + scan_len <= len) {
1011
- if(strncasecmp(str + pos, rhrd__month_names[i], scan_len) == 0) {
1015
+ if(strncasecmp(str + pos, rhrd__month_names[i], (size_t)scan_len) == 0) {
1012
1016
  month = i;
1013
1017
  break;
1014
1018
  }
@@ -1095,7 +1099,7 @@ VALUE rhrd__strptime(VALUE rstr, const char *fmt_str, long fmt_len) {
1095
1099
  if (sscanf(str + pos, "%03ld%n", &sec_fraction_num, &scan_len) != 1) {
1096
1100
  return Qnil;
1097
1101
  }
1098
- sec_fraction = sec_fraction_num/pow(10, scan_len);
1102
+ sec_fraction = sec_fraction_num/pow(10.0, (double)scan_len);
1099
1103
  state |= RHRR_SEC_FRACTION_SET;
1100
1104
  break;
1101
1105
  case 'm':
@@ -1128,7 +1132,7 @@ VALUE rhrd__strptime(VALUE rstr, const char *fmt_str, long fmt_len) {
1128
1132
  if (sscanf(str + pos, "%09ld%n", &sec_fraction_num, &scan_len) != 1) {
1129
1133
  return Qnil;
1130
1134
  }
1131
- sec_fraction = sec_fraction_num/pow(10, scan_len);
1135
+ sec_fraction = sec_fraction_num/pow(10.0, (double)scan_len);
1132
1136
  state |= RHRR_SEC_FRACTION_SET;
1133
1137
  break;
1134
1138
  case 'P':
@@ -1418,7 +1422,7 @@ VALUE rhrd__strptime(VALUE rstr, const char *fmt_str, long fmt_len) {
1418
1422
  }
1419
1423
  if(state & RHRR_UNIXM_SET) {
1420
1424
  rb_hash_aset(hash, rhrd_sym_seconds, LL2NUM(milliseconds/1000));
1421
- rb_hash_aset(hash, rhrd_sym_sec_fraction, rb_float_new((milliseconds % 1000)/1000.0));
1425
+ rb_hash_aset(hash, rhrd_sym_sec_fraction, rb_float_new((double)(milliseconds % 1000)/1000.0));
1422
1426
  }
1423
1427
  if(RTEST(zone)) {
1424
1428
  rb_hash_aset(hash, rhrd_sym_zone, zone);
@@ -2000,7 +2004,7 @@ VALUE rhrd_s_zone_to_diff(VALUE klass, VALUE str) {
2000
2004
  v = rb_funcall(str, rhrd_id_split, 1, rhrd_re_comma_period);
2001
2005
  e = rb_ary_entry(v, 1);
2002
2006
  return LONG2NUM(((NUM2LONG(rb_funcall(rb_ary_entry(v, 0), rhrd_id_to_i, 0)) * RHR_SECONDS_PER_HOUR)
2003
- + ((NUM2LONG(rb_funcall(e, rhrd_id_to_i, 0)) * RHR_SECONDS_PER_HOUR) / (long)pow(10, RSTRING_LEN(rb_str_to_str(e))))) * offset);
2007
+ + ((NUM2LONG(rb_funcall(e, rhrd_id_to_i, 0)) * RHR_SECONDS_PER_HOUR) / (long)pow(10.0, (double)RSTRING_LEN(rb_str_to_str(e))))) * offset);
2004
2008
  }
2005
2009
  }
2006
2010
  switch (len) {
@@ -2067,10 +2071,10 @@ static VALUE rhrd_asctime(VALUE self) {
2067
2071
  RHR_FILL_JD(d)
2068
2072
 
2069
2073
  s = rb_str_buf_new(128);
2070
- len = snprintf(RSTRING_PTR(s), 128, "%s %s %2hhi 00:00:00 %04li",
2074
+ len = snprintf(RSTRING_PTR(s), 128, "%s %s %2i 00:00:00 %04li",
2071
2075
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
2072
2076
  rhrd__abbr_month_names[d->month],
2073
- d->day,
2077
+ (int)d->day,
2074
2078
  d->year);
2075
2079
  if (len == -1 || len > 127) {
2076
2080
  rb_raise(rb_eNoMemError, "in Date#asctime (in snprintf)");
@@ -2283,8 +2287,8 @@ static VALUE rhrd_inspect(VALUE self) {
2283
2287
  RHR_FILL_CIVIL(d)
2284
2288
 
2285
2289
  s = rb_str_buf_new(128);
2286
- len = snprintf(RSTRING_PTR(s), 128, "#<Date %04li-%02hhi-%02hhi>",
2287
- d->year, d->month, d->day);
2290
+ len = snprintf(RSTRING_PTR(s), 128, "#<Date %04li-%02i-%02i>",
2291
+ d->year, (int)d->month, (int)d->day);
2288
2292
  if (len == -1 || len > 127) {
2289
2293
  rb_raise(rb_eNoMemError, "in Date#inspect (in snprintf)");
2290
2294
  }
@@ -2617,8 +2621,8 @@ static VALUE rhrd_to_s(VALUE self) {
2617
2621
  RHR_FILL_CIVIL(d)
2618
2622
 
2619
2623
  s = rb_str_buf_new(128);
2620
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02hhi-%02hhi",
2621
- d->year, d->month, d->day);
2624
+ len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02i",
2625
+ d->year, (int)d->month, (int)d->day);
2622
2626
  if (len == -1 || len > 127) {
2623
2627
  rb_raise(rb_eNoMemError, "in Date#to_s (in snprintf)");
2624
2628
  }
@@ -2784,7 +2788,7 @@ static VALUE rhrd_op_minus(VALUE self, VALUE other) {
2784
2788
  RHR_FILL_JD(d)
2785
2789
  RHRDT_FILL_JD(newdt)
2786
2790
  RHRDT_FILL_NANOS(newdt)
2787
- return rb_float_new(d->jd - (newdt->jd + newdt->nanos/RHR_NANOS_PER_DAYD));
2791
+ return rb_float_new(d->jd - (newdt->jd + (double)newdt->nanos/RHR_NANOS_PER_DAYD));
2788
2792
  }
2789
2793
  if (RTEST((rb_obj_is_kind_of(other, rhrd_class)))) {
2790
2794
  Data_Get_Struct(other, rhrd_t, newd);
@@ -3139,9 +3143,9 @@ static VALUE rhrd_httpdate(VALUE self) {
3139
3143
  RHR_FILL_JD(d)
3140
3144
 
3141
3145
  s = rb_str_buf_new(128);
3142
- len = snprintf(RSTRING_PTR(s), 128, "%s, %02hhi %s %04li 00:00:00 GMT",
3146
+ len = snprintf(RSTRING_PTR(s), 128, "%s, %02i %s %04li 00:00:00 GMT",
3143
3147
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
3144
- d->day,
3148
+ (int)d->day,
3145
3149
  rhrd__abbr_month_names[d->month],
3146
3150
  d->year);
3147
3151
  if (len == -1 || len > 127) {
@@ -3172,7 +3176,7 @@ static VALUE rhrd_jisx0301(VALUE self) {
3172
3176
 
3173
3177
  s = rb_str_buf_new(128);
3174
3178
  if (d->jd < 2405160) {
3175
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02hhi-%02hhi", d->year, d->month, d->day);
3179
+ len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02i", d->year, (int)d->month, (int)d->day);
3176
3180
  } else {
3177
3181
  if (d->jd >= 2447535) {
3178
3182
  c = 'H';
@@ -3187,7 +3191,7 @@ static VALUE rhrd_jisx0301(VALUE self) {
3187
3191
  c = 'M';
3188
3192
  year = d->year - 1867;
3189
3193
  }
3190
- len = snprintf(RSTRING_PTR(s), 128, "%c%02li.%02hhi.%02hhi", c, year, d->month, d->day);
3194
+ len = snprintf(RSTRING_PTR(s), 128, "%c%02li.%02i.%02i", c, year, (int)d->month, (int)d->day);
3191
3195
  }
3192
3196
  if (len == -1 || len > 127) {
3193
3197
  rb_raise(rb_eNoMemError, "in Date#jisx0301 (in snprintf)");
@@ -3394,9 +3398,9 @@ static VALUE rhrd_rfc2822(VALUE self) {
3394
3398
  RHR_FILL_JD(d)
3395
3399
 
3396
3400
  s = rb_str_buf_new(128);
3397
- len = snprintf(RSTRING_PTR(s), 128, "%s, %hhi %s %04li 00:00:00 +0000",
3401
+ len = snprintf(RSTRING_PTR(s), 128, "%s, %i %s %04li 00:00:00 +0000",
3398
3402
  rhrd__abbr_day_names[rhrd__jd_to_wday(d->jd)],
3399
- d->day,
3403
+ (int)d->day,
3400
3404
  rhrd__abbr_month_names[d->month],
3401
3405
  d->year);
3402
3406
  if (len == -1 || len > 127) {
@@ -3423,7 +3427,7 @@ static VALUE rhrd_rfc3339(VALUE self) {
3423
3427
  RHR_FILL_CIVIL(d)
3424
3428
 
3425
3429
  s = rb_str_buf_new(128);
3426
- len = snprintf(RSTRING_PTR(s), 128, "%04li-%02hhi-%02hhiT00:00:00+00:00", d->year, d->month, d->day);
3430
+ len = snprintf(RSTRING_PTR(s), 128, "%04li-%02i-%02iT00:00:00+00:00", d->year, (int)d->month, (int)d->day);
3427
3431
  if (len == -1 || len > 127) {
3428
3432
  rb_raise(rb_eNoMemError, "in Date#rfc3339 (in snprintf)");
3429
3433
  }
@@ -3697,11 +3701,11 @@ static VALUE rhrd_s_day_fraction_to_time(VALUE klass, VALUE rf) {
3697
3701
  int h, m, s;
3698
3702
 
3699
3703
  f = NUM2DBL(rf) * 24;
3700
- h = floor(f);
3704
+ h = (int)floor(f);
3701
3705
  f = (f - h) * 60;
3702
- m = floor(f);
3706
+ m = (int)floor(f);
3703
3707
  f = (f - m) * 60;
3704
- s = floor(f);
3708
+ s = (int)floor(f);
3705
3709
  f = (f - s)/RHR_SECONDS_PER_DAY;
3706
3710
  return rb_ary_new3(4, LONG2NUM(h), LONG2NUM(m), LONG2NUM(s), rb_float_new(f));
3707
3711
  }
@@ -4109,7 +4113,7 @@ void Init_date_ext(void) {
4109
4113
  rb_ary_push(rhrd_monthnames, Qnil);
4110
4114
  rb_ary_push(rhrd_abbr_monthnames, Qnil);
4111
4115
  for(i = 1; i < 13; i++) {
4112
- rb_ary_push(rhrd_monthnames, rb_str_new2(rhrd__month_names[i]));
4116
+ rb_ary_push(rhrd_monthnames, rb_str_new2((const char *)rhrd__month_names[i]));
4113
4117
  rb_ary_push(rhrd_abbr_monthnames, rb_str_new2(rhrd__abbr_month_names[i]));
4114
4118
  }
4115
4119
 
@@ -4299,9 +4303,9 @@ void Init_date_ext(void) {
4299
4303
  /* Define some static regexps. The 1 for the options makes
4300
4304
  * it case insensitive, as I don't want to deal with including
4301
4305
  * the ruby regex header just to get it. */
4302
- rhrd_zone_re = rb_reg_new(rhrd__zone_re_str, strlen(rhrd__zone_re_str), 1);
4303
- rhrd_zone_dst_re = rb_reg_new(rhrd__zone_dst_re_str, strlen(rhrd__zone_dst_re_str), 1);
4304
- rhrd_zone_sign_re = rb_reg_new(rhrd__zone_sign_re_str, strlen(rhrd__zone_sign_re_str), 1);
4306
+ rhrd_zone_re = rb_reg_new(rhrd__zone_re_str, (int)strlen(rhrd__zone_re_str), 1);
4307
+ rhrd_zone_dst_re = rb_reg_new(rhrd__zone_dst_re_str, (int)strlen(rhrd__zone_dst_re_str), 1);
4308
+ rhrd_zone_sign_re = rb_reg_new(rhrd__zone_sign_re_str, (int)strlen(rhrd__zone_sign_re_str), 1);
4305
4309
  rhrd_re_comma_period = rb_reg_new("[,.]", 4, 0);
4306
4310
 
4307
4311
  /* Register global variables with Garbage collector, so users
@@ -119,7 +119,6 @@ so that no calculations can overflow.
119
119
  #define RHRDT_FILL_NANOS(d) if (!((d)->flags & RHR_HAVE_NANOS)) { rhrdt__hms_to_nanos(d); }
120
120
 
121
121
  #ifdef RHR_ENCODING
122
- int rhrd_encoding_index;
123
122
  #define RHR_ASCII_ENCODING(s) s = rb_enc_associate_index(s, rhrd_encoding_index); \
124
123
  if(rb_default_internal_encoding()) {s = rb_str_export_to_enc(s, rb_default_internal_encoding());}
125
124
  #else
@@ -135,7 +134,7 @@ int rhrd_encoding_index;
135
134
  #define RHR_SPACE_SHIP(x, l, r) if (l < r) { x = -1; } else if (l == r) { x = 0; } else { x = 1; }
136
135
 
137
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);}
138
- #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 = %hhi, day = %hhi", d->year, d->month, d->day);}
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);}
139
138
 
140
139
  #define RHR_CACHED_IV(self, iv) VALUE v = rb_ivar_get(self, iv); if (RTEST(v)) {return v;}
141
140