summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-27 17:14:13 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-27 17:14:13 +0000
commitf0aa9838a23bba3abe411df12070fddc23775a82 (patch)
tree258ad19703416337dfcf605ee8e0dfa024764206 /time.c
parent7f9b9fbae8b0c588535af9247188d002d50ca850 (diff)
* time.c: fix previos commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/time.c b/time.c
index 9ac1ec3091..96f995b329 100644
--- a/time.c
+++ b/time.c
@@ -122,11 +122,12 @@ xv2w(VALUE xv) {
int64_t i = 0;
while (len)
i = (i << sizeof(BDIGIT)*CHAR_BIT) | ds[--len];
- TIMEW_SETVAL(w, INT64toFIXTV(i));
+ if (FIXTVABLE(i))
+ TIMEW_SETVAL(w, INT64toFIXTV(i));
}
}
else {
- if (ds[len-1] <= ((BDIGIT)1 << (sizeof(BDIGIT)*CHAR_BIT-2))) {
+ if (ds[len-1] < ((BDIGIT)1 << (sizeof(BDIGIT)*CHAR_BIT-2))) {
int64_t i = 0;
while (len)
i = (i << sizeof(BDIGIT)*CHAR_BIT) | ds[--len];
@@ -616,7 +617,7 @@ timegmw_noleapsecond(struct vtm *vtm)
int year_mod400;
int yday = vtm->mday;
long days_in400;
- VALUE ret;
+ VALUE vdays, ret;
timew_t wret;
year1900 = sub(vtm->year, INT2FIX(1900));
@@ -643,9 +644,10 @@ timegmw_noleapsecond(struct vtm *vtm)
+ DIV(year_mod400 - 69, 4)
- DIV(year_mod400 - 1, 100)
+ (year_mod400 + 299) / 400;
- ret = add(ret, mul(LONG2NUM(days_in400), INT2FIX(86400)));
- ret = add(ret, mul(q400, INT2FIX(97*86400)));
- ret = add(ret, mul(year1900, INT2FIX(365*86400)));
+ vdays = LONG2NUM(days_in400);
+ vdays = add(vdays, mul(q400, INT2FIX(97)));
+ vdays = add(vdays, mul(year1900, INT2FIX(365)));
+ ret = add(ret, mul(vdays, INT2FIX(86400)));
wret = wadd(rb_time_magnify(ret), xv2w(vtm->subsecx));
return wret;