Author: mkupfer Date: Fri Aug 1 12:43:53 2008 New Revision: 35016
URL: http://svn.reactos.org/svn/reactos?rev=35016&view=rev Log: - extended range for calendar view for years 1900-9999, each selectable year/month combination creates a correct month view - special case september 1752 partly prepared, but disabled as long as unneeded ;-) - enable via #define WITH_1752
Modified: trunk/reactos/dll/cpl/timedate/monthcal.c
Modified: trunk/reactos/dll/cpl/timedate/monthcal.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/timedate/monthcal.c... ============================================================================== --- trunk/reactos/dll/cpl/timedate/monthcal.c [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/timedate/monthcal.c [iso-8859-1] Fri Aug 1 12:43:53 2008 @@ -75,6 +75,19 @@ return Ret; }
+/* + * for the year range 1..9999 + * return 1 if is leap year otherwise 0 + */ +static WORD LeapYear(IN WORD Year) +{ + return +#ifdef WITH_1752 + (Year <= 1752) ? !(Year % 4) : +#endif + !(Year % 4) && ((Year % 100) || !(Year % 400)); +} + static WORD MonthCalMonthLength(IN WORD Month, IN WORD Year) @@ -82,9 +95,16 @@ const BYTE MonthDays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
if(Month == 2) - return MonthDays[Month - 1] + ((Year % 400 == 0) ? 1 : ((Year % 100 != 0) && (Year % 4 == 0)) ? 1 : 0); + return MonthDays[Month - 1] + LeapYear(Year); else - return MonthDays[Month - 1]; + { +#ifdef WITH_1752 + if ((Year == 1752) && (Month == 9)) + return 19; // special case: September 1752 has no 3rd-13th + else +#endif + return MonthDays[Month - 1]; + } }
static WORD @@ -134,7 +154,7 @@ if (Month < 1 || Month > 12 || Day == 0 || Day > MonthCalMonthLength(Month, Year) || - Year < 1980 || Year > 2099) + Year < 1899 || Year > 9999) { return FALSE; }