Dmitry Timoshkov : msvcrt: localtime should accept any positive time value.

Alexandre Julliard julliard at wine.codeweavers.com
Sat Feb 11 13:37:13 CST 2006


Module: wine
Branch: refs/heads/master
Commit: ea0e7b339751c16dca08c73cfc292a843f641bda
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=ea0e7b339751c16dca08c73cfc292a843f641bda

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Sat Feb 11 12:15:21 2006 +0100

msvcrt: localtime should accept any positive time value.

---

 dlls/msvcrt/time.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index b2b67f1..819f905 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -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 (*secs < 0) return NULL;
+
+  time = *secs * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
 
   ft.dwHighDateTime = (UINT)(time >> 32);
   ft.dwLowDateTime  = (UINT)time;
@@ -161,8 +165,6 @@ struct MSVCRT_tm* MSVCRT_localtime(const
   FileTimeToLocalFileTime(&ft, &lft);
   FileTimeToSystemTime(&lft, &st);
 
-  if (st.wYear < 1970) return NULL;
-
   data->time_buffer.tm_sec  = st.wSecond;
   data->time_buffer.tm_min  = st.wMinute;
   data->time_buffer.tm_hour = st.wHour;




More information about the wine-cvs mailing list