Re: localtime should accept any positive time value
Dmitry Timoshkov escreveu:
Hello,
Hello,
--- cvs/hq/wine/dlls/msvcrt/time.c 2006-01-23 20:50:58.000000000 -0600 +++ wine/dlls/msvcrt/time.c 2006-02-10 12:51:30.000000000 -0600 @@ -152,8 +152,12 @@ struct MSVCRT_tm* MSVCRT_localtime(const SYSTEMTIME st; DWORD tzid; TIME_ZONE_INFORMATION tzinfo; + ULONGLONG time;
- ULONGLONG time = *secs * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970; + /* time < 0 means a date before midnight of January 1, 1970 */ + if (time < 0) return NULL; + + time = *secs * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
You compared the "time" before it has a assigned value...
ft.dwHighDateTime = (UINT)(time >> 32); ft.dwLowDateTime = (UINT)time; @@ -161,7 +165,12 @@ struct MSVCRT_tm* MSVCRT_localtime(const FileTimeToLocalFileTime(&ft, &lft); FileTimeToSystemTime(&lft, &st);
- if (st.wYear < 1970) return NULL; + if (st.wYear < 1970) + { + /* if this happens it means that the sequence above does something wrong */ + FIXME("seconds since 1970 %ld => %d/%d/%d %02d:%02d:%02d\n", *secs, + st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond); + }
data->time_buffer.tm_sec = st.wSecond; data->time_buffer.tm_min = st.wMinute;
------------------------------------------------------------------------
participants (1)
-
Marcelo Duarte