diff --git a/reactos/lib/kernel32/misc/time.c b/reactos/lib/kernel32/misc/time.c index 2c9b9a2dc61..8ff2937920a 100644 --- a/reactos/lib/kernel32/misc/time.c +++ b/reactos/lib/kernel32/misc/time.c @@ -10,6 +10,9 @@ */ #include #include +#include + +TIME_ZONE_INFORMATION TimeZoneInformation; typedef struct __DOSTIME { @@ -27,26 +30,44 @@ typedef struct __DOSDATE #define NSPERSEC 10000000 + + #define SECOND 1 #define MINUTE 60*SECOND #define HOUR 60*MINUTE + #define DAY 24*HOUR #define YEAR (365*DAY) #define FOURYEAR (4*YEAR+DAY) #define CENTURY (25*FOURYEAR-DAY) -#define MILLENIUM (100*CENTURY) +#define FOURCENTURY (4*CENTURY+DAY) +#define MINUTE60 1 +#define HOUR60 60*MINUTE60 +#define DAY60 24*HOUR60 +#define YEAR60 (365*DAY60) +#define FOURYEAR60 (4*YEAR60+DAY60) +#define CENTURY60 (25*FOURYEAR60-DAY60) +#define FOURCENTURY60 (4*CENTURY60+DAY60) + +#ifdef COMPILER_LARGE_INTEGERS + #define RtlEnlargedUnsignedMultiply(m,n) (LARGE_INTEGER_QUAD_PART(((ULONGLONG)m)*((ULONGLONG)n))) + #define RtlEnlargedIntegerMultiply(m,n) (LARGE_INTEGER_QUAD_PART(((LONGLONG)m)*((LONGLONG)n))) + #define RtlLargeIntegerAdd(a1,a2) (LARGE_INTEGER_QUAD_PART(a1) + LARGE_INTEGER_QUAD_PART(a2)) + #define RtlExtendedIntegerMultiply(m1,m2) (LARGE_INTEGER_QUAD_PART(m1) * m2) + #define RtlLargeIntegerDivide(d1,d2,r1) LARGE_INTEGER_QUAD_PART(d1) / LARGE_INTEGER_QUAD_PART(d2);LARGE_INTEGER_QUAD_PART(*r1) = LARGE_INTEGER_QUAD_PART(d1) % LARGE_INTEGER_QUAD_PART(d2) + +#endif + #define LISECOND RtlEnlargedUnsignedMultiply(SECOND,NSPERSEC) -#define LIMINUTE RtlEnlargedUnsignedMultiply(MINUTE,NSPERSEC) -#define LIHOUR RtlEnlargedUnsignedMultiply(HOUR,NSPERSEC) -#define LIDAY RtlEnlargedUnsignedMultiply(DAY,NSPERSEC) -#define LIYEAR RtlEnlargedUnsignedMultiply(YEAR,NSPERSEC) -#define LIFOURYEAR RtlEnlargedUnsignedMultiply(FOURYEAR,NSPERSEC) -#define LICENTURY RtlEnlargedUnsignedMultiply(CENTURY,NSPERSEC) -#define LIMILLENIUM RtlEnlargedUnsignedMultiply(CENTURY,10*NSPERSEC) - - +#define LIMINUTE RtlEnlargedUnsignedMultiply(MINUTE60,60*NSPERSEC) +#define LIHOUR RtlEnlargedUnsignedMultiply(HOUR60,60*NSPERSEC) +#define LIDAY RtlEnlargedUnsignedMultiply(DAY60,60*NSPERSEC) +#define LIYEAR RtlEnlargedUnsignedMultiply(YEAR60,60*NSPERSEC) +#define LIFOURYEAR RtlEnlargedUnsignedMultiply(FOURYEAR60,60*NSPERSEC) +#define LICENTURY RtlEnlargedUnsignedMultiply(CENTURY60,60*NSPERSEC) +#define LIFOURCENTURY RtlEnlargedUnsignedMultiply(FOURCENTURY60,60*NSPERSEC) @@ -132,24 +153,29 @@ CompareFileTime( CONST FILETIME *lpFileTime2 ) { - + LARGE_INTEGER FileTime1, FileTime2; + + + if ( lpFileTime1 == NULL ) return 0; if ( lpFileTime2 == NULL ) return 0; - /* - if ((GET_LARGE_INTEGER_HIGH_PART(lpFileTime1)) > (GET_LARGE_INTEGER_HIGH_PART(lpFileTime2)) ) + + memcpy(&FileTime1,lpFileTime1,sizeof(FILETIME)); + memcpy(&FileTime2,lpFileTime2,sizeof(FILETIME)); + if ((GET_LARGE_INTEGER_HIGH_PART((FileTime1))) > (GET_LARGE_INTEGER_HIGH_PART((FileTime2))) ) return 1; - else if ((GET_LARGE_INTEGER_HIGH_PART(lpFileTime1)) < (GET_LARGE_INTEGER_HIGH_PART(lpFileTime2))) + else if ((GET_LARGE_INTEGER_HIGH_PART(FileTime1)) < (GET_LARGE_INTEGER_HIGH_PART(FileTime2))) return -1; - else if ((GET_LARGE_INTEGER_LOW_PART(lpFileTime1)) > (GET_LARGE_INTEGER_LOW_PART(lpFileTime2))) + else if ((GET_LARGE_INTEGER_LOW_PART(FileTime1)) > (GET_LARGE_INTEGER_LOW_PART(FileTime2))) return 1; - else if ((GET_LARGE_INTEGER_LOW_PART(lpFileTime1)) < (GET_LARGE_INTEGER_LOW_PART(lpFileTime2))) + else if ((GET_LARGE_INTEGER_LOW_PART(FileTime1)) < (GET_LARGE_INTEGER_LOW_PART(FileTime2))) return -1; else return 0; - */ + } VOID @@ -254,31 +280,31 @@ FileTimeToSystemTime( LARGE_INTEGER FileTime; - LARGE_INTEGER dwMillenium; - LARGE_INTEGER dwRemMillenium; + LARGE_INTEGER liFourCentury; + LARGE_INTEGER liRemFourCentury; - LARGE_INTEGER dwCentury; - LARGE_INTEGER dwRemCentury; + LARGE_INTEGER liCentury; + LARGE_INTEGER liRemCentury; - LARGE_INTEGER dwFourYear; - LARGE_INTEGER dwRemFourYear; + LARGE_INTEGER liFourYear; + LARGE_INTEGER liRemFourYear; - LARGE_INTEGER dwYear; - LARGE_INTEGER dwRemYear; + LARGE_INTEGER liYear; + LARGE_INTEGER liRemYear; - LARGE_INTEGER dwDay; - LARGE_INTEGER dwRemDay; + LARGE_INTEGER liDay; + LARGE_INTEGER liRemDay; - LARGE_INTEGER dwHour; - LARGE_INTEGER dwRemHour; + LARGE_INTEGER liHour; + LARGE_INTEGER liRemHour; - LARGE_INTEGER dwMinute; - LARGE_INTEGER dwRemMinute; + LARGE_INTEGER liMinute; + LARGE_INTEGER liRemMinute; - LARGE_INTEGER dwSecond; - LARGE_INTEGER dwRemSecond; + LARGE_INTEGER liSecond; + LARGE_INTEGER liRemSecond; - LARGE_INTEGER dwDayOfWeek; + LARGE_INTEGER liDayOfWeek; DWORD LeapDay = 0; @@ -287,19 +313,19 @@ FileTimeToSystemTime( memcpy(&FileTime,lpFileTime,sizeof(FILETIME)); - dwMillenium = RtlLargeIntegerDivide(FileTime,LIMILLENIUM,&dwRemMillenium); - dwCentury = RtlLargeIntegerDivide(dwRemMillenium,LICENTURY,&dwRemCentury); - dwFourYear = RtlLargeIntegerDivide(dwRemCentury,LIFOURYEAR,&dwRemFourYear); - dwYear = RtlLargeIntegerDivide(dwRemFourYear,LIYEAR,&dwRemYear); - dwDay = RtlLargeIntegerDivide(dwRemYear,LIDAY,&dwRemDay); - dwHour = RtlLargeIntegerDivide(dwRemDay,LIHOUR,&dwRemHour); - dwMinute = RtlLargeIntegerDivide(dwRemHour,LIMINUTE,&dwRemMinute); - dwSecond = RtlLargeIntegerDivide(dwRemMinute,LISECOND,&dwRemSecond); + liFourCentury = RtlLargeIntegerDivide(FileTime,LIFOURCENTURY,&liRemFourCentury); + liCentury = RtlLargeIntegerDivide(liRemFourCentury,LICENTURY,&liRemCentury); + liFourYear = RtlLargeIntegerDivide(liRemCentury,LIFOURYEAR,&liRemFourYear); + liYear = RtlLargeIntegerDivide(liRemFourYear,LIYEAR,&liRemYear); + liDay = RtlLargeIntegerDivide(liRemYear,LIDAY,&liRemDay); + liHour = RtlLargeIntegerDivide(liRemDay,LIHOUR,&liRemHour); + liMinute = RtlLargeIntegerDivide(liRemHour,LIMINUTE,&liRemMinute); + liSecond = RtlLargeIntegerDivide(liRemMinute,LISECOND,&liRemSecond); - lpSystemTime->wHour= (WORD) GET_LARGE_INTEGER_LOW_PART(dwHour); - lpSystemTime->wMinute= (WORD)GET_LARGE_INTEGER_LOW_PART(dwMinute); - lpSystemTime->wSecond= (WORD)GET_LARGE_INTEGER_LOW_PART(dwSecond); - lpSystemTime->wMilliseconds = (WORD)(GET_LARGE_INTEGER_LOW_PART(dwRemSecond)/10000); + lpSystemTime->wHour= (WORD) GET_LARGE_INTEGER_LOW_PART(liHour); + lpSystemTime->wMinute= (WORD)GET_LARGE_INTEGER_LOW_PART(liMinute); + lpSystemTime->wSecond= (WORD)GET_LARGE_INTEGER_LOW_PART(liSecond); + lpSystemTime->wMilliseconds = (WORD)(GET_LARGE_INTEGER_LOW_PART(liRemSecond)/10000); if ( lpSystemTime->wSecond > 60 ) { @@ -314,13 +340,14 @@ FileTimeToSystemTime( if (lpSystemTime->wHour > 24 ) { lpSystemTime->wHour-= 24; - SET_LARGE_INTEGER_LOW_PART(dwDay,GET_LARGE_INTEGER_LOW_PART(dwDay)+1); + SET_LARGE_INTEGER_LOW_PART(liDay,GET_LARGE_INTEGER_LOW_PART(liDay)+1); } //FIXME since 1972 some years have a leap second [ aprox 15 out of 20 ] + // printf("400 %d 100 %d 4 %d 1 %d\n",(LONG)GET_LARGE_INTEGER_LOW_PART(liFourCentury) , (LONG)GET_LARGE_INTEGER_LOW_PART(liCentury), (LONG)GET_LARGE_INTEGER_LOW_PART(liFourYear), (LONG)GET_LARGE_INTEGER_LOW_PART(liYear)); // if leap year - lpSystemTime->wYear= 1601 + 1000* (LONG)GET_LARGE_INTEGER_LOW_PART(dwMillenium) + 100 * (LONG)GET_LARGE_INTEGER_LOW_PART(dwCentury) + 4*(LONG)GET_LARGE_INTEGER_LOW_PART(dwFourYear) + (LONG)GET_LARGE_INTEGER_LOW_PART(dwYear); + lpSystemTime->wYear= 1601 + 400* (WORD)GET_LARGE_INTEGER_LOW_PART(liFourCentury) + 100 * (WORD)GET_LARGE_INTEGER_LOW_PART(liCentury) + 4*(LONG)GET_LARGE_INTEGER_LOW_PART(liFourYear) + (WORD)GET_LARGE_INTEGER_LOW_PART(liYear); if ( (lpSystemTime->wYear % 4 == 0 && lpSystemTime->wYear % 100 != 0) || lpSystemTime->wYear % 400 == 0) LeapDay = 1; @@ -329,58 +356,58 @@ FileTimeToSystemTime( - if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 0 && GET_LARGE_INTEGER_LOW_PART(dwDay) < 31 ) { + if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 0 && GET_LARGE_INTEGER_LOW_PART(liDay) < 31 ) { lpSystemTime->wMonth = 1; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1; + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1; } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 31 && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 59 + LeapDay )) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 31 && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 59 + LeapDay )) { lpSystemTime->wMonth = 2; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - 31; + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - 31; } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 59 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 90 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 59 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 90 + LeapDay ) ) { lpSystemTime->wMonth = 3; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 59 + LeapDay); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 59 + LeapDay); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 90+ LeapDay && GET_LARGE_INTEGER_LOW_PART(dwDay) < 120 + LeapDay) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 90+ LeapDay && GET_LARGE_INTEGER_LOW_PART(liDay) < 120 + LeapDay) { lpSystemTime->wMonth = 4; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (31 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (31 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 120 + LeapDay && GET_LARGE_INTEGER_LOW_PART(dwDay) < 151 + LeapDay ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 120 + LeapDay && GET_LARGE_INTEGER_LOW_PART(liDay) < 151 + LeapDay ) { lpSystemTime->wMonth = 5; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (120 + LeapDay); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (120 + LeapDay); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 151 + LeapDay) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 181 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 151 + LeapDay) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 181 + LeapDay ) ) { lpSystemTime->wMonth = 6; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 151 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 151 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 181 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 212 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 181 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 212 + LeapDay ) ) { lpSystemTime->wMonth = 7; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 181 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 181 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 212 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 243 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 212 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 243 + LeapDay ) ) { lpSystemTime->wMonth = 8; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (212 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (212 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 243+ LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 273 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 243+ LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 273 + LeapDay ) ) { lpSystemTime->wMonth = 9; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 243 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 243 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 273 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 304 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 273 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 304 + LeapDay ) ) { lpSystemTime->wMonth = 10; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 273 + LeapDay); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 273 + LeapDay); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 304 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 334 + LeapDay ) ) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 304 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 334 + LeapDay ) ) { lpSystemTime->wMonth = 11; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 304 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 304 + LeapDay ); } - else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 334 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 365 + LeapDay )) { + else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 334 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 365 + LeapDay )) { lpSystemTime->wMonth = 12; - lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 334 + LeapDay ); + lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 334 + LeapDay ); } - dwDayOfWeek = RtlLargeIntegerDivide(FileTime,LIDAY,&dwRemDay); - lpSystemTime->wDayOfWeek = 1 + GET_LARGE_INTEGER_LOW_PART(dwDayOfWeek) % 7; + liDayOfWeek = RtlLargeIntegerDivide(FileTime,LIDAY,&liRemDay); + lpSystemTime->wDayOfWeek = 1 + GET_LARGE_INTEGER_LOW_PART(liDayOfWeek) % 7; @@ -396,9 +423,18 @@ FileTimeToLocalFileTime( LPFILETIME lpLocalFileTime ) { - // memcpy(lpLocalFileTime,lpFileTime,sizeof(FILETIME)); - - return TRUE; + TIME_ZONE_INFORMATION TimeZoneInformation; + LARGE_INTEGER *FileTime, *LocalFileTime; + + if ( lpFileTime == NULL || lpLocalFileTime == NULL ) + return FALSE; + FileTime = (LARGE_INTEGER *)lpFileTime; + LocalFileTime = (LARGE_INTEGER *)lpLocalFileTime; + + GetTimeZoneInformation(&TimeZoneInformation); + *LocalFileTime = RtlLargeIntegerAdd(*FileTime,RtlExtendedIntegerMultiply((LIMINUTE),(LONG)-1*TimeZoneInformation.Bias)); + + return TRUE; } WINBOOL @@ -408,8 +444,18 @@ LocalFileTimeToFileTime( LPFILETIME lpFileTime ) { - - return TRUE; + TIME_ZONE_INFORMATION TimeZoneInformation; + LARGE_INTEGER *FileTime, *LocalFileTime; + + if ( lpFileTime == NULL || lpLocalFileTime == NULL ) + return FALSE; + FileTime = (LARGE_INTEGER *)lpFileTime; + LocalFileTime = (LARGE_INTEGER *)lpLocalFileTime; + + GetTimeZoneInformation(&TimeZoneInformation); + *FileTime = RtlLargeIntegerAdd(*LocalFileTime,RtlExtendedIntegerMultiply((LIMINUTE),(LONG)TimeZoneInformation.Bias)); + + return TRUE; } VOID @@ -418,7 +464,13 @@ GetLocalTime( LPSYSTEMTIME lpSystemTime ) { - GetSystemTime(lpSystemTime); + + FILETIME FileTime; + FILETIME LocalTime; + GetSystemTimeAsFileTime(&FileTime); + FileTimeToLocalFileTime(&FileTime,&LocalTime); + FileTimeToSystemTime(&LocalTime,lpSystemTime); + return; } @@ -440,8 +492,17 @@ SetLocalTime( CONST SYSTEMTIME *lpSystemTime ) { - return SetSystemTime(lpSystemTime); + NTSTATUS errCode; + FILETIME FileTime, LocalTime; + SystemTimeToFileTime(lpSystemTime,&LocalTime); + LocalFileTimeToFileTime(&LocalTime,&FileTime); + errCode = NtSetSystemTime ((LARGE_INTEGER *)&FileTime,(LARGE_INTEGER *)&FileTime); + if ( !NT_SUCCESS(errCode) ) + return FALSE; + return TRUE; + } + WINBOOL STDCALL SetSystemTime( @@ -452,37 +513,12 @@ SetSystemTime( LARGE_INTEGER NewSystemTime; SystemTimeToFileTime(lpSystemTime, (FILETIME *)&NewSystemTime); - errCode = NtSetSystemTime (&NewSystemTime,&NewSystemTime); + errCode = NtSetSystemTime ((LARGE_INTEGER *)&NewSystemTime,(LARGE_INTEGER *)&NewSystemTime); if ( !NT_SUCCESS(errCode) ) return FALSE; return TRUE; } -/* -typedef struct _TIME_ZONE_INFORMATION { // tzi - LONG Bias; - WCHAR StandardName[ 32 ]; - SYSTEMTIME StandardDate; - LONG StandardBias; - WCHAR DaylightName[ 32 ]; - SYSTEMTIME DaylightDate; - LONG DaylightBias; -} TIME_ZONE_INFORMATION; -TIME_ZONE_INFORMATION TimeZoneInformation = {60,"CET",; - -*/ -DWORD -STDCALL -GetTimeZoneInformation( - LPTIME_ZONE_INFORMATION lpTimeZoneInformation - ) -{ - // aprintf("GetTimeZoneInformation()\n"); - - // memset(lpTimeZoneInformation, 0, sizeof(TIME_ZONE_INFORMATION)); - - return TIME_ZONE_ID_UNKNOWN; -} DWORD STDCALL @@ -498,4 +534,86 @@ GetTickCount(VOID) ULONG UpTime; NtGetTickCount(&UpTime); return UpTime; -} \ No newline at end of file +} + + + +VOID __InitTimeZoneInformation(VOID) +{ + TimeZoneInformation.Bias = 60; + TimeZoneInformation.StandardName[0] = 0; + TimeZoneInformation.StandardDate.wMonth = 9; + TimeZoneInformation.StandardDate.wDay = 21; + TimeZoneInformation.StandardBias = 0; + TimeZoneInformation.DaylightName[0] = 0; + TimeZoneInformation.DaylightDate.wMonth = 3; + TimeZoneInformation.DaylightDate.wDay = 21; + TimeZoneInformation.DaylightBias = -60; + +} + +WINBOOL +STDCALL +SetTimeZoneInformation( + CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation + ) +{ + if ( lpTimeZoneInformation == NULL ) + return FALSE; + TimeZoneInformation = *lpTimeZoneInformation; + return TRUE; +} + + + +DWORD +STDCALL +GetTimeZoneInformation( + LPTIME_ZONE_INFORMATION lpTimeZoneInformation + ) +{ + // aprintf("GetTimeZoneInformation()\n"); + SYSTEMTIME SystemTime; + if ( lpTimeZoneInformation == NULL ) + return -1; + + + *lpTimeZoneInformation = TimeZoneInformation; +/* + FIXME I should not recurse + GetLocalTime(&SystemTime); + if ( TimeZoneInformation.DaylightDate.wMonth == 0 || TimeZoneInformation.StandardDate.wMonth == 0 ) + return TIME_ZONE_ID_UNKNOWN; + else if ( ( SystemTime.wMonth > TimeZoneInformation.DaylightDate.wMonth && + SystemTime.wDay > TimeZoneInformation.DaylightDate.wDay ) && + ( SystemTime.wMonth < TimeZoneInformation.StandardDate.wMonth && + SystemTime.wDay < TimeZoneInformation.StandardDate.wDay ) ) + return TIME_ZONE_ID_DAYLIGHT; + else + return TIME_ZONE_ID_STANDARD; + */ + return TIME_ZONE_ID_UNKNOWN; +} + + +WINBOOL +STDCALL +SetSystemTimeAdjustment( + DWORD dwTimeAdjustment, + WINBOOL bTimeAdjustmentDisabled + ) +{ + return FALSE; +} + + +WINBOOL +STDCALL +GetSystemTimeAdjustment( + PDWORD lpTimeAdjustment, + PDWORD lpTimeIncrement, + PWINBOOL lpTimeAdjustmentDisabled + ) +{ + return FALSE; +}