* ext/date/date_core.c: mathn still alive (should die soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
be5e17704c
commit
6c1e759c3f
@ -1,3 +1,7 @@
|
|||||||
|
Fri Jul 1 03:24:03 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* ext/date/date_core.c: mathn still alive (should die soon).
|
||||||
|
|
||||||
Thu Jun 30 23:50:00 2011 Kenta Murata <mrkn@mrkn.jp>
|
Thu Jun 30 23:50:00 2011 Kenta Murata <mrkn@mrkn.jp>
|
||||||
|
|
||||||
* misc/ruby-mode.el (ruby-indent-beg-re): Fix broken regular
|
* misc/ruby-mode.el (ruby-indent-beg-re): Fix broken regular
|
||||||
|
@ -417,7 +417,7 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
|
|||||||
(x)->jd = (y)->jd;\
|
(x)->jd = (y)->jd;\
|
||||||
(x)->sg = (sg_cast)((y)->sg);\
|
(x)->sg = (sg_cast)((y)->sg);\
|
||||||
(x)->year = (y)->year;\
|
(x)->year = (y)->year;\
|
||||||
(x)->pc = PACK5(EX_MON((y)->pc), EX_MDAY((y)->pc), 0, 0, 0);\
|
(x)->pc = PACK2(EX_MON((y)->pc), EX_MDAY((y)->pc));\
|
||||||
(x)->flags = (y)->flags;\
|
(x)->flags = (y)->flags;\
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1904,6 +1904,12 @@ k_numeric_p(VALUE x)
|
|||||||
return f_kind_of_p(x, rb_cNumeric);
|
return f_kind_of_p(x, rb_cNumeric);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static VALUE
|
||||||
|
k_rational_p(VALUE x)
|
||||||
|
{
|
||||||
|
return f_kind_of_p(x, rb_cRational);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
static void
|
static void
|
||||||
civil_to_jd(VALUE y, int m, int d, double sg,
|
civil_to_jd(VALUE y, int m, int d, double sg,
|
||||||
@ -2280,14 +2286,32 @@ offset_to_sec(VALUE vof, int *rof)
|
|||||||
if (!k_numeric_p(vof))
|
if (!k_numeric_p(vof))
|
||||||
rb_raise(rb_eTypeError, "expected numeric");
|
rb_raise(rb_eTypeError, "expected numeric");
|
||||||
vof = f_to_r(vof);
|
vof = f_to_r(vof);
|
||||||
|
#ifdef CANONICALIZATION_FOR_MATHN
|
||||||
|
if (!k_rational_p(vof))
|
||||||
|
return offset_to_sec(vof, rof);
|
||||||
|
#endif
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case T_RATIONAL:
|
case T_RATIONAL:
|
||||||
{
|
{
|
||||||
VALUE vs = day_to_sec(vof);
|
VALUE vs, vn, vd;
|
||||||
VALUE vn = RRATIONAL(vs)->num;
|
|
||||||
VALUE vd = RRATIONAL(vs)->den;
|
|
||||||
long n;
|
long n;
|
||||||
|
|
||||||
|
vs = day_to_sec(vof);
|
||||||
|
|
||||||
|
#ifdef CANONICALIZATION_FOR_MATHN
|
||||||
|
if (!k_rational_p(vs)) {
|
||||||
|
vn = vs;
|
||||||
|
vd = INT2FIX(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vn = RRATIONAL(vs)->num;
|
||||||
|
vd = RRATIONAL(vs)->den;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
vn = RRATIONAL(vs)->num;
|
||||||
|
vd = RRATIONAL(vs)->den;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (FIXNUM_P(vn) && FIXNUM_P(vd) && (FIX2LONG(vd) == 1))
|
if (FIXNUM_P(vn) && FIXNUM_P(vd) && (FIX2LONG(vd) == 1))
|
||||||
n = FIX2LONG(vn);
|
n = FIX2LONG(vn);
|
||||||
else {
|
else {
|
||||||
@ -5671,6 +5695,10 @@ d_lite_plus(VALUE self, VALUE other)
|
|||||||
if (!k_numeric_p(other))
|
if (!k_numeric_p(other))
|
||||||
rb_raise(rb_eTypeError, "expected numeric");
|
rb_raise(rb_eTypeError, "expected numeric");
|
||||||
other = f_to_r(other);
|
other = f_to_r(other);
|
||||||
|
#ifdef CANONICALIZATION_FOR_MATHN
|
||||||
|
if (!k_rational_p(other))
|
||||||
|
return d_lite_plus(self, other);
|
||||||
|
#endif
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case T_RATIONAL:
|
case T_RATIONAL:
|
||||||
{
|
{
|
||||||
@ -8323,11 +8351,10 @@ dt_lite_strftime(int argc, VALUE *argv, VALUE self)
|
|||||||
static VALUE
|
static VALUE
|
||||||
iso8601_timediv(VALUE self, VALUE n)
|
iso8601_timediv(VALUE self, VALUE n)
|
||||||
{
|
{
|
||||||
VALUE f, fmt;
|
VALUE fmt;
|
||||||
|
|
||||||
if (f_lt_p(n, INT2FIX(1)))
|
fmt = rb_usascii_str_new2("T%H:%M:%S");
|
||||||
f = rb_usascii_str_new2("");
|
if (f_gt_p(n, INT2FIX(0))) {
|
||||||
else {
|
|
||||||
VALUE argv[3];
|
VALUE argv[3];
|
||||||
|
|
||||||
get_d1(self);
|
get_d1(self);
|
||||||
@ -8337,11 +8364,9 @@ iso8601_timediv(VALUE self, VALUE n)
|
|||||||
argv[2] = f_round(f_quo(m_sf_in_sec(dat),
|
argv[2] = f_round(f_quo(m_sf_in_sec(dat),
|
||||||
f_quo(INT2FIX(1),
|
f_quo(INT2FIX(1),
|
||||||
f_expt(INT2FIX(10), n))));
|
f_expt(INT2FIX(10), n))));
|
||||||
f = rb_f_sprintf(3, argv);
|
rb_str_append(fmt, rb_f_sprintf(3, argv));
|
||||||
}
|
}
|
||||||
fmt = f_add3(rb_usascii_str_new2("T%H:%M:%S"),
|
rb_str_append(fmt, rb_usascii_str_new2("%:z"));
|
||||||
f,
|
|
||||||
rb_usascii_str_new2("%:z"));
|
|
||||||
return strftimev(RSTRING_PTR(fmt), self, set_tmx);
|
return strftimev(RSTRING_PTR(fmt), self, set_tmx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user