473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Week numbers totally incorrect !!

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

(see code sample here below)



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.ToDate Time("31/12/2004"), myCWR, myFirstDOW).ToString());



MessageBox.Show(MyCal.GetWeekOfYear(Convert.ToDate Time("01/01/2005"), myCWR, myFirstDOW).ToString());
Jul 21 '05 #1
2 1564
Hi Steph,

That is certainly very odd. However, I suspect that this is by design as the CalendarWeekRule of fr-BE is FirstDay and setting the CalendarWeekRule to FirstDay for nb-NO will return week 1 for 2005.1.1 where it would be week 53 for by default with FirstFourDayWeek.

I'm not familiar with the FirstDay rule and AFAIK it means the week number does not carry over to the next year.
Just a thought.

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #2
I made a quick test (I'm French).

It looks like to me that the rule is incorrect for this culture (as well as
for France).

For now using :

CalendarWeekRule myCWR = System.globalization.FirstForuDayWeek ; //
myCI.DateTimeFormat.CalendarWeekRule; (this is FirstDay)

seems to work. Double check this.

For now it looks like the cultural settings are not correct...

Patrice
--

"Steph." <st***@nomail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

(see code sample here below)

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.ToDate Time("31/12/2004"), myCWR,
myFirstDOW).ToString());

MessageBox.Show(MyCal.GetWeekOfYear(Convert.ToDate Time("01/01/2005"), myCWR,
myFirstDOW).ToString());
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Stig Andersen | last post by:
Hi does anyone know how to make MS SQL server 2000 calculate the right week number around new year ? According to the help file, MSSQL should follow ISO8601, which ensures that i.e. 2003 has...
10
by: Ty Smith via AccessMonster.com | last post by:
I noticed that the week numbers in Stephan Leban's MonthCalendar are not consistent with Microsoft Outlook (they are shifted one week forward). Is there any way I can sync these two up by changing...
9
by: Ray | last post by:
I need to convert the normal calendar to show the week no., the period no. and the financial year. The financial year format is as follows:- Date start: 2 May, 2005 7 days a week, 4 weeks a...
1
by: Steph. | last post by:
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
2
by: Steph. | last post by:
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
10
by: Jim | last post by:
I'm sure this has been asked before but I can't find any postings. I have a table that has weekly inspections for multiple buildings. What I need to do is break these down by the week of the...
0
by: JosAH | last post by:
Greetings, Introduction At this moment we have a TextProcessor, a LibraryBuilder as well as the Library itself. As you read last week a Library is capable of producing pieces of text in a...
3
by: mtek | last post by:
Hi, I am using this code to get the day number of the week: var numbers = entered.split('/'); var daynum = (new Date(Date.UTC(numbers - 1900,numbers,numbers-1))).getUTCDay(); Date comes in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.