mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:12:57 +00:00
RtlCutoverTimeToSystemTime(): The 4th argument determines whether the cutover time of the current year or the next cutover time is calculated.
svn path=/trunk/; revision=12864
This commit is contained in:
parent
d6f646a37f
commit
a366210998
2 changed files with 55 additions and 39 deletions
|
@ -112,7 +112,7 @@ static __inline VOID
|
||||||
InsertHeadList(
|
InsertHeadList(
|
||||||
IN PLIST_ENTRY ListHead,
|
IN PLIST_ENTRY ListHead,
|
||||||
IN PLIST_ENTRY Entry)
|
IN PLIST_ENTRY Entry)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY OldFlink;
|
PLIST_ENTRY OldFlink;
|
||||||
OldFlink = ListHead->Flink;
|
OldFlink = ListHead->Flink;
|
||||||
Entry->Flink = OldFlink;
|
Entry->Flink = OldFlink;
|
||||||
|
@ -140,7 +140,7 @@ static __inline VOID
|
||||||
InsertTailList(
|
InsertTailList(
|
||||||
IN PLIST_ENTRY ListHead,
|
IN PLIST_ENTRY ListHead,
|
||||||
IN PLIST_ENTRY Entry)
|
IN PLIST_ENTRY Entry)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY OldBlink;
|
PLIST_ENTRY OldBlink;
|
||||||
OldBlink = ListHead->Blink;
|
OldBlink = ListHead->Blink;
|
||||||
Entry->Flink = ListHead;
|
Entry->Flink = ListHead;
|
||||||
|
@ -882,7 +882,7 @@ BOOLEAN STDCALL
|
||||||
RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
|
RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
|
||||||
OUT PLARGE_INTEGER SystemTime,
|
OUT PLARGE_INTEGER SystemTime,
|
||||||
IN PLARGE_INTEGER CurrentTime,
|
IN PLARGE_INTEGER CurrentTime,
|
||||||
IN ULONG Unknown);
|
IN BOOLEAN ThisYearsCutoverOnly);
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
RtlDecompressBuffer(IN USHORT CompressionFormat,
|
RtlDecompressBuffer(IN USHORT CompressionFormat,
|
||||||
|
|
|
@ -74,7 +74,7 @@ BOOLEAN STDCALL
|
||||||
RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
|
RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
|
||||||
OUT PLARGE_INTEGER SystemTime,
|
OUT PLARGE_INTEGER SystemTime,
|
||||||
IN PLARGE_INTEGER CurrentTime,
|
IN PLARGE_INTEGER CurrentTime,
|
||||||
IN ULONG Unknown)
|
IN BOOLEAN ThisYearsCutoverOnly)
|
||||||
{
|
{
|
||||||
TIME_FIELDS AdjustedTimeFields;
|
TIME_FIELDS AdjustedTimeFields;
|
||||||
TIME_FIELDS CurrentTimeFields;
|
TIME_FIELDS CurrentTimeFields;
|
||||||
|
@ -82,6 +82,7 @@ RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
|
||||||
LARGE_INTEGER CutoverSystemTime;
|
LARGE_INTEGER CutoverSystemTime;
|
||||||
CSHORT MonthLength;
|
CSHORT MonthLength;
|
||||||
CSHORT Days;
|
CSHORT Days;
|
||||||
|
BOOLEAN NextYearsCutover = FALSE;
|
||||||
|
|
||||||
/* Check fixed cutover time */
|
/* Check fixed cutover time */
|
||||||
if (CutoverTimeFields->Year != 0)
|
if (CutoverTimeFields->Year != 0)
|
||||||
|
@ -105,45 +106,60 @@ RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
|
||||||
|
|
||||||
RtlTimeToTimeFields(CurrentTime, &CurrentTimeFields);
|
RtlTimeToTimeFields(CurrentTime, &CurrentTimeFields);
|
||||||
|
|
||||||
/* Compute the cutover time of the first day of the current month */
|
while (TRUE)
|
||||||
AdjustedTimeFields.Year = CurrentTimeFields.Year;
|
|
||||||
AdjustedTimeFields.Month = CutoverTimeFields->Month;
|
|
||||||
AdjustedTimeFields.Day = 1;
|
|
||||||
AdjustedTimeFields.Hour = CutoverTimeFields->Hour;
|
|
||||||
AdjustedTimeFields.Minute = CutoverTimeFields->Minute;
|
|
||||||
AdjustedTimeFields.Second = CutoverTimeFields->Second;
|
|
||||||
AdjustedTimeFields.Milliseconds = CutoverTimeFields->Milliseconds;
|
|
||||||
|
|
||||||
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
RtlTimeToTimeFields(&CutoverSystemTime, &CutoverSystemTimeFields);
|
|
||||||
|
|
||||||
/* Adjust day to first matching weekday */
|
|
||||||
if (CutoverSystemTimeFields.Weekday != CutoverTimeFields->Weekday)
|
|
||||||
{
|
{
|
||||||
if (CutoverSystemTimeFields.Weekday < CutoverTimeFields->Weekday)
|
/* Compute the cutover time of the first day of the current month */
|
||||||
Days = CutoverTimeFields->Weekday - CutoverSystemTimeFields.Weekday;
|
AdjustedTimeFields.Year = CurrentTimeFields.Year;
|
||||||
else
|
if (NextYearsCutover == TRUE)
|
||||||
Days = DAYSPERWEEK - (CutoverSystemTimeFields.Weekday - CutoverTimeFields->Weekday);
|
AdjustedTimeFields.Year++;
|
||||||
|
|
||||||
AdjustedTimeFields.Day += Days;
|
AdjustedTimeFields.Month = CutoverTimeFields->Month;
|
||||||
|
AdjustedTimeFields.Day = 1;
|
||||||
|
AdjustedTimeFields.Hour = CutoverTimeFields->Hour;
|
||||||
|
AdjustedTimeFields.Minute = CutoverTimeFields->Minute;
|
||||||
|
AdjustedTimeFields.Second = CutoverTimeFields->Second;
|
||||||
|
AdjustedTimeFields.Milliseconds = CutoverTimeFields->Milliseconds;
|
||||||
|
|
||||||
|
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
RtlTimeToTimeFields(&CutoverSystemTime, &CutoverSystemTimeFields);
|
||||||
|
|
||||||
|
/* Adjust day to first matching weekday */
|
||||||
|
if (CutoverSystemTimeFields.Weekday != CutoverTimeFields->Weekday)
|
||||||
|
{
|
||||||
|
if (CutoverSystemTimeFields.Weekday < CutoverTimeFields->Weekday)
|
||||||
|
Days = CutoverTimeFields->Weekday - CutoverSystemTimeFields.Weekday;
|
||||||
|
else
|
||||||
|
Days = DAYSPERWEEK - (CutoverSystemTimeFields.Weekday - CutoverTimeFields->Weekday);
|
||||||
|
|
||||||
|
AdjustedTimeFields.Day += Days;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adjust the number of weeks */
|
||||||
|
if (CutoverTimeFields->Day > 1)
|
||||||
|
{
|
||||||
|
Days = DAYSPERWEEK * (CutoverTimeFields->Day - 1);
|
||||||
|
MonthLength = MonthLengths[IsLeapYear(AdjustedTimeFields.Year)][AdjustedTimeFields.Month - 1];
|
||||||
|
if ((AdjustedTimeFields.Day + Days) > MonthLength)
|
||||||
|
Days -= DAYSPERWEEK;
|
||||||
|
|
||||||
|
AdjustedTimeFields.Day += Days;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (ThisYearsCutoverOnly == TRUE ||
|
||||||
|
NextYearsCutover == TRUE ||
|
||||||
|
CutoverSystemTime.QuadPart >= CurrentTime->QuadPart)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
NextYearsCutover = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust the number of weeks */
|
|
||||||
if (CutoverTimeFields->Day > 1)
|
|
||||||
{
|
|
||||||
Days = DAYSPERWEEK * (CutoverTimeFields->Day - 1);
|
|
||||||
MonthLength = MonthLengths[IsLeapYear(AdjustedTimeFields.Year)][AdjustedTimeFields.Month - 1];
|
|
||||||
if ((AdjustedTimeFields.Day + Days) > MonthLength)
|
|
||||||
Days -= DAYSPERWEEK;
|
|
||||||
|
|
||||||
AdjustedTimeFields.Day += Days;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
SystemTime->QuadPart = CutoverSystemTime.QuadPart;
|
SystemTime->QuadPart = CutoverSystemTime.QuadPart;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue