Skip to content

Commit 48df11d

Browse files
committed
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
1 parent baac9b0 commit 48df11d

File tree

3 files changed

+60
-38
lines changed

3 files changed

+60
-38
lines changed

ChangeLog

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
2+
3+
* win32/win32.c (filetime_to_timeval): new function, split from
4+
gettimeofday().
5+
6+
* win32/win32.c (gettimeofday): use above function.
7+
8+
* win32/win32.c (filetime_to_unixtime): ditto. [ruby-dev:36135]
9+
10+
Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
11+
12+
* win32/win32.c (gettimeofday): tv_usec is usec, not msec.
13+
[ruby-dev:36094]
14+
15+
Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
16+
17+
* win32/win32.c (gettimeofday): calc tv_sec and tv_usec from system
18+
time by myself. [ruby-dev:36084]
19+
20+
Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
21+
22+
* win32/win32.c (gettimeofday): shouldn't use mktime(2) because it's
23+
buggy about handling summer time.
24+
reported by Yoshikawa <yoshixool AT gmail.com> at [ruby-dev:36071]
25+
126
Tue Jan 20 12:23:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
227

328
* lib/scanf.rb (Scanf::FormatSpecifier#initialize): %i should accept

version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#define RUBY_VERSION "1.8.7"
2-
#define RUBY_RELEASE_DATE "2009-01-20"
2+
#define RUBY_RELEASE_DATE "2009-01-21"
33
#define RUBY_VERSION_CODE 187
4-
#define RUBY_RELEASE_CODE 20090120
5-
#define RUBY_PATCHLEVEL 90
4+
#define RUBY_RELEASE_CODE 20090121
5+
#define RUBY_PATCHLEVEL 91
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8
99
#define RUBY_VERSION_TEENY 7
1010
#define RUBY_RELEASE_YEAR 2009
1111
#define RUBY_RELEASE_MONTH 1
12-
#define RUBY_RELEASE_DAY 20
12+
#define RUBY_RELEASE_DAY 21
1313

1414
#ifdef RUBY_EXTERN
1515
RUBY_EXTERN const char ruby_version[];

win32/win32.c

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,24 +2975,36 @@ waitpid(rb_pid_t pid, int *stat_loc, int options)
29752975

29762976
#include <sys/timeb.h>
29772977

2978+
static int
2979+
filetime_to_timeval(const FILETIME* ft, struct timeval *tv)
2980+
{
2981+
ULARGE_INTEGER tmp;
2982+
unsigned LONG_LONG lt;
2983+
2984+
tmp.LowPart = ft->dwLowDateTime;
2985+
tmp.HighPart = ft->dwHighDateTime;
2986+
lt = tmp.QuadPart;
2987+
2988+
/* lt is now 100-nanosec intervals since 1601/01/01 00:00:00 UTC,
2989+
convert it into UNIX time (since 1970/01/01 00:00:00 UTC).
2990+
the first leap second is at 1972/06/30, so we doesn't need to think
2991+
about it. */
2992+
lt /= 10; /* to usec */
2993+
lt -= (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60 * 1000 * 1000;
2994+
2995+
tv->tv_sec = lt / (1000 * 1000);
2996+
tv->tv_usec = lt % (1000 * 1000);
2997+
2998+
return tv->tv_sec > 0 ? 0 : -1;
2999+
}
3000+
29783001
int _cdecl
29793002
gettimeofday(struct timeval *tv, struct timezone *tz)
29803003
{
2981-
SYSTEMTIME st;
2982-
time_t t;
2983-
struct tm tm;
2984-
2985-
GetLocalTime(&st);
2986-
tm.tm_sec = st.wSecond;
2987-
tm.tm_min = st.wMinute;
2988-
tm.tm_hour = st.wHour;
2989-
tm.tm_mday = st.wDay;
2990-
tm.tm_mon = st.wMonth - 1;
2991-
tm.tm_year = st.wYear - 1900;
2992-
tm.tm_isdst = -1;
2993-
t = mktime(&tm);
2994-
tv->tv_sec = t;
2995-
tv->tv_usec = st.wMilliseconds * 1000;
3004+
FILETIME ft;
3005+
3006+
GetSystemTimeAsFileTime(&ft);
3007+
filetime_to_timeval(&ft, tv);
29963008

29973009
return 0;
29983010
}
@@ -3267,27 +3279,12 @@ isUNCRoot(const char *path)
32673279
static time_t
32683280
filetime_to_unixtime(const FILETIME *ft)
32693281
{
3270-
FILETIME loc;
3271-
SYSTEMTIME st;
3272-
struct tm tm;
3273-
time_t t;
3282+
struct timeval tv;
32743283

3275-
if (!FileTimeToLocalFileTime(ft, &loc)) {
3284+
if (filetime_to_timeval(ft, &tv) == (time_t)-1)
32763285
return 0;
3277-
}
3278-
if (!FileTimeToSystemTime(&loc, &st)) {
3279-
return 0;
3280-
}
3281-
memset(&tm, 0, sizeof(tm));
3282-
tm.tm_year = st.wYear - 1900;
3283-
tm.tm_mon = st.wMonth - 1;
3284-
tm.tm_mday = st.wDay;
3285-
tm.tm_hour = st.wHour;
3286-
tm.tm_min = st.wMinute;
3287-
tm.tm_sec = st.wSecond;
3288-
tm.tm_isdst = -1;
3289-
t = mktime(&tm);
3290-
return t == -1 ? 0 : t;
3286+
else
3287+
return tv.tv_sec;
32913288
}
32923289

32933290
static unsigned

0 commit comments

Comments
 (0)