mirror of
https://github.com/reactos/reactos.git
synced 2025-06-25 23:49:43 +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,
|
VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
|
||||||
PTIME_FIELDS TimeFields)
|
PTIME_FIELDS TimeFields)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
const int *Months;
|
const int *Months;
|
||||||
int LeapSecondCorrections, SecondsInDay, CurYear;
|
int LeapSecondCorrections, SecondsInDay, CurYear;
|
||||||
int LeapYear, CurMonth, GMTOffset;
|
int LeapYear, CurMonth, GMTOffset;
|
||||||
long int Days;
|
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 */
|
/* Extract millisecond from time and convert time into seconds */
|
||||||
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
|
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
|
||||||
|
@ -122,21 +119,11 @@ VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
|
||||||
Days = Days - (long) Months[CurMonth];
|
Days = Days - (long) Months[CurMonth];
|
||||||
TimeFields->Month = (CSHORT) (CurMonth + 1);
|
TimeFields->Month = (CSHORT) (CurMonth + 1);
|
||||||
TimeFields->Day = (CSHORT) (Days + 1);
|
TimeFields->Day = (CSHORT) (Days + 1);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
||||||
PLARGE_INTEGER Time)
|
PLARGE_INTEGER Time)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
int CurYear, CurMonth;
|
int CurYear, CurMonth;
|
||||||
long long int rcTime;
|
long long int rcTime;
|
||||||
TIME_FIELDS TimeFields = *tfTimeFields;
|
TIME_FIELDS TimeFields = *tfTimeFields;
|
||||||
|
@ -194,11 +181,4 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
||||||
*Time = *(LARGE_INTEGER *)&rcTime;
|
*Time = *(LARGE_INTEGER *)&rcTime;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,13 +582,6 @@ VOID KeInitializeTimerImpl(VOID)
|
||||||
* Calculate the starting time for the system clock
|
* Calculate the starting time for the system clock
|
||||||
*/
|
*/
|
||||||
HalQueryRealTimeClock(&TimeFields);
|
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);
|
RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
|
||||||
boot_time=SystemBootTime.QuadPart;
|
boot_time=SystemBootTime.QuadPart;
|
||||||
system_time=boot_time;
|
system_time=boot_time;
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
#define TICKSPERMIN 600000000
|
||||||
#define TICKSPERSEC 10000000
|
#define TICKSPERSEC 10000000
|
||||||
#define TICKSPERMSEC 10000
|
#define TICKSPERMSEC 10000
|
||||||
#define SECSPERDAY 86400
|
#define SECSPERDAY 86400
|
||||||
|
@ -54,14 +56,11 @@ static __inline void NormalizeTimeFields(CSHORT *FieldToNormalize,
|
||||||
VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
|
VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
|
||||||
PTIME_FIELDS TimeFields)
|
PTIME_FIELDS TimeFields)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
const int *Months;
|
const int *Months;
|
||||||
int LeapSecondCorrections, SecondsInDay, CurYear;
|
int LeapSecondCorrections, SecondsInDay, CurYear;
|
||||||
int LeapYear, CurMonth, GMTOffset;
|
int LeapYear, CurMonth, GMTOffset;
|
||||||
long int Days;
|
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 */
|
/* Extract millisecond from time and convert time into seconds */
|
||||||
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
|
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
|
||||||
|
@ -122,22 +121,12 @@ VOID RtlTimeToTimeFields(PLARGE_INTEGER liTime,
|
||||||
Days = Days - (long) Months[CurMonth];
|
Days = Days - (long) Months[CurMonth];
|
||||||
TimeFields->Month = (CSHORT) (CurMonth + 1);
|
TimeFields->Month = (CSHORT) (CurMonth + 1);
|
||||||
TimeFields->Day = (CSHORT) (Days + 1);
|
TimeFields->Day = (CSHORT) (Days + 1);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
||||||
PLARGE_INTEGER Time)
|
PLARGE_INTEGER Time)
|
||||||
{
|
{
|
||||||
|
int CurYear, CurMonth, MonthLength;
|
||||||
#if 1
|
|
||||||
|
|
||||||
int CurYear, CurMonth;
|
|
||||||
long long int rcTime;
|
long long int rcTime;
|
||||||
TIME_FIELDS TimeFields = *tfTimeFields;
|
TIME_FIELDS TimeFields = *tfTimeFields;
|
||||||
|
|
||||||
|
@ -162,12 +151,13 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
||||||
&TimeFields.Day,
|
&TimeFields.Day,
|
||||||
HOURSPERDAY);
|
HOURSPERDAY);
|
||||||
}
|
}
|
||||||
while (TimeFields.Day >
|
MonthLength =
|
||||||
MonthLengths[IsLeapYear(TimeFields.Year)][TimeFields.Month - 1])
|
MonthLengths[IsLeapYear(TimeFields.Year)][TimeFields.Month - 1];
|
||||||
|
while (TimeFields.Day > MonthLength)
|
||||||
{
|
{
|
||||||
NormalizeTimeFields(&TimeFields.Day,
|
NormalizeTimeFields(&TimeFields.Day,
|
||||||
&TimeFields.Month,
|
&TimeFields.Month,
|
||||||
SECSPERMIN);
|
MonthLength);
|
||||||
}
|
}
|
||||||
while (TimeFields.Month > MONSPERYEAR)
|
while (TimeFields.Month > MONSPERYEAR)
|
||||||
{
|
{
|
||||||
|
@ -191,14 +181,11 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS tfTimeFields,
|
||||||
TimeFields.Second;
|
TimeFields.Second;
|
||||||
rcTime *= TICKSPERSEC;
|
rcTime *= TICKSPERSEC;
|
||||||
rcTime += TimeFields.Milliseconds * TICKSPERMSEC;
|
rcTime += TimeFields.Milliseconds * TICKSPERMSEC;
|
||||||
|
|
||||||
|
/* FIXME: handle UTC bias here */
|
||||||
|
// rcTime += UTCBias * TICKSPERMIN;
|
||||||
|
|
||||||
*Time = *(LARGE_INTEGER *)&rcTime;
|
*Time = *(LARGE_INTEGER *)&rcTime;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue