Fix RtlTimeToTimeFields

György 'Nog' Jeney nog at sdf.lonestar.org
Sat Nov 2 02:16:26 CST 2002


ChangeLog:
 * dlls/ntdll/time.c
   - Fix RtlTimeToTimeFields to actually work.
   - Reomve comments about leap seconds, windows doesn't take that into   
account.

nog.

-------------- next part --------------
Index: dlls/ntdll/time.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/time.c,v
retrieving revision 1.20
diff -u -r1.20 time.c
--- dlls/ntdll/time.c	12 Sep 2002 22:07:03 -0000	1.20
+++ dlls/ntdll/time.c	2 Nov 2002 07:59:57 -0000
@@ -86,44 +86,32 @@
 	PTIME_FIELDS TimeFields)
 {
 	const int *Months;
-	int LeapSecondCorrections, SecondsInDay, CurYear;
-	int LeapYear, CurMonth, GMTOffset;
+	int SecondsInDay, CurYear;
+	int LeapYear, CurMonth;
 	long int Days;
-	LONGLONG Time = *(LONGLONG *)&liTime;
+	LONGLONG Time;
+
+	Time = liTime->s.HighPart;
+	Time <<= 32;
+	Time += liTime->s.LowPart;
 
 	/* Extract millisecond from time and convert time into seconds */
 	TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
 	Time = Time / TICKSPERSEC;
 
-	/* FIXME: Compute the number of leap second corrections here */
-	LeapSecondCorrections = 0;
-
-	/* FIXME: get the GMT offset here */
-	GMTOffset = 0;
+	/* The native version of RtlTimeToTimeFields does not take leap seconds
+	 * into account */
 
 	/* Split the time into days and seconds within the day */
 	Days = Time / SECSPERDAY;
 	SecondsInDay = Time % SECSPERDAY;
 
-	/* Adjust the values for GMT and leap seconds */
-	SecondsInDay += (GMTOffset - LeapSecondCorrections);
-	while (SecondsInDay < 0)
-	{ SecondsInDay += SECSPERDAY;
-	  Days--;
-	}
-	while (SecondsInDay >= SECSPERDAY)
-	{ SecondsInDay -= SECSPERDAY;
-	  Days++;
-	}
-
 	/* compute time of day */
 	TimeFields->Hour = (CSHORT) (SecondsInDay / SECSPERHOUR);
 	SecondsInDay = SecondsInDay % SECSPERHOUR;
 	TimeFields->Minute = (CSHORT) (SecondsInDay / SECSPERMIN);
 	TimeFields->Second = (CSHORT) (SecondsInDay % SECSPERMIN);
 
-	/* FIXME: handle the possibility that we are on a leap second (i.e. Second = 60) */
-
 	/* compute day of week */
 	TimeFields->Weekday = (CSHORT) ((EPOCHWEEKDAY + Days) % DAYSPERWEEK);
 
@@ -147,6 +135,7 @@
 	TimeFields->Month = (CSHORT) (CurMonth + 1);
 	TimeFields->Day = (CSHORT) (Days + 1);
 }
+
 /******************************************************************************
  *  RtlTimeFieldsToTime		[NTDLL.@]
  *



More information about the wine-patches mailing list