How to find week of month for calendar which starts from Monday?
<p>I have a calendar starting on Monday.</p>

<p><strong>May, 2011</strong></p>

<pre><code>----------------------------
Mon Tue Wed Thu Fri Sat Sun
----------------------------
25  26  27  28  29  30   1     week 1
2   3   4    5   6   7   8     week 2
9   10  11  12  13  14   15    week 3
16  17  18  19  20  21   22    week 4
23  24  25  26  27  28   29    week 5
30  31  1   2    3  4     5    week 6
</code></pre>

<p><strong>I want to find week of month on giving Date.</strong></p>

<p>Below works fine on the calendar that starts on Sunday.</p>

<pre><code>function getWeekOfMonth(date) {

  prefixes = ['1', '2', '3', '4', '5'];
  return prefixes[0 | date.getDate() / 7];
}
</code></pre>

<p>But in my Calendar (Monday based) if I choose <strong>May 1st</strong>, the return value if <strong>"1"</strong> thus
gives me <code>"week2"</code> but it should be <code>"week1"</code>.</p>

<p>If I choose May 15th, giving me "week4" instead of "week3".</p>

<p>It works on things like May 12th.</p>

<p>I tried to shift this one day gap (monday and sunday) and modified the algorithm which failed.</p>

<p>Could anyone show me how can I fix my algorithm correctly?</p>

<pre><code>function getWeekOfMonth(date) {

  prefixes = ['1', '2', '3', '4', '5'];
  return prefixes[0 | date.getDate() - 1 / 7];
}
</code></pre>
