title: C#: Get all week numbers from within 2 dates globalized/ISO 8601 compatible
body: <p>I have a </p>
  
  <p><em>startdate</em> <strong>2010-01-01</strong> (I just assume its a first day of the week)</p>
  
  <p>and an</p>
  
  <p><em>enddate</em> <strong>2010-07-31</strong> (I just assume its a first day of the week)</p>
  
  <p>I want to have returned from a method all week numbers for every first day of the week for the </p>
  
  <p>above timespan. I can not assume that the first day of week is always monday, because my user </p>
  
  <p>could be from <strong>Sweden</strong>, <strong>USA</strong> or whereever. The algorythm should be compatible with ISO 8601.</p>
  
  <p>The final result should look roughly like this:</p>
  
  <pre><code>2010-01-01 , 1
  2010-01-08 , 2
  2010-01-15 , 3
  2010-01-22 , 4
  ...
  2010-07-31 , ~28
  </code></pre>
  
  <p>Yes I know google is full of links about that topic but nobody is doing it right. They all </p>
  
  <p>assume that monday is first day of a week. Maybe some of the c# gods on SO pass by :P</p>
  
  <p>EDIT:</p>
  
  <p>What do you say to this code:</p>
  
  <pre><code>public static int GetWeekNumber(DateTime dtPassed)
          {
              CultureInfo ciCurr = CultureInfo.CurrentCulture;
              int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstDay, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek);
              return weekNum;
          }
  </code></pre>
  
  <p>I found it partly on google and changed it a bit.</p>