home_run 1.0.5-x86-mswin32-60 → 1.0.6-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -1
- data/ext/date_ext/date_ext.c +60 -21
- data/ext/date_ext/date_ext.h +2 -0
- data/ext/date_ext/datetime.c +0 -63
- data/lib/1.8/date_ext.so +0 -0
- data/lib/1.9/date_ext.so +0 -0
- metadata +3 -3
data/CHANGELOG
CHANGED
data/ext/date_ext/date_ext.c
CHANGED
@@ -2906,30 +2906,69 @@ static VALUE rhrd_op_relationship(VALUE self, VALUE other) {
|
|
2906
2906
|
* For an unrecognized type, return +nil+.
|
2907
2907
|
*/
|
2908
2908
|
static VALUE rhrd_op_spaceship(VALUE self, VALUE other) {
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2909
|
+
if (RTEST(rb_obj_is_kind_of(self, rhrdt_class))) {
|
2910
|
+
rhrdt_t *dt, *odt;
|
2911
|
+
rhrd_t *od;
|
2912
|
+
double diff;
|
2913
|
+
int res;
|
2914
|
+
|
2915
|
+
if (RTEST(rb_obj_is_kind_of(other, rhrdt_class))) {
|
2916
|
+
self = rhrdt__new_offset(self, 0.0);
|
2917
|
+
other = rhrdt__new_offset(other, 0.0);
|
2918
|
+
Data_Get_Struct(self, rhrdt_t, dt);
|
2919
|
+
Data_Get_Struct(other, rhrdt_t, odt);
|
2920
|
+
return LONG2NUM(rhrdt__spaceship(dt, odt));
|
2921
|
+
}
|
2922
|
+
if (RTEST(rb_obj_is_kind_of(other, rhrd_class))) {
|
2923
|
+
Data_Get_Struct(self, rhrdt_t, dt);
|
2924
|
+
Data_Get_Struct(other, rhrd_t, od);
|
2925
|
+
RHRDT_FILL_JD(dt)
|
2926
|
+
RHR_FILL_JD(od)
|
2927
|
+
RHR_SPACE_SHIP(res, dt->jd, od->jd)
|
2928
|
+
if (res == 0) {
|
2929
|
+
RHRDT_FILL_NANOS(dt)
|
2930
|
+
RHR_SPACE_SHIP(res, dt->nanos, 0)
|
2931
|
+
}
|
2932
|
+
return LONG2NUM(res);
|
2933
|
+
}
|
2934
|
+
if (RTEST((rb_obj_is_kind_of(other, rb_cNumeric)))) {
|
2935
|
+
Data_Get_Struct(self, rhrdt_t, dt);
|
2936
|
+
diff = NUM2DBL(other);
|
2937
|
+
RHRDT_FILL_JD(dt)
|
2938
|
+
RHR_SPACE_SHIP(res, dt->jd, (long)diff)
|
2939
|
+
if (res == 0) {
|
2940
|
+
RHRDT_FILL_NANOS(dt)
|
2941
|
+
RHR_SPACE_SHIP(res, dt->nanos, llround((diff - floor(diff)) * RHR_NANOS_PER_DAY))
|
2942
|
+
}
|
2943
|
+
return LONG2NUM(res);
|
2944
|
+
}
|
2945
|
+
} else {
|
2946
|
+
rhrd_t *d, *o;
|
2947
|
+
rhrdt_t *odt;
|
2948
|
+
long diff;
|
2949
|
+
Data_Get_Struct(self, rhrd_t, d);
|
2913
2950
|
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2951
|
+
if (RTEST(rb_obj_is_kind_of(other, rhrdt_class))) {
|
2952
|
+
Data_Get_Struct(other, rhrdt_t, odt);
|
2953
|
+
RHR_FILL_JD(d)
|
2954
|
+
RHRDT_FILL_JD(odt)
|
2955
|
+
RHR_SPACE_SHIP(diff, d->jd, odt->jd)
|
2956
|
+
if (diff == 0) {
|
2957
|
+
RHRDT_FILL_NANOS(odt)
|
2958
|
+
RHR_SPACE_SHIP(diff, 0, odt->nanos)
|
2959
|
+
}
|
2960
|
+
return LONG2NUM(diff);
|
2961
|
+
} else if (RTEST(rb_obj_is_kind_of(other, rhrd_class))) {
|
2962
|
+
Data_Get_Struct(other, rhrd_t, o);
|
2963
|
+
return LONG2NUM(rhrd__spaceship(d, o));
|
2964
|
+
} else if (RTEST((rb_obj_is_kind_of(other, rb_cNumeric)))) {
|
2965
|
+
diff = NUM2LONG(other);
|
2966
|
+
RHR_FILL_JD(d)
|
2967
|
+
RHR_SPACE_SHIP(diff, d->jd, diff)
|
2968
|
+
return LONG2NUM(diff);
|
2922
2969
|
}
|
2923
|
-
return LONG2NUM(diff);
|
2924
|
-
} else if (RTEST(rb_obj_is_kind_of(other, rhrd_class))) {
|
2925
|
-
Data_Get_Struct(other, rhrd_t, o);
|
2926
|
-
return LONG2NUM(rhrd__spaceship(d, o));
|
2927
|
-
} else if (RTEST((rb_obj_is_kind_of(other, rb_cNumeric)))) {
|
2928
|
-
diff = NUM2LONG(other);
|
2929
|
-
RHR_FILL_JD(d)
|
2930
|
-
RHR_SPACE_SHIP(diff, d->jd, diff)
|
2931
|
-
return LONG2NUM(diff);
|
2932
2970
|
}
|
2971
|
+
|
2933
2972
|
return Qnil;
|
2934
2973
|
}
|
2935
2974
|
|
data/ext/date_ext/date_ext.h
CHANGED
@@ -181,6 +181,8 @@ VALUE rhrd_s_zone_to_diff(VALUE self, VALUE zone);
|
|
181
181
|
VALUE rhrd__strftime(rhrdt_t *d, const char * fmt, int fmt_len);
|
182
182
|
long rhrd__ordinal_day(long year, unsigned char month, unsigned char day);
|
183
183
|
VALUE rhrd__ragel_parse(char * p, long len);
|
184
|
+
VALUE rhrdt__new_offset(VALUE self, double offset);
|
185
|
+
long rhrdt__spaceship(rhrdt_t *dt, rhrdt_t *odt);
|
184
186
|
void Init_datetime(void);
|
185
187
|
|
186
188
|
#endif /* DATE_EXT_H */
|
data/ext/date_ext/datetime.c
CHANGED
@@ -14,7 +14,6 @@ extern const char * rhrd__abbr_day_names[];
|
|
14
14
|
|
15
15
|
static VALUE rhrdt_step(int argc, VALUE *argv, VALUE self);
|
16
16
|
static VALUE rhrdt_to_s(VALUE self);
|
17
|
-
VALUE rhrdt__new_offset(VALUE self, double offset);
|
18
17
|
void rhrdt__jd_to_civil(rhrdt_t *date);
|
19
18
|
void rhrdt__nanos_to_hms(rhrdt_t *d);
|
20
19
|
|
@@ -1908,67 +1907,6 @@ static VALUE rhrdt_op_relationship(VALUE self, VALUE other) {
|
|
1908
1907
|
return dt->jd == jd ? Qtrue : Qfalse;
|
1909
1908
|
}
|
1910
1909
|
|
1911
|
-
/* call-seq:
|
1912
|
-
* <=>(other) -> -1, 0, 1, or nil
|
1913
|
-
*
|
1914
|
-
* If +other+ is a +DateTime+, returns -1 if the absolute date and time of
|
1915
|
-
* +other+ is before the absolute time of the receiver chronologically,
|
1916
|
-
* 0 if +other+ is the same absolute date and time as the receiver,
|
1917
|
-
* or 1 if the absolute date and time of +other+ is before the receiver
|
1918
|
-
* chronologically. Absolute date and time in this case means after taking
|
1919
|
-
* account the time zone offset.
|
1920
|
-
*
|
1921
|
-
* If +other+ is a +Date+, return 0 if +other+ has the same
|
1922
|
-
* julian date as the receiver and the receiver has no fractional part,
|
1923
|
-
* 1 if +other+ has a julian date greater than the receiver's, or
|
1924
|
-
* -1 if +other+ has a julian date less than the receiver's or
|
1925
|
-
* a julian date the same as the receiver's and the receiver has a
|
1926
|
-
* fractional part.
|
1927
|
-
*
|
1928
|
-
* If +other+ is a +Numeric+, convert it to an +Float+ and compare
|
1929
|
-
* it to the receiver's julian date plus the fractional part.
|
1930
|
-
*
|
1931
|
-
* For an unrecognized type, return +nil+.
|
1932
|
-
*/
|
1933
|
-
static VALUE rhrdt_op_spaceship(VALUE self, VALUE other) {
|
1934
|
-
rhrdt_t *dt, *odt;
|
1935
|
-
rhrd_t *od;
|
1936
|
-
double diff;
|
1937
|
-
int res;
|
1938
|
-
|
1939
|
-
if (RTEST(rb_obj_is_kind_of(other, rhrdt_class))) {
|
1940
|
-
self = rhrdt__new_offset(self, 0.0);
|
1941
|
-
other = rhrdt__new_offset(other, 0.0);
|
1942
|
-
Data_Get_Struct(self, rhrdt_t, dt);
|
1943
|
-
Data_Get_Struct(other, rhrdt_t, odt);
|
1944
|
-
return LONG2NUM(rhrdt__spaceship(dt, odt));
|
1945
|
-
}
|
1946
|
-
if (RTEST(rb_obj_is_kind_of(other, rhrd_class))) {
|
1947
|
-
Data_Get_Struct(self, rhrdt_t, dt);
|
1948
|
-
Data_Get_Struct(other, rhrd_t, od);
|
1949
|
-
RHRDT_FILL_JD(dt)
|
1950
|
-
RHR_FILL_JD(od)
|
1951
|
-
RHR_SPACE_SHIP(res, dt->jd, od->jd)
|
1952
|
-
if (res == 0) {
|
1953
|
-
RHRDT_FILL_NANOS(dt)
|
1954
|
-
RHR_SPACE_SHIP(res, dt->nanos, 0)
|
1955
|
-
}
|
1956
|
-
return LONG2NUM(res);
|
1957
|
-
}
|
1958
|
-
if (RTEST((rb_obj_is_kind_of(other, rb_cNumeric)))) {
|
1959
|
-
Data_Get_Struct(self, rhrdt_t, dt);
|
1960
|
-
diff = NUM2DBL(other);
|
1961
|
-
RHRDT_FILL_JD(dt)
|
1962
|
-
RHR_SPACE_SHIP(res, dt->jd, (long)diff)
|
1963
|
-
if (res == 0) {
|
1964
|
-
RHRDT_FILL_NANOS(dt)
|
1965
|
-
RHR_SPACE_SHIP(res, dt->nanos, llround((diff - floor(diff)) * RHR_NANOS_PER_DAY))
|
1966
|
-
}
|
1967
|
-
return LONG2NUM(res);
|
1968
|
-
}
|
1969
|
-
return Qnil;
|
1970
|
-
}
|
1971
|
-
|
1972
1910
|
#ifdef RUBY19
|
1973
1911
|
|
1974
1912
|
/* Ruby 1.9 helper methods */
|
@@ -2858,7 +2796,6 @@ void Init_datetime(void) {
|
|
2858
2796
|
rb_define_method(rhrdt_class, "+", rhrdt_op_plus, 1);
|
2859
2797
|
rb_define_method(rhrdt_class, "-", rhrdt_op_minus, 1);
|
2860
2798
|
rb_define_method(rhrdt_class, "===", rhrdt_op_relationship, 1);
|
2861
|
-
rb_define_method(rhrdt_class, "<=>", rhrdt_op_spaceship, 1);
|
2862
2799
|
|
2863
2800
|
rb_define_alias(rhrdt_class, "ctime", "asctime");
|
2864
2801
|
rb_define_alias(rhrdt_class, "mday", "day");
|
data/lib/1.8/date_ext.so
CHANGED
Binary file
|
data/lib/1.9/date_ext.so
CHANGED
Binary file
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: x86-mswin32-60
|
12
12
|
authors:
|
13
13
|
- Jeremy Evans
|