Standing on the shoulders of giants. RSS 2.0
# Tuesday, June 26, 2007

The week number depends on 4 variables:

  1. The date you're interested in,
  2. The calendar you use (e.g. Gregorian, Julian, Hebrew etc.)
  3. The first day of the week
  4. The week you count as 1 (e.g. the week containing Jan 1, the first 4 day week etc.)

 

All these parameters are included in the Calendar.GetWeekOfYear method, as shown in the following code snippet:

// instantiate the calendar used in the Netherlands
Calendar calendar = new GregorianCalendar();

// get the current week for the Netherlands
calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);


// and for the USA
calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
Tuesday, June 26, 2007 6:31:55 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] - Trackback
Codesnippet
Comments are closed.
Ads
About
© Copyright 2012
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.2011.0
All Content © 2012, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)