473,388 Members | 1,340 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,388 software developers and data experts.

GregorianCalendar GetWeekOfYear - bug?

using System.Globalization;

GregorianCalendar cal = new GregorianCalendar();

int weekNum;

weekNum = cal.GetWeekOfYear(new DateTime(2007, 12, 30),
CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
// returns 52 (OK)

weekNum = cal.GetWeekOfYear(new DateTime(2007, 12, 31),
CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
// returns 53 (*** correct is 1 ***)

weekNum = cal.GetWeekOfYear(new DateTime(2008, 1, 1),
CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
// returns 1 (OK)
Dec 8 '05 #1
0 1475

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

Similar topics

1
by: cg_news | last post by:
I understand that the GregorianCalendar can be used to calculate the week of year for a date, and after instantiating a GregorianCalendar object with the no arg constructor, I can infact retrieve...
4
by: Pål Andreassen | last post by:
I'm trying to discover the number of weeks in a given year. As I live in Norway we are using the gregorian calendar. First week of a year is the first week with four days. First day of the week is...
2
by: Rustan | last post by:
Hi Im using GregorianCalendar to find out the current years week numbers. When the user chooses a week number in a dropdown i want to show that week in a table with the corresponding dates. For...
3
by: Soren Jorgensen | last post by:
Hi, Following code should give the number of weeks in years 1998-2010 for a Danish calendar (on a Danish box) GregorianCalendar cal = new GregorianCalendar(); for(int i = 1998; i < 2010; i++)...
3
by: bp | last post by:
I'm using the System.Globalization.GregorianCalendar class to calculate week numbers. My weeks begin on Saturday and follow the "first four day" rule. GregorianCalendar cal = new...
1
by: AliceG | last post by:
Hi all, By using JOptionPane, I'm trying to do this little program with Notepad for generating a password from the user's first two letters of the first name, the age calculated as a difference of...
1
by: cnixuser | last post by:
I am currently working on an "experimental" simple java program to allow me to learn how to work with arrays of GregorianCalendars. Is there a reason why these two lines of code temp2.set(1902, 11,...
10
by: Mika M | last post by:
Hi! I'm converting some methods of VB-class into C#-class for another project. It's quite easy, but when converting method which returns last week number of the entered year I got problems. The...
2
by: Shamim1983 | last post by:
I want to find difference between 2 dates in number of months using GregorianCalendar utility. I want it to work fine considering the year having 28, 29, 30 or 31 days in month. It should give me...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
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,...

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.