msvcrt: localtime should accept any positive time value.

This commit is contained in:
Dmitry Timoshkov 2006-02-11 12:15:21 +01:00 committed by Alexandre Julliard
parent b4b3e6a165
commit ea0e7b3397
1 changed files with 5 additions and 3 deletions

View File

@ -152,8 +152,12 @@ struct MSVCRT_tm* MSVCRT_localtime(const MSVCRT_time_t* secs)
SYSTEMTIME st; SYSTEMTIME st;
DWORD tzid; DWORD tzid;
TIME_ZONE_INFORMATION tzinfo; 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 (*secs < 0) return NULL;
time = *secs * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
ft.dwHighDateTime = (UINT)(time >> 32); ft.dwHighDateTime = (UINT)(time >> 32);
ft.dwLowDateTime = (UINT)time; ft.dwLowDateTime = (UINT)time;
@ -161,8 +165,6 @@ struct MSVCRT_tm* MSVCRT_localtime(const MSVCRT_time_t* secs)
FileTimeToLocalFileTime(&ft, &lft); FileTimeToLocalFileTime(&ft, &lft);
FileTimeToSystemTime(&lft, &st); FileTimeToSystemTime(&lft, &st);
if (st.wYear < 1970) return NULL;
data->time_buffer.tm_sec = st.wSecond; data->time_buffer.tm_sec = st.wSecond;
data->time_buffer.tm_min = st.wMinute; data->time_buffer.tm_min = st.wMinute;
data->time_buffer.tm_hour = st.wHour; data->time_buffer.tm_hour = st.wHour;