Fixed bug in RtlTimeToTimeFields().

svn path=/trunk/; revision=467
This commit is contained in:
Eric Kohl 1999-05-14 16:42:05 +00:00
parent 3ed33156f2
commit acc9e8fbc3
3 changed files with 13 additions and 53 deletions

View file

@ -54,14 +54,11 @@ static __inline void NormalizeTimeFields(CSHORT *FieldToNormalize,
VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
PTIME_FIELDS TimeFields)
{
#if 1
const int *Months;
int LeapSecondCorrections, SecondsInDay, CurYear;
int LeapYear, CurMonth, GMTOffset;
long int Days;
long long int Time = *(long long int *)liTime;
long long int Time = (long long int)liTime->QuadPart;
/* Extract millisecond from time and convert time into seconds */
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
@ -122,21 +119,11 @@ VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
Days = Days - (long) Months[CurMonth];
TimeFields->Month = (CSHORT) (CurMonth + 1);
TimeFields->Day = (CSHORT) (Days + 1);
#else
UNIMPLEMENTED;
#endif
}
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
PLARGE_INTEGER Time)
{
#if 1
int CurYear, CurMonth;
long long int rcTime;
TIME_FIELDS TimeFields = *tfTimeFields;
@ -194,11 +181,4 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
*Time = *(LARGE_INTEGER *)&rcTime;
return TRUE;
#else
UNIMPLEMENTED;
#endif
}

View file

@ -582,13 +582,6 @@ VOID KeInitializeTimerImpl(VOID)
* Calculate the starting time for the system clock
*/
HalQueryRealTimeClock(&TimeFields);
DbgPrint("Date: %d.%d.%d\nTime: %d:%d:%d\n",
TimeFields.Day,
TimeFields.Month,
TimeFields.Year,
TimeFields.Hour,
TimeFields.Minute,
TimeFields.Second);
RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
boot_time=SystemBootTime.QuadPart;
system_time=boot_time;

View file

@ -13,8 +13,10 @@
#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
#define TICKSPERMIN 600000000
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
#define SECSPERDAY 86400
@ -54,14 +56,11 @@ static __inline void NormalizeTimeFields(CSHORT *FieldToNormalize,
VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
PTIME_FIELDS TimeFields)
{
#if 1
const int *Months;
int LeapSecondCorrections, SecondsInDay, CurYear;
int LeapYear, CurMonth, GMTOffset;
long int Days;
long long int Time = *(long long int *)&liTime;
long long int Time = (long long int)liTime->QuadPart;
/* Extract millisecond from time and convert time into seconds */
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
@ -122,22 +121,12 @@ VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
Days = Days - (long) Months[CurMonth];
TimeFields->Month = (CSHORT) (CurMonth + 1);
TimeFields->Day = (CSHORT) (Days + 1);
#else
UNIMPLEMENTED;
#endif
}
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
PLARGE_INTEGER Time)
{
#if 1
int CurYear, CurMonth;
int CurYear, CurMonth, MonthLength;
long long int rcTime;
TIME_FIELDS TimeFields = *tfTimeFields;
@ -162,12 +151,13 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
&TimeFields.Day,
HOURSPERDAY);
}
while (TimeFields.Day >
MonthLengths[IsLeapYear(TimeFields.Year)][TimeFields.Month - 1])
MonthLength =
MonthLengths[IsLeapYear(TimeFields.Year)][TimeFields.Month - 1];
while (TimeFields.Day > MonthLength)
{
NormalizeTimeFields(&TimeFields.Day,
&TimeFields.Month,
SECSPERMIN);
MonthLength);
}
while (TimeFields.Month > MONSPERYEAR)
{
@ -191,14 +181,11 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
TimeFields.Second;
rcTime *= TICKSPERSEC;
rcTime += TimeFields.Milliseconds * TICKSPERMSEC;
/* FIXME: handle UTC bias here */
// rcTime += UTCBias * TICKSPERMIN;
*Time = *(LARGE_INTEGER *)&rcTime;
return TRUE;
#else
UNIMPLEMENTED;
#endif
}