473,946 Members | 19,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gregorian Calendar - GetWeekOfYear for 2005

bp
I'm using the System.Globaliz ation.Gregorian Calendar class to calculate
week numbers. My weeks begin on Saturday and follow the "first four
day" rule.

GregorianCalend ar cal = new GregorianCalend ar();
week = cal.GetWeekOfYe ar("12/31/2005",
CalendarWeekRul e.FirstFourDayW eek, DayOfWeek.Satur day);

GetWeekOfYear() returns "53" for "12/31/2005", even though there are
only 52 weeks in 2005. "12/30/2005" correctly returns "52", and
"1/1/2006" correctly returns "1".

Can someone explain this to me? Is this intended behavior or is this a
bug in the GregorianCalend ar class?

Thanks in advance.

Nov 16 '05 #1
3 4477
> I'm using the System.Globaliz ation.Gregorian Calendar class to
calculate week numbers. My weeks begin on Saturday and follow the
"first four day" rule.

GregorianCalend ar cal = new GregorianCalend ar();
week = cal.GetWeekOfYe ar("12/31/2005",
CalendarWeekRul e.FirstFourDayW eek, DayOfWeek.Satur day);
GetWeekOfYear() returns "53" for "12/31/2005", even though there are
only 52 weeks in 2005. "12/30/2005" correctly returns "52", and
"1/1/2006" correctly returns "1".

Can someone explain this to me? Is this intended behavior or is this
a bug in the GregorianCalend ar class?

Thanks in advance.


Check it on a calendar, looks correct to me.
12/30 is a Friday, the end of the 52nd week.
12/31 is a Saturday, the beginning of the 53rd week (1 day week).

Nov 16 '05 #2
bp
The project I'm working on is a fiscal calendar that doesn't provide
for "partial weeks" (ie. a week with less than 7 days). In this case I
want "12/31/2005" to be the first day of fiscal week "1" for 2006. The
first week of 2006 would be the week beginning on "12/31/2005" because
that week contains "4 or more" days in January...
I see now that this is not how the GregorianCalend ar works...do you
know if there's another calendar with a GetWeekOfYear() method
supporting this calculation?
Thanks for the response.

Nov 16 '05 #3
One way to handle this is check the week of 1/1/2006, and also the DayOfWeek
for 1/1/2006. If it returns 3 or more (wednesday or later), add 1 to the
week count, and thus get the correct fiscal week.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"bp" <ba*****@i-55.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
The project I'm working on is a fiscal calendar that doesn't provide
for "partial weeks" (ie. a week with less than 7 days). In this case I
want "12/31/2005" to be the first day of fiscal week "1" for 2006. The
first week of 2006 would be the week beginning on "12/31/2005" because
that week contains "4 or more" days in January...
I see now that this is not how the GregorianCalend ar works...do you
know if there's another calendar with a GetWeekOfYear() method
supporting this calculation?
Thanks for the response.

Nov 16 '05 #4

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

Similar topics

3
9763
by: sunny076 | last post by:
Hi, I am trying to convert from Julian to Gregorian data in C#. I was exploring teh JulianCalendar and Gregorian calendar classes but still not sure how I can do it. For example, the Julian date is 100033 and I know that it is 2/2/2000 in Gregorian. I would appreciate if anyone can help point me out.
5
16108
by: SalimShahzad | last post by:
Dear Respected Gurus, I need a coding assistant converting from gregorian to hijri and vice versa. I have problem with this codes. the problem Gregorian to Hijri gives 100% results. when i enter this to Hijri to gregorian it either do nothing or go to next record on form. well there r two fields on form that r calc afterevents each other dates. ur assistance will be highly appreciated, if any one can tell what is wrong with this codes
1
4553
by: Sam | last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on following guideline found at Internet? To convert Julian date to Gregorian date: double JD = 2299160.5; double Z = Math.Floor(JD+0.5); double W = Math.Floor((Z - 1867216.25)/36524.25); double X = Math.Floor(W/4);
1
1270
by: ReidarT | last post by:
How do I find the weeknumber from a selected date from the calendar? regards reidarT
0
1505
by: TibX | last post by:
using System.Globalization; GregorianCalendar cal = new GregorianCalendar(); int weekNum; weekNum = cal.GetWeekOfYear(new DateTime(2007, 12, 30), CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); // returns 52 (OK)
2
2375
by: Brenden Bixler | last post by:
Hello. I am using the ASP.NET calendar object and am looking to provide a "weekly view", but not the typical "Outlook" style. Rather, I just want it to render the calendar normally, but only display the current week and not any of the other weeks within the given month. If this isn't possible with the built-in component, has anyone else solved this issue with a third party component?
14
16918
by: pdavis06 | last post by:
I know that there is a thread about this, but I was unable to add to it; I just joined. The problem is that I do not want to change the date format for the entire database output, merely for a header on a report and for a field on that report. I thought that I could just go into the expression builder and paste one of the codes that were posted in the thread about this conversion-you'll know that did not work. So, I went to the new...
2
3968
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i am using this code: http://weblogs.asp.net/rosherove/archive/2004/09/13/228688.aspx i am passing for example 10/03/1975 and i get the hebrew date : "כ"ז אדר תשל"ה" now i want to do the opposite direction which means to give the hebrew date andget the gregorian date - how can i do that? thnaks in advance peleg
3
2571
by: nisse2562 | last post by:
this code: http://pastebin.com/f168570c8 gives the compile error: test_templates.cpp: In function 'int main(int, char**)': test_templates.cpp:51: error: expected `(' before 'g' test_templates.cpp:51: error: expected `)' before ';' token test_templates.cpp:51: error: invalid const_cast from type 'bar<lab2::Gregorian>' to type 'bar<lab2::Julian>*' where the Julian and Gregorian are date classes that inherit from Date How do I "make" the...
0
10162
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9981
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
11153
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
11340
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,...
1
8253
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
6112
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6331
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4943
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
3
3541
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.