OK, will fix. All callers use JS function EquivalentTime to put the argument in the 32-bit range. EquivalentTime needs to be changed, so it starts after 1970. Runtime checks are corrected.
On Mon, Dec 1, 2008 at 3:49 PM, Søren Gjesse <[EMAIL PROTECTED]> wrote: > We already use _USE_32BIT_TIME_T in both SCons and Visual Studio builds. > /Søren > > > On Mon, Dec 1, 2008 at 3:19 PM, Mads Ager <[EMAIL PROTECTED]> wrote: > >> >> Thanks Dean. Bill put in explicit checks for that and we make sure to >> convert to a reasonable date in the caller. >> >> -- Mads >> >> On Mon, Dec 1, 2008 at 3:11 PM, Dean McNamee <[EMAIL PROTECTED]> wrote: >> > Just an fyi, beware of: >> > >> > http://securityvulns.com/advisories/year3000.asp >> > >> > -- dean >> > >> > On Mon, Dec 1, 2008 at 5:50 AM, <[EMAIL PROTECTED]> wrote: >> >> >> >> Reviewers: Mike Belshe, Mads Ager, >> >> >> >> Message: >> >> Here is the change in the daylight saving time lookup >> >> code. I also have a browser test for it, which I will email you. I >> >> would like someone in the US to test it on a US Windows system, to >> check >> >> US DST calculations. >> >> >> >> It is much faster on Windows XP SP 3. >> >> >> >> Description: >> >> Change Windows daylight saving time calculations to >> >> use C stdlib local time functions, not Win32 functions. >> >> Win32 time functions slowed down with Windows XP SP3. >> >> >> >> Please review this at http://codereview.chromium.org/12824 >> >> >> >> SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ >> >> >> >> Affected files: >> >> M src/platform-win32.cc >> >> >> >> >> >> Index: src/platform-win32.cc >> >> =================================================================== >> >> --- src/platform-win32.cc (revision 875) >> >> +++ src/platform-win32.cc (working copy) >> >> @@ -56,6 +56,7 @@ >> >> >> >> #include <windows.h> >> >> >> >> +#include <time.h> // For LocalOffset() implementation. >> >> #include <mmsystem.h> // For timeGetTime(). >> >> #include <dbghelp.h> // For SymLoadModule64 and al. >> >> #include <tlhelp32.h> // For Module32First and al. >> >> @@ -323,6 +324,8 @@ >> >> // Just return if timezone information has already been initialized. >> >> if (tz_initialized_) return; >> >> >> >> + // Initialize POSIX time zone data >> >> + _tzset(); >> >> // Obtain timezone information from operating system. >> >> memset(&tzinfo_, 0, sizeof(tzinfo_)); >> >> if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) { >> >> @@ -396,9 +399,9 @@ >> >> static bool initialized = false; >> >> static TimeStamp init_time; >> >> static DWORD init_ticks; >> >> - static const int kHundredNanosecondsPerSecond = 10000; >> >> - static const int kMaxClockElapsedTime = >> >> - 60*60*24*kHundredNanosecondsPerSecond; // 1 day >> >> + static const int64_t kHundredNanosecondsPerSecond = 10000000; >> >> + static const int64_t kMaxClockElapsedTime = >> >> + 60*kHundredNanosecondsPerSecond; // 1 minute >> >> >> >> // If we are uninitialized, we need to resync the clock. >> >> bool needs_resync = !initialized; >> >> @@ -433,26 +436,31 @@ >> >> // Initialize timezone information, if needed. >> >> TzSet(); >> >> >> >> - // Convert timestamp to date/time components. These are now in UTC >> >> - // format. NB: Please do not replace the following three calls with >> one >> >> - // call to FileTimeToLocalFileTime(), because it does not handle >> >> - // daylight saving correctly. >> >> - SYSTEMTIME utc; >> >> - FileTimeToSystemTime(&ft(), &utc); >> >> + Time rounded_to_second(*this); >> >> + rounded_to_second.t() /= 1000 * kTimeScaler; >> >> + rounded_to_second.t() *= 1000 * kTimeScaler; >> >> + // Convert to local time using POSIX localtime function. >> >> + // Windows XP Service Pack 3 made SystemTimeToTzSpecificLocalTime() >> >> + // very slow. Other browsers use localtime(). >> >> >> >> - // Convert to local time, using timezone information. >> >> - SYSTEMTIME local; >> >> - SystemTimeToTzSpecificLocalTime(&tzinfo_, &utc, &local); >> >> + // Convert from JavaScript milliseconds past 1/1/1970 0:00:00 to >> >> + // POSIX seconds past 1/1/1970 0:00:00. >> >> + time_t posix_time = static_cast<time_t>(this->ToJSTime() / 1000); >> >> + // Conversion to standard year by callers of this function should >> ensure >> >> + // that the time is between the limits Jan 1, 1970 and Jan 1, 3001. >> >> + // Exceeding these limits will terminate the program. This is >> >> + // a Windows security feature. >> >> + if (posix_time >= 32535244800i64) return 0; // Jan 1, 3001. >> >> _MAX__TIME64_T >> >> + // is reportedly the wrong limit, and is not declared in a standard >> >> header. >> >> + if (posix_time < 0 ) return 0; >> >> + // Convert to local time, as struct with fields for day, hour, year, >> etc. >> >> + tm posix_local_time_struct; >> >> + if (localtime_s(&posix_local_time_struct, &posix_time)) return 0; >> >> + // Convert local time in struct to POSIX time as if it were a UTC >> time. >> >> + time_t local_posix_time = _mkgmtime(&posix_local_time_struct); >> >> + Time localtime(1000.0 * local_posix_time); >> >> >> >> - // Convert local time back to a timestamp. This timestamp now >> >> - // has a bias similar to the local timezone bias in effect >> >> - // at the time of the original timestamp. >> >> - Time localtime; >> >> - SystemTimeToFileTime(&local, &localtime.ft()); >> >> - >> >> - // The difference between the new local timestamp and the original >> >> - // timestamp and is the local timezone offset. >> >> - return localtime.Diff(this); >> >> + return localtime.Diff(&rounded_to_second); >> >> } >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > >> >> >> > > > > -- We can IMAGINE what is not --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
