summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-21 02:13:46 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-21 02:13:46 +0000
commit48df11da1c6a53a34881649d49fa1bfaf9abdb61 (patch)
tree7da48a7331db4eecef9313ad68c8e893d7f4726a
parentbaac9b03518cf97384b913edcfd689243c830ed6 (diff)
merge revision(s) 19025,19050,19064,19482:
* win32/win32.c (gettimeofday): shouldn't use mktime(2) because it's buggy about handling summer time. reported by Yoshikawa <yoshixool AT gmail.com> at [ruby-dev:36071] * win32/win32.c (gettimeofday): calc tv_sec and tv_usec from system time by myself. [ruby-dev:36084] * win32/win32.c (gettimeofday): tv_usec is usec, not msec. [ruby-dev:36094] of the Gregorian calendar. * win32/win32.c (filetime_to_timeval): new function, split from gettimeofday(). * win32/win32.c (gettimeofday): use above function. * win32/win32.c (filetime_to_unixtime): ditto. [ruby-dev:36135] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@21705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog25
-rw-r--r--version.h8
-rw-r--r--win32/win32.c65
3 files changed, 60 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 9bc76990fc..3e7b575fe0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (filetime_to_timeval): new function, split from
+ gettimeofday().
+
+ * win32/win32.c (gettimeofday): use above function.
+
+ * win32/win32.c (filetime_to_unixtime): ditto. [ruby-dev:36135]
+
+Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (gettimeofday): tv_usec is usec, not msec.
+ [ruby-dev:36094]
+
+Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (gettimeofday): calc tv_sec and tv_usec from system
+ time by myself. [ruby-dev:36084]
+
+Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (gettimeofday): shouldn't use mktime(2) because it's
+ buggy about handling summer time.
+ reported by Yoshikawa <yoshixool AT gmail.com> at [ruby-dev:36071]
+
Tue Jan 20 12:23:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/scanf.rb (Scanf::FormatSpecifier#initialize): %i should accept
diff --git a/version.h b/version.h
index 58efa11121..6fb2c6d437 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2009-01-20"
+#define RUBY_RELEASE_DATE "2009-01-21"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20090120
-#define RUBY_PATCHLEVEL 90
+#define RUBY_RELEASE_CODE 20090121
+#define RUBY_PATCHLEVEL 91
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 20
+#define RUBY_RELEASE_DAY 21
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
diff --git a/win32/win32.c b/win32/win32.c
index 6f29a15f97..d128713a21 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2975,24 +2975,36 @@ waitpid(rb_pid_t pid, int *stat_loc, int options)
#include <sys/timeb.h>
+static int
+filetime_to_timeval(const FILETIME* ft, struct timeval *tv)
+{
+ ULARGE_INTEGER tmp;
+ unsigned LONG_LONG lt;
+
+ tmp.LowPart = ft->dwLowDateTime;
+ tmp.HighPart = ft->dwHighDateTime;
+ lt = tmp.QuadPart;
+
+ /* lt is now 100-nanosec intervals since 1601/01/01 00:00:00 UTC,
+ convert it into UNIX time (since 1970/01/01 00:00:00 UTC).
+ the first leap second is at 1972/06/30, so we doesn't need to think
+ about it. */
+ lt /= 10; /* to usec */
+ lt -= (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60 * 1000 * 1000;
+
+ tv->tv_sec = lt / (1000 * 1000);
+ tv->tv_usec = lt % (1000 * 1000);
+
+ return tv->tv_sec > 0 ? 0 : -1;
+}
+
int _cdecl
gettimeofday(struct timeval *tv, struct timezone *tz)
{
- SYSTEMTIME st;
- time_t t;
- struct tm tm;
-
- GetLocalTime(&st);
- tm.tm_sec = st.wSecond;
- tm.tm_min = st.wMinute;
- tm.tm_hour = st.wHour;
- tm.tm_mday = st.wDay;
- tm.tm_mon = st.wMonth - 1;
- tm.tm_year = st.wYear - 1900;
- tm.tm_isdst = -1;
- t = mktime(&tm);
- tv->tv_sec = t;
- tv->tv_usec = st.wMilliseconds * 1000;
+ FILETIME ft;
+
+ GetSystemTimeAsFileTime(&ft);
+ filetime_to_timeval(&ft, tv);
return 0;
}
@@ -3267,27 +3279,12 @@ isUNCRoot(const char *path)
static time_t
filetime_to_unixtime(const FILETIME *ft)
{
- FILETIME loc;
- SYSTEMTIME st;
- struct tm tm;
- time_t t;
+ struct timeval tv;
- if (!FileTimeToLocalFileTime(ft, &loc)) {
+ if (filetime_to_timeval(ft, &tv) == (time_t)-1)
return 0;
- }
- if (!FileTimeToSystemTime(&loc, &st)) {
- return 0;
- }
- memset(&tm, 0, sizeof(tm));
- tm.tm_year = st.wYear - 1900;
- tm.tm_mon = st.wMonth - 1;
- tm.tm_mday = st.wDay;
- tm.tm_hour = st.wHour;
- tm.tm_min = st.wMinute;
- tm.tm_sec = st.wSecond;
- tm.tm_isdst = -1;
- t = mktime(&tm);
- return t == -1 ? 0 : t;
+ else
+ return tv.tv_sec;
}
static unsigned