* ext/date/date_core.c (datetime_s_now): localtime() and localtime_r()

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
This commit is contained in:
usa 2011-02-28 03:28:24 +00:00
parent 18c34c6c92
commit 5d881f0fd4
2 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,9 @@
Mon Feb 28 12:28:13 2011 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/date/date_core.c (datetime_s_now): localtime() and localtime_r()
required time_t pointer as 1st parameter, and tv_sec member of struct
timeval is long.
Mon Feb 28 11:57:40 2011 Shota Fukumori <sorah@tubusu.net> Mon Feb 28 11:57:40 2011 Shota Fukumori <sorah@tubusu.net>
* test/testunit/test_parallel.rb: Temporally disable test on Windows. * test/testunit/test_parallel.rb: Temporally disable test on Windows.

View File

@ -261,7 +261,7 @@ civil_to_jd(int y, int m, int d, double sg, long *rjd, int *ns)
else else
*ns = 1; *ns = 1;
*rjd = jd; *rjd = (long)jd;
} }
static void static void
@ -289,9 +289,9 @@ jd_to_civil(long jd, double sg, int *ry, int *rm, int *rdom)
y = c - 4715; y = c - 4715;
} }
*ry = y; *ry = (int)y;
*rm = m; *rm = (int)m;
*rdom = dom; *rdom = (int)dom;
} }
static void static void
@ -2443,6 +2443,7 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass)
struct timespec ts; struct timespec ts;
#else #else
struct timeval tv; struct timeval tv;
time_t sec;
#endif #endif
struct tm tm; struct tm tm;
long y; long y;
@ -2463,7 +2464,8 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass)
#else #else
if (gettimeofday(&tv, NULL) == -1) if (gettimeofday(&tv, NULL) == -1)
rb_sys_fail("gettimeofday"); rb_sys_fail("gettimeofday");
localtime_r(&tv.tv_sec, &tm); sec = tv.tv_sec;
localtime_r(&sec, &tm);
#endif #endif
y = tm.tm_year + 1900; y = tm.tm_year + 1900;