mirror of
https://github.com/reactos/reactos.git
synced 2025-06-25 01:30:13 +00:00
Fixed bug in RtlTimeToTimeFields().
svn path=/trunk/; revision=467
This commit is contained in:
parent
3ed33156f2
commit
acc9e8fbc3
3 changed files with 13 additions and 53 deletions
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue