473,320 Members | 1,988 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,320 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());

Nov 17 '05 #1
3 6074
CalendarWeekRule myCWR = CalendarWeekRule.FirstFourDayWeek;
Indicates that the first week of the year starts on the first day of the
year and ends before the following designated first day of the week.

CalendarWeekRule myCWR = CalendarWeekRule.FirstFourDayWeek;
Indicates that the first week of the year is the first week with four or
more days before the designated first day of the week.

CalendarWeekRule myCWR = CalendarWeekRule.FirstFullWeek;
Indicates that the first week of the year begins on the first occurrence of
the designated first day of the week on or after the first day of the year.

No need to say what the default is for culture fr-BE :-)

Gabriel Lozano-Morán
"Steph." <st***@nomail.com> wrote in message
news:OG**************@tk2msftngp13.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());
Nov 17 '05 #2
What you can also do is use your Windows settings by using the following constructor for CultureInfo (passing true as second param)
CultureInfo myCI = new CultureInfo("fr-BE", true);

Gabriel Lozano-Morán
Nov 17 '05 #3

THANK-YOU !!!! It works correctly now !

I was thinking that by setting the correct CultureInfo the Calendar rule was automaticaly adapted ... bug was in my head !

Steph.
"LOZANO-MORÁN, Gabriel" <ga************@no-spam.com> wrote in message news:uQ**************@TK2MSFTNGP15.phx.gbl...
CalendarWeekRule myCWR = CalendarWeekRule.FirstFourDayWeek;
Indicates that the first week of the year starts on the first day of the
year and ends before the following designated first day of the week.

CalendarWeekRule myCWR = CalendarWeekRule.FirstFourDayWeek;
Indicates that the first week of the year is the first week with four or
more days before the designated first day of the week.

CalendarWeekRule myCWR = CalendarWeekRule.FirstFullWeek;
Indicates that the first week of the year begins on the first occurrence of
the designated first day of the week on or after the first day of the year.

No need to say what the default is for culture fr-BE :-)

Gabriel Lozano-Morán
"Steph." <st***@nomail.com> wrote in message
news:OG**************@tk2msftngp13.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());
Nov 17 '05 #4

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...
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: 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
0
by: Lee Harr | last post by:
I wrote a function to return the first date of a given week (and a few related functions) : -- return the first date in the given week CREATE or REPLACE FUNCTION week_start(integer, integer)...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.