title: Matching Outlook Week Numbering in .Net
body: <p>my current app uses week numbers (as in week x of 52).  The business want this to match the default MS Outlook behaviour, which is a rule it calls 'Starts on Jan 1'.  (We use weeks starting on Monday.  There is a mixture of Outlook 2003 and 2007).</p>
  
  <p>This rule looks at the working week which includes the 1st of the year, and makes that working week 'week 1'.  So to look at 2009/2010 as an example, the weeks would be:</p>
  
  <p>week 52: Mon 21st Dec - Sun 27th Dec<br>
  Week 1:  Mon 28th Dec - Sun 3rd Jan<br>
  Week 2:  Mon 4th Jan  - Sun 10th Jan</p>
  
  <p>These week numbers are what Outlook shows alongside the weeks in any of the monthly views.</p>
  
  <p>The problem I'm having is getting code to replicate these.  The current code uses CultureInfo to work it out, but it's not the same.  There are three different rules you can apply, but none match Outlook - None of them include any day of 2009 in week 1 of 2010 as Outlook does.</p>
  
  <p>Here's the code I'm using to find the week number:</p>
  
  <pre><code>int weekNum = culture.Calendar.GetWeekOfYear(baseDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
  </code></pre>
  
  <p>You can see here what the three different available rules give (with the Outlook definition on the end):</p>
  
  <p>Culture: English (United Kingdom)</p>
  
  <pre>
  (Rule: 1st Day | 4 Day | FullWeek | Outlook)
  
  27/12/2009: 52 |    52 |    51 | 52  
  28/12/2009: 53 |    53 |    52 | 1  
  29/12/2009: 53 |    53 |    52 | 1  
  30/12/2009: 53 |    53 |    52 | 1  
  31/12/2009: 53 |    53 |    52 | 1  
  01/01/2010: 01 |    53 |    52 | 1  
  02/01/2010: 01 |    53 |    52 | 1  
  03/01/2010: 01 |    53 |    52 | 1  
  04/01/2010: 02 |    01 |    01 | 2  
  05/01/2010: 02 |    01 |    01 | 2  
  </pre>
  
  <p>Does anyone know if there's a simple-ish way to match the Outlook weeks?  I don't want to rely on having Outlook installed and using interop, as that may not always be the case.</p>
  
  <p>Thanks</p>