473,608 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Week numbers totally incorrect !!

Hi,

When I use the "Calendar.GetWe ekOfYear" 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;

CalendarWeekRul e myCWR = myCI.DateTimeFo rmat.CalendarWe ekRule;

DayOfWeek myFirstDOW = myCI.DateTimeFo rmat.FirstDayOf Week;



MessageBox.Show (MyCal.GetWeekO fYear(Convert.T oDateTime("31/12/2004"), myCWR, myFirstDOW).ToS tring());



MessageBox.Show (MyCal.GetWeekO fYear(Convert.T oDateTime("01/01/2005"), myCWR, myFirstDOW).ToS tring());

Nov 17 '05 #1
3 6094
CalendarWeekRul e myCWR = CalendarWeekRul e.FirstFourDayW eek;
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.

CalendarWeekRul e myCWR = CalendarWeekRul e.FirstFourDayW eek;
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.

CalendarWeekRul e myCWR = CalendarWeekRul e.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.c om> wrote in message
news:OG******** ******@tk2msftn gp13.phx.gbl...
Hi,

When I use the "Calendar.GetWe ekOfYear" 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;
CalendarWeekRul e myCWR = myCI.DateTimeFo rmat.CalendarWe ekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFo rmat.FirstDayOf Week;

MessageBox.Show (MyCal.GetWeekO fYear(Convert.T oDateTime("31/12/2004"), myCWR,
myFirstDOW).ToS tring());

MessageBox.Show (MyCal.GetWeekO fYear(Convert.T oDateTime("01/01/2005"), myCWR,
myFirstDOW).ToS tring());
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******** ******@TK2MSFTN GP15.phx.gbl...
CalendarWeekRul e myCWR = CalendarWeekRul e.FirstFourDayW eek;
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.

CalendarWeekRul e myCWR = CalendarWeekRul e.FirstFourDayW eek;
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.

CalendarWeekRul e myCWR = CalendarWeekRul e.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.c om> wrote in message
news:OG******** ******@tk2msftn gp13.phx.gbl...
Hi,

When I use the "Calendar.GetWe ekOfYear" 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;
CalendarWeekRul e myCWR = myCI.DateTimeFo rmat.CalendarWe ekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFo rmat.FirstDayOf Week;

MessageBox.Show (MyCal.GetWeekO fYear(Convert.T oDateTime("31/12/2004"), myCWR,
myFirstDOW).ToS tring());

MessageBox.Show (MyCal.GetWeekO fYear(Convert.T oDateTime("01/01/2005"), myCWR,
myFirstDOW).ToS tring());
Nov 17 '05 #4

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

Similar topics

2
5207
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 appreciated. TIA
4
11333
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 only 52 weeks. but these two prove it wrong: Select datepart(ww,'2003/12/31') --(wednesday -> returns 53) Select datepart(ww,'2004/1/1') --(thursday -> returns 1) Well - the weeknumber does not change in the middle of the week. Since
2
1576
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
3880
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 something in the module or the code in Stephan's MonthCalendar? Thanks, TySmith -- Message posted via http://www.accessmonster.com
9
3412
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 period and 13 periods a year. normally 52 weeks per year but one 53-week a year every 6 years. The 53th week is included in period 13. Can someone advise any idea how to construct such conversion.
1
1529
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
2847
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) RETURNS date AS ' DECLARE pyear ALIAS FOR $1; pweek ALIAS FOR $2;
10
1251
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 month of my choosing. Let me explain; I can get my week numbers no problem. I can get the date from the week numbers no problem. What I haven't been able to do is put things together and make a simple function that will allow my users to select from...
0
4054
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 simple way. We also briefly mentioned the BookMark which represents a single paragraph of text. We haven't seen it's implementation yet. This is the topic of this week's article part.
3
1427
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 as MM/DD/YYYY
0
8059
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.