S
Soren Jorgensen
Hi,
Following code should give the number of weeks in years 1998-2010 for a
Danish calendar (on a Danish box)
GregorianCalendar cal = new GregorianCalendar();
for(int i = 1998; i < 2010; i++)
{
DateTime date = new DateTime(i, 12, 31);
int week= cal.GetWeekOfYear(date,
CalendarWeekRule.FirstFourDayWeek,
DayOfWeek.Monday);
Debug.WriteLine( String.Format("Last week in year {0:0} = {1:0}", date.Year,
week));
}
Last week in year 1998 = 53 - OK
Last week in year 1999 = 52 - OK
Last week in year 2000 = 52 - OK
Last week in year 2001 = 53 - Wrong, only 52
Last week in year 2002 = 53 - Wrong, only 52
Last week in year 2003 = 53 - Wrong, only 52
Last week in year 2004 = 53 - OK
Last week in year 2005 = 52 - OK
Last week in year 2006 = 52 - OK
Last week in year 2007 = 53 - Wrong, only 52
Last week in year 2008 = 53 - Wrong, only 52
Last week in year 2009 = 53 - Wrong, only 52
Does anyone see the same pattern as I, and do anyone know why this happens
??
Kind regards, and thanx in advance...
Soren
Following code should give the number of weeks in years 1998-2010 for a
Danish calendar (on a Danish box)
GregorianCalendar cal = new GregorianCalendar();
for(int i = 1998; i < 2010; i++)
{
DateTime date = new DateTime(i, 12, 31);
int week= cal.GetWeekOfYear(date,
CalendarWeekRule.FirstFourDayWeek,
DayOfWeek.Monday);
Debug.WriteLine( String.Format("Last week in year {0:0} = {1:0}", date.Year,
week));
}
Last week in year 1998 = 53 - OK
Last week in year 1999 = 52 - OK
Last week in year 2000 = 52 - OK
Last week in year 2001 = 53 - Wrong, only 52
Last week in year 2002 = 53 - Wrong, only 52
Last week in year 2003 = 53 - Wrong, only 52
Last week in year 2004 = 53 - OK
Last week in year 2005 = 52 - OK
Last week in year 2006 = 52 - OK
Last week in year 2007 = 53 - Wrong, only 52
Last week in year 2008 = 53 - Wrong, only 52
Last week in year 2009 = 53 - Wrong, only 52
Does anyone see the same pattern as I, and do anyone know why this happens
??
Kind regards, and thanx in advance...
Soren