From dad0922fdacf62ea2b4cb8af61171e24781624d9 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Mon, 30 Sep 2002 20:57:54 +0000 Subject: [PATCH] Fixed the value for EPOCHWEEKDAY. Improve converting speed in RtlTimeToTimeFields. svn path=/trunk/; revision=3584 --- reactos/lib/ntdll/rtl/time.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reactos/lib/ntdll/rtl/time.c b/reactos/lib/ntdll/rtl/time.c index 39c94201114..fd263351597 100644 --- a/reactos/lib/ntdll/rtl/time.c +++ b/reactos/lib/ntdll/rtl/time.c @@ -1,4 +1,4 @@ -/* $Id: time.c,v 1.12 2002/09/08 10:23:07 chorns Exp $ +/* $Id: time.c,v 1.13 2002/09/30 20:57:54 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -23,7 +23,7 @@ #define SECSPERMIN 60 #define MINSPERHOUR 60 #define HOURSPERDAY 24 -#define EPOCHWEEKDAY 0 +#define EPOCHWEEKDAY 1 #define DAYSPERWEEK 7 #define EPOCHYEAR 1601 #define DAYSPERNORMALYEAR 365 @@ -139,6 +139,13 @@ RtlTimeToTimeFields(PLARGE_INTEGER liTime, /* compute year */ CurYear = EPOCHYEAR; + CurYear += Days / DAYSPERLEAPYEAR; + Days -= (CurYear - EPOCHYEAR) * DAYSPERLEAPYEAR; + CurYear--; /* The next calculation needs CurYear - 1 */ + Days += CurYear - CurYear / 4 + CurYear / 100 - CurYear / 400; + CurYear++; + Days -= EPOCHYEAR - 1 - (EPOCHYEAR -1) / 4 + (EPOCHYEAR -1) / 100 - (EPOCHYEAR - 1) / 400; + /* FIXME: handle calendar modifications */ while (1) { @@ -153,6 +160,7 @@ RtlTimeToTimeFields(PLARGE_INTEGER liTime, TimeFields->Year = (CSHORT) CurYear; /* Compute month of year */ + LeapYear = IsLeapYear(CurYear); Months = MonthLengths[LeapYear]; for (CurMonth = 0; Days >= (long) Months[CurMonth]; CurMonth++) Days = Days - (long) Months[CurMonth];