473,836 Members | 1,534 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 6104
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
5228
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
11354
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
1584
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
3903
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
3425
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
1535
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
2867
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
4077
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
1438
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
9671
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10846
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10551
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10595
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
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...
1
7793
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
6979
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
5828
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4458
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

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.