Week numbers totally incorrect !!
- From: "Steph." <steph@xxxxxxxxxx>
- Date: Wed, 27 Apr 2005 14:54:25 +0200
|
Hi,
When I use
the "Calendar.GetWeekOfYear"
function (with "fr-BE" as CultureInfo and Monday as the first day of week) I get
: Friday 31/12/2004 : week =
53 Saturday 01/01/2005 : week =
1
That's very interesting but totally
incorrect !! Friday and Saturday of the same week should have the same week
number ! Except in DOTNET..
ISO 8601 say : Week 01 of a year is per definition the first week
that has the Thursday in this year, which is equivalent to the week that
contains the fourth day of January. In other words, the first week of a new year
is the week that has the majority of its days in the new year.
So the correct numbers are :
Friday 31/12/2004 : week =
53 Saturday 01/01/2005 : week = 53 Manday 03/01/2005 : week = 1
Is there any Patch for this bug
?? Thanks, Steph.
Code
sample : CultureInfo
myCI = new CultureInfo("fr-BE"); Calendar
MyCal = myCI.Calendar; CalendarWeekRule
myCWR = myCI.DateTimeFormat.CalendarWeekRule; DayOfWeek
myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek; MessageBox.Show(MyCal.GetWeekOfYear(Convert.ToDateTime("31/12/2004"),
myCWR, myFirstDOW).ToString()); |
- Follow-Ups:
- Re: Week numbers totally incorrect !!
- From: LOZANO-MORÁN, Gabriel
- Re: Week numbers totally incorrect !!
- From: LOZANO-MORÁN, Gabriel
- Re: Week numbers totally incorrect !!
- Prev by Date: Re: sockets: c# server with c++ client
- Next by Date: Re: Destructors are useless?
- Previous by thread: Textbox text isn't updating
- Next by thread: Re: Week numbers totally incorrect !!
- Index(es):