RtlCutoverTimeToSystemTime(): The 4th argument determines whether the
cutover time of the current year or the next cutover time is calculated.
Modified: trunk/reactos/include/ntos/rtl.h
Modified: trunk/reactos/lib/rtl/time.c
_____
Modified: trunk/reactos/include/ntos/rtl.h
--- trunk/reactos/include/ntos/rtl.h 2005-01-07 09:21:53 UTC (rev
12863)
+++ trunk/reactos/include/ntos/rtl.h 2005-01-07 12:58:46 UTC (rev
12864)
@@ -112,7 +112,7 @@
InsertHeadList(
IN PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry)
-{
+{
PLIST_ENTRY OldFlink;
OldFlink = ListHead->Flink;
Entry->Flink = OldFlink;
@@ -140,7 +140,7 @@
InsertTailList(
IN PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry)
-{
+{
PLIST_ENTRY OldBlink;
OldBlink = ListHead->Blink;
Entry->Flink = ListHead;
@@ -882,7 +882,7 @@
RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
OUT PLARGE_INTEGER SystemTime,
IN PLARGE_INTEGER CurrentTime,
- IN ULONG Unknown);
+ IN BOOLEAN ThisYearsCutoverOnly);
NTSTATUS STDCALL
RtlDecompressBuffer(IN USHORT CompressionFormat,
_____
Modified: trunk/reactos/lib/rtl/time.c
--- trunk/reactos/lib/rtl/time.c 2005-01-07 09:21:53 UTC (rev
12863)
+++ trunk/reactos/lib/rtl/time.c 2005-01-07 12:58:46 UTC (rev
12864)
@@ -74,7 +74,7 @@
RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
OUT PLARGE_INTEGER SystemTime,
IN PLARGE_INTEGER CurrentTime,
- IN ULONG Unknown)
+ IN BOOLEAN ThisYearsCutoverOnly)
{
TIME_FIELDS AdjustedTimeFields;
TIME_FIELDS CurrentTimeFields;
@@ -82,6 +82,7 @@
LARGE_INTEGER CutoverSystemTime;
CSHORT MonthLength;
CSHORT Days;
+ BOOLEAN NextYearsCutover = FALSE;
/* Check fixed cutover time */
if (CutoverTimeFields->Year != 0)
@@ -105,45 +106,60 @@
RtlTimeToTimeFields(CurrentTime, &CurrentTimeFields);
- /* Compute the cutover time of the first day of the current month */
- 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;
+ while (TRUE)
+ {
+ /* Compute the cutover time of the first day of the current month
*/
+ AdjustedTimeFields.Year = CurrentTimeFields.Year;
+ if (NextYearsCutover == TRUE)
+ AdjustedTimeFields.Year++;
- if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
- return FALSE;
+ AdjustedTimeFields.Month = CutoverTimeFields->Month;
+ AdjustedTimeFields.Day = 1;
+ AdjustedTimeFields.Hour = CutoverTimeFields->Hour;
+ AdjustedTimeFields.Minute = CutoverTimeFields->Minute;
+ AdjustedTimeFields.Second = CutoverTimeFields->Second;
+ AdjustedTimeFields.Milliseconds = CutoverTimeFields->Milliseconds;
- RtlTimeToTimeFields(&CutoverSystemTime, &CutoverSystemTimeFields);
+ if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
+ return FALSE;
- /* 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);
+ RtlTimeToTimeFields(&CutoverSystemTime, &CutoverSystemTimeFields);
- AdjustedTimeFields.Day += Days;
- }
+ /* 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);
- /* Adjust the number of weeks */
- if (CutoverTimeFields->Day > 1)
- {
- Days = DAYSPERWEEK * (CutoverTimeFields->Day - 1);
- MonthLength =
MonthLengths[IsLeapYear(AdjustedTimeFields.Year)][AdjustedTimeFields.Mon
th - 1];
- if ((AdjustedTimeFields.Day + Days) > MonthLength)
- Days -= DAYSPERWEEK;
+ AdjustedTimeFields.Day += Days;
+ }
- AdjustedTimeFields.Day += Days;
+ /* Adjust the number of weeks */
+ if (CutoverTimeFields->Day > 1)
+ {
+ Days = DAYSPERWEEK * (CutoverTimeFields->Day - 1);
+ MonthLength =
MonthLengths[IsLeapYear(AdjustedTimeFields.Year)][AdjustedTimeFields.Mon
th - 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;
}
- if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
- return FALSE;
-
SystemTime->QuadPart = CutoverSystemTime.QuadPart;
return TRUE;
Show replies by date