summaryrefslogtreecommitdiff
path: root/ext/date/date_core.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-25 13:01:06 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-25 13:01:06 +0000
commite358888d5e22344429ee7d5589b5053e0a817afd (patch)
tree758b0a7b5588bb4633ddf31540c630d489382a7a /ext/date/date_core.c
parent96216554d2de68c90c53068a87d88e8f25207d74 (diff)
* ext/date/date_core.c: should not force cast with macros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/date/date_core.c')
-rw-r--r--ext/date/date_core.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index e75c666e14..c20079b2e9 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -42,10 +42,10 @@
#define DAY_IN_NANOSECONDS 86400000000000LL
/* copied from time.c */
-#define NDIV(x,y) ((int)(-(-((x)+1)/(y))-1))
-#define NMOD(x,y) ((int)((y)-(-((x)+1)%(y))-1))
-#define DIV(n,d) ((int)((n)<0 ? NDIV((n),(d)) : (n)/(d)))
-#define MOD(n,d) ((int)((n)<0 ? NMOD((n),(d)) : (n)%(d)))
+#define NDIV(x,y) (-(-((x)+1)/(y))-1)
+#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
+#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
+#define MOD(n,d) ((n)<0 ? NMOD((n),(d)) : (n)%(d))
union DateData
{
@@ -338,8 +338,8 @@ jd_to_commercial(long jd, double sg, int *ry, int *rw, int *rd)
commercial_to_jd(a, 1, 1, sg, &rjd2, &ns2);
*ry = a;
}
- *rw = 1 + DIV(jd - rjd2, 7);
- *rd = MOD(jd + 1, 7);
+ *rw = 1 + (int)DIV(jd - rjd2, 7);
+ *rd = (int)MOD(jd + 1, 7);
if (*rd == 0)
*rd = 7;
}
@@ -368,8 +368,8 @@ jd_to_weeknum(long jd, int f, double sg, int *ry, int *rw, int *rd)
find_fdoy(*ry, sg, &rjd, &ns);
rjd += 6;
j = jd - (rjd - MOD((rjd - f) + 1, 7)) + 7;
- *rw = DIV(j, 7);
- *rd = MOD(j, 7);
+ *rw = (int)DIV(j, 7);
+ *rd = (int)MOD(j, 7);
}
#ifndef NDEBUG
@@ -403,7 +403,7 @@ jd_to_nth_kday(long jd, double sg, int *ry, int *rm, int *rn, int *rk)
jd_to_civil(jd, sg, ry, rm, &rd);
find_fdom(*ry, *rm, sg, &rjd, &ns2);
- *rn = DIV(jd - rjd, 7) + 1;
+ *rn = (int)DIV(jd - rjd, 7) + 1;
*rk = jd_to_wday(jd);
}
#endif
@@ -585,7 +585,7 @@ time_to_df(int h, int min, int s)
inline static int
jd_to_wday(long jd)
{
- return MOD(jd + 1, 7);
+ return (int)MOD(jd + 1, 7);
}
static int