Skip to content

Commit

Permalink
* ext/date/date_core.c (datetime_s_now): localtime() and localtime_r()
Browse files Browse the repository at this point in the history
  required time_t pointer as 1st parameter, and tv_sec member of struct
  timeval is long.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
unak committed Feb 28, 2011
1 parent ca53d13 commit 38b37a4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ext/date/date_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ civil_to_jd(int y, int m, int d, double sg, long *rjd, int *ns)
else
*ns = 1;

*rjd = jd;
*rjd = (long)jd;
}

static void
Expand Down Expand Up @@ -289,9 +289,9 @@ jd_to_civil(long jd, double sg, int *ry, int *rm, int *rdom)
y = c - 4715;
}

*ry = y;
*rm = m;
*rdom = dom;
*ry = (int)y;
*rm = (int)m;
*rdom = (int)dom;
}

static void
Expand Down Expand Up @@ -2443,6 +2443,7 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass)
struct timespec ts;
#else
struct timeval tv;
time_t sec;
#endif
struct tm tm;
long y;
Expand All @@ -2463,7 +2464,8 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass)
#else
if (gettimeofday(&tv, NULL) == -1)
rb_sys_fail("gettimeofday");
localtime_r(&tv.tv_sec, &tm);
sec = tv.tv_sec;
localtime_r(&sec, &tm);
#endif

y = tm.tm_year + 1900;
Expand Down

0 comments on commit 38b37a4

Please sign in to comment.