Comment #4 on issue 1386 by [email protected]: new Date() returns invalid
time zone offset, and hour field
http://code.google.com/p/v8/issues/detail?id=1386
You are right whesse, TIME_ZONE_INFORMATION.Bias does not include DST
adjustment. I have the following codes now:
int64_t Time::LocalOffset() {
TIME_ZONE_INFORMATION tzinfo;
DWORD dwRet;
int64_t bias;
dwRet = GetTimeZoneInformation(&tzinfo);
if(dwRet == TIME_ZONE_ID_DAYLIGHT)
{
bias = tzinfo.Bias + tzinfo.DaylightBias;
}
else // TIME_ZONE_ID_STANDARD or TIME_ZONE_ID_UNKNOWN?
{
bias = tzinfo.Bias + tzinfo.StandardBias;
}
return bias * - kMsPerMinute;
}
My codes might have missed something else again, as I did not test with all
cases, I have tested these dates:
Tue Feb 01 2039 00:00:00 GMT+0800 (Malay Peninsula Standard Time)
Thu May 26 2011 03:28:55 GMT+0800 (Malay Peninsula Standard Time)
Tue Feb 01 2039 00:00:00 GMT+0100 (GMT Daylight Time)
Wed May 25 2011 20:29:11 GMT+0100 (GMT Daylight Time)
Tue Feb 01 2039 00:00:00 GMT+0000 (GMT Standard Time)
Tue Nov 01 2011 20:29:54 GMT+0000 (GMT Standard Time)
Tue Feb 01 2039 00:00:00 GMT-0700 (Pacific Daylight Time)
Wed May 25 2011 12:31:13 GMT-0700 (Pacific Daylight Time)
Tue Feb 01 2039 00:00:00 GMT-0800 (Pacific Standard Time)
Thu Dec 01 2011 12:31:35 GMT-0800 (Pacific Standard Time)
Hope this help.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev